I've noticed the min
and max
functions have a surprisingly high CPU cost.
For example
a=stat(1) for i=1,1000 do b=min(1,2) end print(stat(1)-a) |
Outputs:0.103
Which is almost twice the CPU cost for sqrt()
a=stat(1) for i=1,1000 do b=sqrt(2) end print(stat(1)-a) |
Outputs:0.054
And even if I define my own "min" function in lua, it's still a lot faster.
function mymin(a,b) return a<b and a or b end a=stat(1) for i=1,1000 do b=mymin(1,2) end print(stat(1)-a) |
Outputs:0.057
Is this a mistake?



Hello,
Short time listener, first time caller here. I apologize in advance if this is a basic question!
I'm pretty new to Pico-8 and Picotron development, and I'm trying to set up functionality to allow a little character to jump when I press space. Good news is I can get it to jump. Bad news is that if I hold space, it keeps jumping.
I'm using keyp to handle the button press, like below in my jumping/falling code. Apologies in advance if this code is less than stellar...I'm more a web guy than a game dev.
function updatePlayerYSpeed(entity) oldSpeed=entity.ySpeed if(keyp("space") and not entity.isFalling and not entity.isJumping) then entity.isJumping=true end if(entity.isJumping and entity.ySpeed>-entity.maxSpeed) then if(entity.ySpeed>0) then entity.ySpeed = 0 end return entity.ySpeed-entity.speedMod elseif(entity.y<yMax) then entity.isFalling=true entity.isJumping=false return entity.ySpeed+gravity [ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=156333#p) |

This cart shows what I think is a bug with the garbage collector interacting with weakrefs. Nothing should be drawn, yet sprite zero is shown. I'm not entirely sure how to show code here? I'm new!
Here are the steps:
Create a table with weakref values.
Add a value to that table.
Pass that table to a function.
The function uses a LOCAL variable to iterate over ALL() values of the table.
Return
The LOCAL variable holds a reference to the last member of the table. The LOCAL variable doesn't appear to get correctly garbage collected, and so neither does the last table member.
Weirdly, if I run stat(0) inside the function with the iterator, all is well. If I run it outside the function, nothing works.


You are a ship collector with questionable methods of obtainment.
Collect the 100 unique ships! Embarrass the police when they try to catch you!
🅾️
Primary weapon (hold to shoot and charge Secondary)
Secondary weapon (release and press)
Repair (mash!)
❎
Tertiary weapon
Press ❎ in hangar to see upcoming enemies.
Features:
- 2 player co-op!
- 100 unique ships!
- 10 different weapon systems!
- Progressive difficulty!
- Particle effects!
- Embarrass the police without real world implications!
Change log:







pico-api is a project consisting of definition files for the sumneko/lua extension for VSCode, allowing you to write PICO-8 or Picotron programs with the support of modern editor features.
Usage
- Install and enable sumneko/Lua extensions in VSCode Marketplace

-
Put the folder
.vscode/
andlibrary/
into your workspace. -
Create Lua files in your VSCode workspace.
- Create a cartridge and include the Lua file in it with:
-- picotron cd("/myproj") include("main.lua") |
-- pico8 #include main.lua |
Then you can write code in the workspace of VSCode and enjoy code prompts, formatting, AI copilot, etc.
.png)





.png)




On vacation recently, I was excited about seeing Mt Fuji from a ropeway the next day and made a quick tweetcart about it! 275 bytes
(275 chars)
pal({7,12,140,13,129,1,5,8,8,14,142,143,7},1)r=rnd::_::x=r(128)y=r(128)c=9+y/26-2+r(1.5) if(y<((x+40)/6)^1.6and y<((178-x)/6)^1.6and y<79+r(2))c=2.5-sgn(y-45-sin(x/21)*r(4))*1.5+r(2.5-sgn(x-69-r(8)-y/3+25)*.7) pset(x,128-y,c)a=r(1)d=r(25)pset(28+sin(a)*d,30+cos(a)*d,9)goto _ |





You are trapped alone in a forest, and must find a source of warmth...
Oh, and you're also blind.
Directions
- So... what do I do again?
Use the arrow keys to move. Please avoid running into walls.
- Wait! But I can't see the walls!
Use X + an arrow key to check in a particular direction for walls.
- Okay, but where am I going?
Press Z to check the temperature.
- "Warmer" means you're getting closer.
- "Colder" means you're getting further.
- "..." means that it's the same distance away as the last time you checked, or that you haven't moved since last checking.
- Closer to what?
The exit, which will allow you to select a power-up, then take you to the next level.
- Pfft, this is going to be easy.
Keep an eye on the meter towards the bottom. When it runs out, you freeze to death.
- oh. . .
Tips
Tiles are "remembered" (become visible) as you traverse the level (or check things or run into stuff). However, they also fade from memory over time.
As you get closer to the exit, "embers" will become visible to help guide you.
Remember to eat some stew between levels, whenever possible. You might not last too long if you don't...
And finally
I had this weird idea in my head for a while, of some sort of dungeon crawler where the player would only be able to see tiles that they had visited recently. So I decided to create it. It took me a little under a week to finish this, though it isn't really a dungeon crawler anymore.
This is my first complete PICO-8 game. Hopefully it's fun. Enjoy!
--J. M. Potionwiz



rainbow spiral (64 second loop)
(256 chars)
::★::cls() for r=4,128,4 do for i=0,7/4,1/4do q=(t()*(1+r/32)/8)%1 v0=mid((q-i)*4,1) v1=mid((q-i)*4+2,1) a=i-1/8 x=64+cos(a)*r*0.71 y=64+sin(a)*r*0.71 a+=3/8u=cos(a)v=sin(a) if(v1>v0)line(x+u*v0*r,y+v*v0*r,x+u*v1*r,y+v*v1*r,8+(r/4)%8) end end flip() goto ★ |

