Hi @Nayz:
Menus in Pico-8 are quite easy to create. Try copying this code directly to Pico-8:
function _init() cls() menuitem(1,"try this",function()this()end) end function _update() end function this() print("that") end |
Run this code. Press "P" to pause it and bring up the menu. Notice the new menu item, TRY THIS
Select it to run the function this() which returns the text, THAT
You can find full help on this feature HERE:
https://www.lexaloffle.com/dl/docs/pico-8_manual.html#Custom_Menu_Items
hope This Helps !
@BogdaBard oh, haha, didn't realize it was that easy to do that. Any way to avoid the possibility of that happening?
One way to handle multiple screens is to store the sprite position data for each screen, then track a screen state var.
There are methods to make this less token-intensive if you reach token limits, such as string splitting.
screen_sprites={} screen_1_sprites={{sprite_id,x,y},{sprite_id,x,y}} add(screen_sprites,screen_1_sprites) screen_2_sprites={{sprite_id,x,y},{sprite_id,x,y}} add(screen_sprites,screen_2_sprites) -- and so on; good use case for a function |
Then when you want to switch screens, just switch which collection of sprites you're drawing.
screen=1 current_sprites=screen_1_sprites if(btnp(0))screen-=1 if(btnp(1))screen+=1 if(screen>#screen_sprites)screen=1 if(screen<0)screen=#screen_sprites current_sprites=screen_sprites[screen] -- draw the sprites |
Alternate button handling
if(btnp(0))screen=max(0,screen-1) if(btnp(1))screen=min(#screen_sprites,screen+1) |
You might also just have a single collection of sprite tables, and give each sprite table a screen number. Then your draw function would check each sprite's screen number against the current screen number and draw if it matches.
Another way to avoid overflows is to use 0x0.0001 as your increment - tostr() has a feature to print PICO-8 numbers as integers, which increases the limit from 32,767 to 2,147,483,647.
Which still might be too small for a really aggressive clicker game, but at that point it probably makes sense to implement bignums in some way.
[Please log in to post a comment]