For my game, Witch n Wiz (https://www.lexaloffle.com/bbs/?pid=38117#p), I implemented as simple technique for loading a secondary spritesheet at runtime. This allowed me to have a fullscreen title graphic, but not use up any of the sprite sheet memory (needed for game sprites and map data).
The cart at the top of this post is an ultra simple example of it in use. As you can see, you are able to switch between 2 sprite sheets that would each normally take up the entire sprite memory.
Credit for the num2hex function goes to felice (https://www.lexaloffle.com/bbs/?tid=30910)
You can still only have 128x128 worth of sprites in memory at a time. So this is really best for things like the title screen, or major switches in gameplay (say switching worlds where you don't need any of the original sprites anymore).
The runtime code for this is very light in tokens (~100) but the additional sprite sheet is stored as a large (although compressed) string, so that is going to each into your character count and compressed size (around 8000 chars in a typical case, and 25% of the compressed cart limit).
The first thing you need to do, is export your second sprite sheet into a compressed string format the runtime code expects. To do this, you simply load up this cart in Pico-8:
Fill the sprite sheet with the content you want to dynamically load at run-time, and hit "run".
This will copy the compressed data to your computers clipboard as a string. Paste that somewhere, like notepad.
2) Copy Runtime Code
Next, open up the import example (or view the code here in the broswer):
There is a small section of code you will need to add to your cart. Everything between "gfx import runtime begin" and "gfx import runtime end".
This is the code here for reference, if you don't want to load up the cart:
-- --gfx import runtime begin. -- --copy and paste this into your --game cart. --example usage after "end". -- -- converts hex string -- to actual number function hex2num(str) return ("0x"..str)+0 end --call this when you want to --load your fullscreen --graphics. --this assumes a compressed --format of <count>..<color>.. function load_stored_gfx(gfx) index=0 for i=1,#gfx,2 do count=hex2num(sub(gfx,i,i)) col=hex2num(sub(gfx,i+1,i+1)) for j=1,count do sset((index)%128,flr((index)/128),col) index+=1 end end end --call this to go back to --the original graphics stored --on the cart. --eg.after displaying title --screen. function restore_gfx() reload(0x0,0x0,0x2000) end -- --gfx import runtime end. --
3) Paste Export Data
Go an get that string that got exported in step 1, and paste it into your game cart as a variable somewhere.
--something like this. --it will be very large, so I just truncated the string in my example here. local my_gfx="f51d151d151d151d151"
4) Load/Unload As Needed
There are only 2 functions you need to call for the entire library.
First, when you want to use the stored graphics, call load_stored_gfx() and pass it your compressed graphics string (eg. my_gfx) in this example.
When you are done with it, simply call restore_gfx() to return the sprite sheet to its original form.
Day 1 of the 2018 Pico-8 Advent Calendar!
Thanks for checking out my entry for our community "Pico-8 Advent Calendar"!
It's a simple "race the clock" arcade game, with the goal of delivering as many presents as possible before sunrise. The entire game only lasts about a minute, with the idea that you will play many times, and try to beat your previous high score.
About Pico-8 Advent Calender:
During December, each day will be filled with new and exciting PICO-8 games! We have gathered 25 great developers from the PICO-8 community and we have worked hard to make some new games. Each day leading up to Christmas, there will be a new surprise for you!
Find out more at: https://pico8-advent.tumblr.com/
And check out the Pico-8 Advent Calendar each day for a new suprise: https://www.lexaloffle.com/bbs/?tid=32388
Uncompressed Source Code: https://paste.ee/p/5KOG5 (warning: it's pretty gross)
Late last year (2017) I started work on a port of Super Mario Bros [NES] to Pico-8. The goal was to be authentic as possible to the original game, while working within the Pico-8 limitations. Something like Super Mario Bros Deluxe [GBC] (https://www.mariowiki.com/Super_Mario_Bros._Deluxe).
In the end I was able to get 1-1 and 1-2 mostly complete before starting to hit serious memory limits which make it seem near impossible to ship the full game.
With that in mind, I'm releasing it as-is for now so that people can check it out and see where it was headed.
If you are curious, the biggest factor for memory is the level data which is quite huge. At some point I'd like to document how my level authoring process worked, but for now you can check out this twitter thread of me slowly wittling down the level data size:
Update: I have managed to squeeze in all for World 1 now!
Music by: https://twitter.com/gruber_music
I am trying to store some binary data as a string in lua, like so:
local data="ã.ç.G W.§.Ó.×..."
but after saving, all common ascii characters in this string get moved to lowercase:
local data="ã.ç.g w.§.Ó.×..." --(note: G and W are now g and w)
Is there anyway to prevent this?
Testing out my Advanced Micro Platformer Starter Kit's ability to handle 16x16 sprites (vs more common 8x8 used in a lot of pico-8 games).
I have taken my most recent Pico-8 game Kid Bludd, stripped it down to the essentials, and I am releasing it as a kind of Platforming Game Starter Kit.
I removed all logic that isn't game agnostic, so it is hopefully a good starting point for pretty much any platformer.
It's not super complicated, but does a lot of stuff I see many games not doing, which I consider table stakes for a platformer that feel good.
Features the basics:
- Animation System
- Collision Routines
- Camera (w/Shake)
- But also...
This one is very subtle but one of the most important pieces of a platformer. In general the player can only jump if they are on the ground, but this can make the game feel unresponsive when trying to make precision jumps. To give the player some leeway, the game allows jumps for a few frames after the player leaves a platform, and also registers jump presses if they came a few frames before landing.
When you change direction while moving, there is a bit of a slide before moving in the new direction.
Air and Ground Friction
Tunable values for both how much the player slows down while in the air and when touching the ground. This is critical for allowing the player to land on small platforms, while maintaining a good feeling in the air.
Variable Jump Height
Tap to jump a small amount, and hold to jump higher. Again very critical for precision jumps.
Pass Through Floors
Some floors allow the player to jump up through them, but not down. Really important for any levels with verticality, but also fun for horizontal scrollers.
Camera Scrolling Threshold
This cart uses the same camera style as metroid, where the player must leave a small area in the center of the screen before it starts scrolling. This give the player the freedom to make minor movements without causing nauseating camera movements.
|This is a follow up to my original cart: "Micro Platformer - Simple Platforming Engine in 100 Lines of Code". If you are new to programming, I strongly suggest starting with that cart, as it is much simpler to follow!
Short demo showing how to do animations with nothing but palette cycling.
On the right is the actual sprite used, with not palette cycling.
On the left is the resulting animation, when cycling through the palette.
A very primitive example of the amazing techniques seen here: http://www.effectgames.com/demos/canvascycle/?sound=0
Disclaimer: I'm not an artist, so it would be great to see an actual pixel artist do something with this. :)
My 12th one-game-a-month project, and my 4th Pico-8 game.
Loosely inspire by Bubble Bobble, but with a darker, more action-packed twist.
Is it possible to pause or mute music in Pico-8 from script?
I want to halt the music for a short period when the player dies, and resume it when they respawn. Pause or Mute would both work in this case; I just don't want to restart the whole song every time they die.
This is what I currently do:
-- Player Spawns... music(0) --Player dies music(-1) -- Player Spawns... music(0)
My 11th one-game-a-month project, and my 3rd Pico-8 game. Mostly procedurally generated, with a few sprites for decoration. Main character by Adam Atomic.
Post high-scores below!
- New music and sound by @gruber_music
- Improve rendering to remove glitches (thanks ultrabrite).
- Commented code and removed unused logic.
The game I am currently working runs smooth in Pico-8 EXE but when I run in Chrome it has significant perf issues; often dropping frames causing hitches.
Is this a know thing? Is there a way to help with this, or diagnos it better?
A couple things:
1) I am running at 60 fps.
2) I do a LOT of dynamic allocations and discarding (its an endless, procedural game).
3) Stat(1) returns about .3 in best case, and .6 in worst case. Does stat(1) account for FPS target or is .6 on 60fps .1 over budget?
4) It runs totally smooth in Edge Browser, but buttons don't work properly (missing release events i think) and image is blurry (not using point filter).
Here's the game:
FINAL GAME IS HERE: https://www.lexaloffle.com/bbs/?tid=28132
In the game above, the character is gliding in zero-g. They can move left and right using little air jets on the side of the space suit (left and right arrow keys).
I am struggling to make a good sound for this that isn't too grating (you will hear the sound A LOT). I was hoping for a high-pitch hiss; like air escaping a ballon, but having nailed it yet (see above).
Any audio designers know how to achieve this sound?
View Older Posts