(v00 12-10-22)
TO LOAD THIS PICO-8 CART, in immediate mode, type:
load #slowdown
In this demo use the LEFT and RIGHT arrow keys to control actual runtime speed of the cart. Examine the code to see how it is done.
Hello.
As you know conventional code allows you to run your cart in 30fps or 60fps.
However making use of the seldom known command, _set_fps()
you can set any of these values or an arbitrary one.
Is there a way of setting FPS <30 inside a cart that does make use of _update() or _update60() ?
Trying to do this with _update() and _update60() gets some... interesting behavior.
Using _update(), if I try to call _set_fps(60), I get
runtime error attempt to call global '_update60' (a nil value) |
Otherwise calling _set_fps() with anything but 30 hangs the program.
Using _update60() (demonstrated in the cart below) I can toggle between _set_fps(60) and _set_fps(30) (using β and π ΎοΈ) . However, this does not change the speed but rather _set_fps(30) just appears to ignore drawing every other frame. Again, if I try to call _set_fps() with any other number, the program hangs.
Yep, @mattu82.
I'm not going to call it a bug because it's rather a nice feature to run a cart at any FPS, except most people code conventionally with _update() or _update60() so it cannot be used for these.
I do remember making using of this in a TWEETCART written sometime ago.
https://www.lexaloffle.com/bbs/?pid=108196
It used _set_fps() to speed up the game, starting initially at a slow value.
I guess, @zep, I am asking, can you please have a POKE or EXTCMD() that allows you to set an arbitrary FPS that might well be even faster than 60fps and inside a standard _update() function ?
I love how even the button input slows down! (The things coders get
excited about XD)
It was a great thing to be able to control games in this way, @loan_wulf. Try any NES/GB/GBC/GBA/SNES/Sega game and you can control the speed of it. With NES/SNES/GBA you can even run the program in reverse.
Add to that load and save state anywhere anytime anyplace and they become powerful, not just for effective gameplay but observation and education.
And yes, @zep, I would still like to have LOAD/SAVE state for carts. This would greatly facilitate Pico-8 games that have no save ability.
Possibly CTRL-2 or CTRL-5 to save and CTRL-4 or CTRL-7 to load - or just add it to the default "P" menu.
omg, this is so interesting. i'd considered implementing slowdown fx in my last game, but i cut the feature it would've been part of before i even started. i've also considered slowdown for my next project, this may come in very handy, hopefully it's a permanent part of the api since it's undocumented. thx @dw817!
You are very welcome, @ridgekuhn.
Join the dark side of programming ... we haz chocolate chip cookies. :)
No this kind of timing is difficult to code using standard _update() so it's nice it exists here. Truly you should have a few hot-keys in Pico-8, I know I requested these before, @zep.
On the number keypad there is "+" to run maximum speed, bypass timer limitation in _update() or _update60(). Is only active as long as you hold the key. can use up CPU as all holds are released.
On the number keypad there is "-" (minus) to run half or 75% speed normal, so that would be 30 or 45 fps for 60fps and 15 or 22.5 fps for 30fps. Unlike the "+" you need only tap it once. Tap again to return to normal speed.
And yes hopefully this command _set_fps()
will stay as I think it aids tweetcoding and certainly aids my code.
Nono, @ridgekuhn. this is a suggestion, it is not yet available. I wish it was, but it's not. Maybe it will be in the future.
[Please log in to post a comment]