The goal of this cart is to demonstrate a very basic platforming engine in under 100 lines of code (comments don't count), while still maintaining an organized and documented game.
It is not meant to be a demo of doing as much as possible, in as little code as possible (a la demo scene). The 100 line limit is just meant to encourage people that "Hey, you can make a game with very little coding!"
This will hopefully give new users a simple and easy to understand starting point for their own platforming games.
Note: Collision routine is based on Super Mario Bros 2 and M.C. Kids, where we use collision points rather than a box. this has some interesting bugs but if it was good enough for miyamoto, its good enough for me!
Built on a PocketC.H.I.P.!
Choose one browser or the other to be your primary. Then clear All TABS from the other browser and load only PICO games in it.
It should run fast with no hesitation.
How are you liking the keyboard ? Looking at a picture of it I'm still wondering where the arrow keypresses are.
@mhughson I usually hook up a bluetooth keyboard if the coding gets pretty hardcore as I don't want to kill my fingers; pressing them a lot for a long time does hurt, though. :P Bluetooth does suck the battery though.
@dw817 Pretty nice once you get used to it, long periods of time can hurt because it's clicky. Arrows are at the top left corner next to the escape key and numbers.
EDIT: My game is going to be based off this engine! Still working out a story on it, also how does it detect what blocks to collide with? I need help with that so I can add my own blocks.
Alright! Here's a demo of my game so far, it's quite buggy and the level switching isn't completely implemented, but I thought I'd release it and show you how much I've done:
Sorry for no cart picture. I tried FN+7 (F7) on PocketC.H.I.P to take a picture but it didn't work.
@JTE I don't know where the collision points are either. :P
Anyway, my game has a lot more sounds now
//OFFTOPIC: PICO-8 emotes pack!
@funzrey: Nice work! Looking forward to the full game!
@JTE: Look for the calls the MGET. The collision points are usually in there (represented as offsets from the top left position of the player).
--check bottom center of the --player. local v=mget((p1.x[b]+4[/b])/8,(p1.y[b]+8[/b])/8)
In this case we offset to the middle bottom. If want to check for more than 1 point you would make this call multiple times with slightly different offsets (then call FGET for each).
For example, here is what it would look like if you wanted to check on the bottom left and right corners instead of the bottom center:
--bottom left local v1=mget((p1.x+0)/8,(p1.y+8)/8) local v2=mget((p1.x+8)/8,(p1.y+8)/8) if fget(v1,0) or fget(v2,0) then ...
Yep, if you're checking true collision, it should be fine. Now one person made an interesting platformer. You can MOVE over the spikes but you =CAN= fall on them, and that includes jumping in place when the spikes are around you. It will cost a life.
But by being able to walk around the spikes without getting killed, that makes for some interesting puzzle levels.
>>if it was good enough for miyamoto, its good enough for me!
they changed it for the Super Mario All-Stars rerelease :)
The version of Super Mario Bros. 2 included in the compilation has improved graphics and sound to match the Super NES's 16-bit capabilities, [b]as well as minor alterations in some collision mechanics. [/b]
Hey so the division by 8...
So you know how the screen is 128x128 pixels?
And a map tile is 8x8 pixels, meaning a screen of map is 16x16 tiles?
This means there is kind of two co-ordinate scales going on - one for the screen resolution and another for the map. This particular code decides to track the player position based on the screen resolution which means when checking collision against the map the X and y locations need to be divided by 8 to get the appropriate map location.
Mget doesn't check what's on screen, it checks the map data. So if you go into the map editor and move the courser around you can see the X and y values of each tile at the bottom left. Those are the locations you are checking for flags.
Another way to do it would be to track the X and y position on the map scale then multiply by 8 when drawing.
It's a little confusing at first! Does that make sense?
[Please log in to post a comment]