Do anyone know how constant is the duration of a frame in PICO-8?
I am considering making samething that will use rhythm and decided to use the frames as a time basis. First thing I implemented was a simple metronome.
Code below:
This function rounds a number n to the nearest integer that is multiple of m:
function round_mult(n, m) -- n is the number to be -- rounded. -- m is the integer -- significance. -- returns the nearest -- multiple of m. if (n % m) == 0 then return n else v_up = flr(n) + 1 v_up = n + (m - n % m) v_dn = flr(n) v_dn = n - (n % m) if (v_up - n) <= (n - v_dn) then return v_up else return v_dn end end end |
On the metronome itself, I want to put a bpm and use the nearest bpm that can fit inside a frame time.
function _init() bpm = 50 -- this is not necessarily the actual bpm ingame. btime = 60/bpm -- time per beat in seconds subdivs = 4 -- subdivisions of a beat fps = stat(7) -- framerate ftime = 1/fps -- time per frame bframes = round_mult( btime / ftime, subdivs) -- the actual bpm to be used, but in frames instead of seconds curframe = 1 -- frame count starts at 1 end function _update() if curframe == bframes then sfx(1) -- this is the end of a beat curframe = 1 elseif (curframe % (bframes / subdivs)) == 0 then sfx(0) -- this is a subdivision of a beat curframe = curframe + 1 else curframe = curframe + 1 end end function _draw() cls() print(tostr(curframe)) end |



Hey,
I'm writing something that uses a lot of memory and initially was running out of memory, I've been dealing with the issue all day, but went back to an old file (where I was running out of memory) and ran it however I didn't run out of memory this time.
I started printing stat(0) to see what was going on and for maybe the first ~1k of memory I used I was getting a result of 0 memory used back from stat(0).
I tried loading the file on my laptop and got the out of memory error. Went back to my PC, reopened Pico, ran the file, out of memory.
Is this a known bug? Am I being an idiot and missing something?



I am looking to make my old laptop into my Pico8 laboratory using Tiny Core Linux. The OS is blazing fast but does come with many hoops to jump through before being semi usable - no wifi at first, then sound, then weird resolution, and even now I can't seem to log into lexaloffle.com using chromium as the navbar is missing.
Alas, I have managed to deal with all of the issues (save for navbar - used Firefox for to cheat my way out), logged into my acc here, downloaded Pico8, Voxatron and Swarm Racer. I run pico from the terminal and it did fire up, with sound, albeit seemed like I had only a quarter of the screen actually being used, with the rest being black but the cursor would move to this portion of the screen; I managed to get it to run properly (as far as I can tell - windowed and full window used, just like my Ubuntu setup), and the input works as expected except Esc, Enter (main or numlock one). Maybe other keys too, but I can't verify since I can't input any command or hit Esc to jump away from the terminal into GUI.
Anyone has any idea on where I should look/what to google to figure this one out? I'd like to point out there was a terminal printout on the original run (with the messed up screen), but I could not read it properly since the machine is ancient and it ground to a halt on the first run and I couldn't swap windows or exit Pico8, however I did see that it was a 3 liner output with last part mentioning input.
Maybe it's worth noting how after the initial run and after I rebooted my OS seemed to have reset or lost it's config file as I had to setup various stuff again, but Pico seemed to run normally after got it down to windowed mode; also - Voxatron and Swarm Racer won't display anything. I can navigate the menu and I hear the menu sounds and such, but there is no video output at all. If I press Esc both Vox and Swarm will quit and I will be able to resume normal operation on the OS - so the keys do work with Vox but no video output, while in Pico everything seems to be there except the system keys

