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...
Forgiving Jumps
![](https://www.lexaloffle.com/bbs/files/15406/plat_adv_jump.gif)
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.
Mario Sliding
![](https://www.lexaloffle.com/bbs/files/15406/plat_slide.gif)
When you change direction while moving, there is a bit of a slide before moving in the new direction.
Air and Ground Friction
![](https://www.lexaloffle.com/bbs/files/15406/plat_friction.gif)
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
![](https://www.lexaloffle.com/bbs/files/15406/plat_jump.gif)
Tap to jump a small amount, and hold to jump higher. Again very critical for precision jumps.
Pass Through Floors
![](https://www.lexaloffle.com/bbs/files/15406/plat_floors.gif)
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!
|
Old Versions:
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/11736/chibi_me_48x48.png)
This is such pure awesomeness, a mega valuable resource and wonderful square one to begin a game jam from! You are a hero! I cannot wait to dive in and make my 1st pico8 game using this! Thank you so much for this perfect starting point.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/22939/self-portrait.png)
I've been diving into the code of that game to make sense of some of those mechanics and animations. You are awesome, dude! Thanks!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/15110/heeed-vr.jpg)
Wow, nice! Been gradually fumbling my way through figuring these things out myself. Will be great to see some good examples!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/10826/MAX300b.png)
Very valid to things I'm making!! Thank you, and hopefully this can translate to my projects easily... I've already got a little wip on them though...
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/23111/profile.png)
This is really good! There's a glitch where you can zip up a wall if you jump into a corner at the right angle.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/15406/avatar.png)
@ianh: Thanks for reporting the bug! Never seen it before but within 1 minute of trying I was able to do it! I'll try to get a fix in; should be just a matter of adding more collision points on the player's head (to match what is on his feet).
![](https://www.lexaloffle.com/bbs/files/15406/plat_bug_001.gif)
@everyone else: Thanks so much for the positive words! Let me know if you make anything, or have any questions about the engine!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/15406/avatar.png)
Version 1.1 Uploaded:
- Fixes to collision routines (thanks @ianh).
- Camera now follows in Y (not just X).
- Supports sprites of any size (not just 8x8).
Here is a little demo I did of a platformer using 16x16 sprites:
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
This is such a great addition to the community. Definitely going to be using this for one of my projects. Thank you mhughson!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi25.png)
Absolutely phenomenal. For someone who knows so little about coding, this is a beaut!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/23540/Lee-sketch-avatar.gif)
@mhughson I haven't had time to code anything, but this looks like a great foundation for my platformer. Thanks for sharing it!
I noticed a collision error when the player sprite walks all the way left - it overlaps the background a pixel. Is the code collision checking every pixel in the sprite against the background?
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/15406/avatar.png)
@LeeStewart: It does not check for collision on every pixel. It only checks a few points, but the issue you are seeing is because the sprite is not centered and I check the same offset amount on both sides (so on right it is perfect, but on left it is off by one). See function collide_side(self) for more details.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi8.png)
@mhughson: the top pixel (113) should be 114 no ? Because 113 block has the 0 flag so it should not be possible to go to the next level ?
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/16417/alien.png)
Not sure if anyone really cares, but I got rid of the overlap when colliding left, which @LeeStewart mentioned, by adding 0.5 to the offsets for self.dx<0, in lines 75-80:
--elseif self.dx<0 then if fget(mget((self.x-(offset+0.5))/8,(self.y+i)/8),0) then self.dx=0 self.x=(flr((self.x-(offset+0.5))/8)*8)+8+(offset+0.5) return true end |
Thanks for this awesome tool! :D
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/10886/9_hanamaru_ico.png)
@mhughson This is a fantastic demo cart, I think I might try to get it to work with split screen! I have a demo from last year with doing split screen stuff, not sure how out of date it is. https://www.lexaloffle.com/bbs/?tid=27696
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/15406/avatar.png)
@HotSoup: That would be cool! Let me know if you get anywhere with it!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi6.png)
Thanks again for this library! When using it, I made a modification others might be interested in:
JUMPTHROUGH FLOORS
If you want jumpthrough collision to only catch the player if they are actually landing on the TOP of the tile (instead of getting shifted up if they are falling anywhere inside the tile) then you can take this line in collide_floor:
if fget(tile,0) or (fget(tile,1) and self.dy>=0) then
and turn it into these two lines :
local ty = flr(self.y+4)%8
if fget(tile,0) or (fget(tile,1) and self.dy>=0 and ty<=1) then
(you don't actually need the dy >= 0 for any appreciable difference here, so you can actually remove it, but I kept it for consistency)
This adds a check to see if the player's collision bottom is at the border edge of a tile (i.e. collide only when colliding on the TOP of a jumpthrough tile, instead of just anywhere within one)
NOTE: This assumes tiles of 8 height and player collision of 8 tall, with y coordinate at the center (which I believe the rest of the Adv. Platform library does).
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/6/bright3.png)
One function is mistakenly commented:
--square root. function sqr(a) return a*a end |
Should be
--square. function sqr(a) return a*a end |
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/12189/Headshot.jpg)
I wish I had seen this kit before I just re-invented the wheel with all this stuff!
For next time!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/26046/roysterini.jpg)
I hope this isn't frowned upon too much, but this could be the perfect starting point to kick off my next PICO-8 game. It is a flick screen platformer, but I'm still not adept enough at PICO-8 coding to attempt a platformer from scratch. So, this could help immensely.
Thanks.
Roysterini / @Pico8Fan
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/12874/56_av_violet_pikuseru_flat.gif)
For the most part, the PICO-8 community is very collaborative. Obviously you don't want to step on anyone's toes or simply take their work and pretend it's your own, but I don't recall anyone getting upset about indirectly contributing code to another person's game. People are pretty open to sharing here. Given that the platform distributes most apps in source format, it's hard to do otherwise.
That said, it's good to pay attention to the bottom of any posted cart. You can see there if the cart has been flagged by its poster as being released under a Creative Commons style license.
If it's not marked, check the source code to see if the author has included a note about how it may be used--those who care usually do so.
You may find the cart has obfuscated source code, in which case you can probably assume you're not free to use it, but it may also be the case that the author simply used a minifier utility to reduce source code size to fit on the cart, in which case you should look to see if there is a link to the original, unminifed source code.
I think as long as you make a modest effort to operate above-board, you'll be totally fine.
Personally, I find I've learned the majority of the tricks I know from reading other people's code. The PICO-8 platform tends to encourage doing that, and I think it's part of why our community, as small as it is, tends to produce a lot of really clever and creative little games.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/26046/roysterini.jpg)
Thanks Felice. I'll try to be transparent about what I use. I gave a nod to people that helped with Splorf in my info screen.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/15406/avatar.png)
@tmirobot: Thanks for sharing. I'll include it in the next revision, when ever I get a chance to do that.
@matt: Good catch, thanks!
@Roysterini: Yup, this cart is meant to be a starting point for other people. There are some comments at the top of the cart regarding giving credit (its optional).
I'm not sure what a "flick platformer" is but it sounds similar to the game this starter-kit is based on, so you might find it helpful to look at: https://www.lexaloffle.com/bbs/?tid=28714
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/15406/avatar.png)
I ended up building on that Mario Demo i linked to earlier quite a bit. You can find it here:
https://www.lexaloffle.com/bbs/?tid=31744
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/15232/me-square.jpg)
It's great research you've done here, MH. Not now but later I wanted to experiment with and build what I felt were "golden" variables for this kind of genre - that is, the perfect Platformer.
I'll be coming back to look at your brilliant engine then.
Until then, nice job !
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/32135/ck.jpg)
This is super-amazing! Makes me wanna do a little Commander Keen tribute, heh!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/34107/dfs.png)
Love this template! I'm using it for my first project. Having some trouble understanding why the camera isn't following the character around outside the "demo area" included in the template, which I'm guessing is because of line 430:
pos_min=m_vec(64,64),
pos_max=m_vec(320,64),
How do I get the camera to follow the player across the whole map? Completely new to programming, I'm afraid.
EDIT: Changed the values of "pos_max=m_vec" to "(1000,1000)" and it seems to work.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi25.png)
I took this project and combined with a starter template I found. There was some dead code that I removed. Here's the project: https://github.com/jressey/adv_micro_platformer_template
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi24.png)
Hello I used the sdk for my game:
Http://omael.itch.io/frog
I found a couple of bugs, the camera have a missing parameter for height, and the coyote jump should consider dy>0 when checking for air time, both are quick fixes
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi21.png)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/13549/Cheap Profile PETSCII.png)
This platformer example is absolutely magic. Thank you for putting this together.
I'm going to be working on a platformer project soon and will be sure to reference your material throughout.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/72643/IMG_0365.gif)
Yo ngl the platforming if kinda bad, it feels like your on the moon, idk if it’s supposed to have bad controls but it does imo
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/101183/2_download (1).png)
Hi, ive just been looking through the code, but cant seem to find the x and y values for the character. ive checked everywhere, but just cant see it... but everything else is perfect 👍 thx
[Please log in to post a comment]