This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- inside init have a collection called particles | |
particles = {} | |
-- adder function, you call this anytime you want to add a new particle | |
-- to the system | |
function add_particle(_x, _y, _sx, _sy, _lifetime, _color, _type) | |
-- create particle | |
local part = { | |
x = _x, | |
y = _y, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- For this I whipped up my good ol’ reliable approach of having the following functions: | |
-- export the currently drawn map to the clipboard | |
-- I used this in copied .p8 files to draw levels, | |
-- run them and copy the given string into this main | |
-- file's map collection | |
function export_map() | |
-- start with empty string | |
local mapString = "" | |
-- loop over the map tile by tile | |
-- and append tile numbers by , after each other |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- function to add characters to the game | |
-- at any point on the map | |
function add_character(_x, _y) | |
local p = { | |
x = _x, | |
y = _y, | |
direction = 5, | |
doReplaceOldTile = false, | |
replaceTileId = 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Or if you don't want to bother with drawing each pickup with every tile aviable to you, you can make them "objects". | |
--For this, create an array, that will hold all our pickups: | |
pickupCollection = {} | |
-- and a function that you can call to add pickups. | |
-- we include a _type so later you can differentiate them | |
-- by checking the this. For ex: _type = 1 is a healing item, _type = 2 is a bomb etc... | |
function add_pickup(_xPosition, _yPosition, _type) | |
-- we create a local variable to hold the item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function replace() | |
-- collection for the if is it this tile | |
local tilesToCheck = {1,2,3,4,5,6} | |
-- collection to replace tile | |
local tilesToReplace = {10,20,30,40,50,60} | |
local x,y = 0,0 | |
for i=1,#tilesToCheck do | |
if mget(x,y) == tilesToCheck[i] then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pico-8 cartridge // http://www.pico-8.com | |
version 42 | |
__lua__ | |
-- selector library | |
-- by achiegamedev | |
-- the selector object you will be playing and | |
-- calling around with. You can create a new | |
-- one by calling selector:init({object}) | |
-- where object has the same values as here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elseif state == "tools" then | |
-- pressing left will only move you to first item | |
if btnp(0) then toolbar.cursor = max(0, toolbar.cursor-1) end | |
-- pressing right will only mvoe to the last item | |
if btnp(1) then toolbar.cursor = min(12, toolbar.cursor+1) end | |
-- if we are on tools I want to have a float-in menu | |
-- that comes in from the bottom, showcasing the tools | |
toolbar.y = lerp(toolbar.y, toolbar.yOnScreen, 0.2) | |
-- go back to planning phase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pico-8 cartridge // http://www.pico-8.com | |
version 42 | |
__lua__ | |
-- I would create an enemy adder function that | |
-- creates enemies at certain positions (basically spawn them in) | |
function add_enemy(_x, _y, _type) | |
-- if youw ant to store enemy properties, I'd do it here in an array | |
-- for ex: | |
--[[ | |
local enemyData = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- here we modifiy the creation to accomodate | |
-- the tutorial, where we are gonna show the | |
-- player which stance beats what | |
if tutorial > 0 then | |
tutorial -= 1 | |
if tutorial > 0 then | |
-- based on which tutorial we are in, set the enemy stance so that is beatable | |
-- by the other table inside the players code when we are about to resolve the fight | |
local tutorialBeatTable = {MID_STANCE,LOW_STANCE, MID_STANCE, HIGH_STANCE} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- transiton effect is from DW from the lexaloffle bbs | |
function draw_transition_effect() | |
-- magic circle does the | |
-- opposite of circfill and | |
-- instead erases the outside | |
-- of the circle first | |
for i=64,transition,-1 do | |
circ(32,32,i,11) | |
circ(33,32,i,11) | |
end--next i |
NewerOlder