It's a frosted 3D donut, drawn in 265 chars of Lua!
I'm including the code here, with spacing and indents for legibility (instead of minimizing chars like in the cart).
Variable meanings:
X/Y/Z: Current sample position (moves along a camera ray), +Y is up
I/J: Screenspace position
U/V/W: Ray direction (normalized)
C: Output color of the current ray
K: Raymarch iterator
Q: Distance to the unextruded torus on XZ plane
L: Shortest distance to the surface of the extruded 3D torus
A: Angular position of sample pos around the torus (0-1, repeating)
(Both distance values are signed: a negative distance means that a point is inside a shape)
cls(2) ::_:: x=0 y=2 z=-3 i=rnd(112)+8 j=rnd(66)+40 u=i/128-.5 v=-(j/128) w=sqrt(1-u*u-v*v) c=2 for k=1,20 do q=sqrt(x*x+z*z)-1 l=sqrt(q*q+y*y)-.5 if (z>4 or y<-1) then break end if (l<.08) then a=t()/64+atan2(z,x) c=(-y*5-.3+sin(a*6)/4) break end x+=u*l y+=v*l z+=w*l end pset(i,j,max(c%16,1)) goto _ |

Fixes:
- pixel-perfect fullscreen (requested https://www.lexaloffle.com/bbs/?tid=28615)
- fullscreen mouse support (reported https://www.lexaloffle.com/bbs/?tid=28295)
- browser zoom (ctrl+/ctrl-) doesn't break fullscreen (also reported above)
- tab key disabled (https://www.lexaloffle.com/bbs/?tid=28844)
- select & drag disabled (https://www.lexaloffle.com/bbs/?tid=30380)
- context menu disabled on canvas & buttons
- gamepad support (krajzeg's https://github.com/krajzeg/pico8gamepad/)
Features:
- pixel-perfect auto-resizing (optional, set autoresize to true in html)
- minor enhancements (pico8 palette colors, black frame with shadow)
- play button when autoplay is denied (in compliance with autoplay policy changes in chrome 66)
Tested on:
- win10 (chrome,opera,firefox, edge(blurry as expected, lol@ms))
- linux mint (chromium,firefox)
- macos (safari)
- itch.io, site & app (min embed size is 516x540, close fit with borders without autoresize)
How to:
unzip ub.html to {application data}/pico-8/plates
and then
> EXPORT FOO.HTML -P UB
minified version:
> EXPORT FOO.HTML -P UBM
Download:
https://www.lexaloffle.com/bbs/files/13845/ub_html_12.zip
Have fun!
(edit) no mobile support for now
...
1.2: power button when autoplay disabled (chrome update may 2018)
1.1c: fixed cursor keys scrolling page within iframe
1.1b: removed CRs, added minified
1.1: fixed select/drag/context menu
1.0: first version
Previous versions:
https://www.lexaloffle.com/bbs/files/13845/ub_html_11c.zip
https://www.lexaloffle.com/bbs/files/13845/ub_html_11b.zip
https://www.lexaloffle.com/bbs/files/13845/ub_html_10.zip
(free to use and modify, no attribution required)





Here's a super secret preview of Dragondell, a cute stealth adventure game. Code and art are by me, music and sound design are by Gruber -- grubermusic.com. The main page for this game is now on its itch.io page -- feel free to continue leaving comments here as well, but I may be slower to see them, and the version here may lag behind that version if I make further updates.
Note: There's a brief flashing effect when you go through the portal. You can disable it in the pause menu.
GOALS AND CONTROLS
- Collect loot by bringing keys to chests
- Befriend royals with O (z), then return them to the castle of the proper color (match robes to flags and lead them all the way to the door)
- Don't get spotted by knights; you can breathe fire at them by holding X (x), but it takes a couple seconds
- Once all the royals are returned, use the portal to end the game
CHANGELOGS
[hidden]
1.0.0
- Knights will now only alert when they see fireballs on Veteran.
- Found some tokens and added key hints.
0.9.12
- Tuned knight speeds at Adventurer and Veteran difficulty levels.
- Fixed a bug that caused roasted-knight ash to stay in the room if you roasted two knights in the same place.
0.9.11
- Added sentries.
- Added difficulty settings.
- Fixed royals not entering castles after swapping positions.
0.9.10
- Made the board a little smaller; there's now 5 each of royals and treasure instead of 7.
- Knights you haven't seen before should no longer spawn right next to you. (If you let one chase you off screen and then turn around and come back, it'll still be there, though.)
- Added new score bonuses and adjusted some existing values.
- Fixed bug whereby roasting a knight who was standing on a key would destroy the key.
0.9.9
- Fixed the speed bonus not resetting properly in between games.
0.9.8
- Updated sounds to final version, including end music.
- Keys, coins, and piles of ash (former knights) no longer block sight, movement, or fireballs.
- Added more possible score segments.
- Added new set pieces.
- Put visible trays in the HUD for keys, coins, and crowns.
- Adjusted the fireball sprite to look more continuous.
- Adjusted some set pieces.
- Fixed knights sometimes spawning on top of castles.
- Fixed chests spawning in positions that would block passage through the room.
0.9.7
- Fixed speed bonus calculation.
- Fixed several bugs that caused sounds to repeat rapidly.
- Fixed the timing of the portal using noise.
- You can now move while befriending.
- If you manage to step through a door onto an NPC, that NPC should now move. (Please let me know if you successfully reproduce this, it's hard to test.)
- Knights will now pause for a moment when you enter a room.
0.9.6
- Fixed bug where special items would sometimes be placed behind trees.
- Bumping into knights from behind makes them turn around.
- Knights turn to ash a little faster when fireballed.
- Ash will disappear immediately when you leave the room.
- Tweaked some score bonuses.
- Some new sfx and related bugfixes.
0.9.5
- Capped the speed bonus based on how many rooms the player visited.
0.9.4
- First draft of sfx!
- Knights will no longer turn around if you sneak up right behind them.
- Knights now notice fireballs in their field of view and try to find the origin.
- The end portal now only appears after returning the last royal.
- Added a bunch of new score bonuses, some of them quite silly.
- Lots of title screen improvements.
- Minor adjustments to room templates.
0.9.3
- Fixed a bug in vision cone calculations (thanks Joel!)
- Massive art update.
0.9.2
- Fixed a bug where the castle distribution was sometimes different from "one of each color" (thanks Yoshi!)
- Fixed a bug where knights would get stuck in their "charging" sprite if you left the room and came back
- More score tweaks
0.9.1
- Map generation now validates rooms (to make sure all goals and exits are reachable)
- Made it even harder for knights to chase you immediately on room entry (and easier to get out of it if you're clever)
0.9.0
- Switched to the version number I actually meant last time (whoops)
- Knights who have spotted you but not yet charged on you move faster
- Knights will not be looking at you as soon as you enter a room (even for the second time)
- Minor tweaks to room generation, scoring, and portal animation
- Added menu option to disable flicker effect






Charlie needs help. He doesn't understand music. To learn about it, he has built a machine that can make sounds. He will have to teach his neural network (music brain) how to make musical sounds.
When he starts the machine for the first time, it will make a random sound. To hear this sound again he can press the green PLAY button. To reward the machine for playing something sort of musical, he can press the red LEARN button. This will modify the brain and a new sound will play, usually similar to the first but not always. If the new sound is still "musical," he can press LEARN again to get more creative. To save this brain to the cartdata, he can press the gray SAVE button.
If the brain is not making musical sounds, he can modify any node directly by moving on top of it, pushing the value up or down with the buttons. The weights of the nodes and edges are represented by color patterns. The first column of nodes are input nodes. Modify them and press play to get a new sound from the machine using the current brain, without changing any connections. The middle column are learning nodes. Modify them and press learn for chaotic, unpredictable behavior. Pressing play will reset them. The right column are output nodes associated with instruments, pitches, envelopes, volumes, speed, and loop length, respectively. Modify these to be what you believe they should be and press learn to train the brain to produce those outputs when given the current inputs. (left column)
Good luck have fun!


Yeah, I'm one of those people. You know. The ones who use an alternative keyboard layout. Also I'm running Arch Linux too, if you need to know the OS.
So, Pico-8 works great with Dvorak, but there are a few instances when it does weird things. The one that comes to mind is in the Sound Editor. For the top letter row (qwertyui on Qwerty) (',.pyfgc on Dvorak) (;,.pyfgc on Programmer Dvorak), you are still able to correctly enter the correct notes as you would expect (cdefgabc).
BUT as you see with both Dvoraks, the comma key = note D, the period key = note E. Unfortunately the comma key is also mapped to speed up and the period is mapped to slow down. This has been bugging me for a while.
I would suggest a fix by mapping all the shortcuts (at least in the sound editor, maybe other ones) to the key code/location on the keyboard instead of whatever the user has the key mapped to (keyboard layout).
Let me know if you have other suggestions for a fix. And thanks!




2019-02-05 UPDATE: Minor code clean-up and dialling back glitch effects at game-over screen
2018-03-26 UPDATE: Change of name (from Dataseed) due to name being in-use.
2018-03-25 UPDATE: Added rudimentary hi-score system (resets when cart resets)
First game I've ever made, on pico-8 or otherwise.
Learned a ton of stuff while making it, including how not to structure my code next time :)
Hey friends,
For your interest, in case you haven’t seen it on Twitter, Trasevol_Dog and I just finished a major collaboration on JS Bach’s Two-Part Inventions.
I arranged all 15 of these compositions in Pico-8 (Each required 2-3 carts worth of SFX). And Trasevol_Dog created animated portraits for each.

Write-ups on the how he did the portraits can be found on Trasevol_Dog’s Patreon Page
And all of the music and portraits can be seen/heard in this YouTube playlist
Hope you enjoy!



I'm using a Microsoft Surface Pro. I noticed that Pico-8 doesn't respond correctly to touch events. This affects the use of the touchscreen as well as the use of a stylus. I'm using the Surface Pen.
Although you can control the cursor with touch inputs, triggering clicks is difficult. Tap events aren't registered as click. They move the mouse cursor but don't click. Tap and drag is correctly recognized as click and drag. So in order to click you need to basically draw tiny circles with the pen.
I would love to use the pen as a convenient way to do some Pico-8 pixelart on the go.



Prototype for Bennett Foddy's Pixel Prototype Studio, NYU Game Center
Prompt: Food
Float through donut space, kill the baddies with sugary treats
Arrow keys to move, ESDF to shoot new donuts
I want to keep working on this, maybe rewrite it in Phaser or Unity
Music by Elizabeth Castaño and me


Well I am new to lua and pico-8
In javascript, it is possible to force run inner function after some seconds with setTimeout();
setTimeout(function(){},5000);
and I am looking for something similar method or function in lua or pico-8
this is my code
function define_level() local level = 'level'..levels; show_level(level); end function show_level(level) print(level,54,64,8); end |
levels is number.
I want to hide or remove text which is printed with print(level, 54,64,8);
after some seconds.
Any tips?



Hey P8 fam,
Got a weird thing happening with my game and am having trouble finding anything on this, What is happening is on my map editor I am seeing sprite formations that I did not put there and when I try to remove some of them I see a glitching effect on some of the sprites I did place intentionally when I run the game.
Does that make sense?
Does this have to do with the 128 sprite limit? Didn't think I hit it.
Happy to answer any questions, thanks.




Hello I started lua programming just yesterday.
Because my project should be started right now, I hadn't so much time to read through lua tutorials.
I am an web developer and I have never seen such errors when I worked with Javascript and Java and I don't understand meaning of the error.
This is my code
The error is occured in function drawLife.draw()
function _draw() cls(); rectfill(0,0,128,128,12); rectfill(0,72,128,128,7); clouds.draw(); mapdraw(16,16); mapdraw(0,0); enemies.draw(); bullets.draw(); p.draw(); mapdraw(16,0); fires.draw(); score.draw(); drawLife.draw(); print(bullets.type,4,4,7); end function drawLife.draw() rectfill(80,80,60,60,#FF004D); rectfill(80,80,60,60,#FF004D); rectfill(80,80,60,60,#FF004D); rectfill(80,80,60,60,#FF004D); rectfill(80,80,60,60,#FF004D); end |
I added .draw() after drawLife because I got lua code from my friend's brother who is game developer... and there were many .draw() and :draw() after the function name.. I need to learn about that



