Log In  

Cart #28248 | 2016-09-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

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.!

P#28249 2016-09-09 20:33 ( Edited 2018-06-14 03:09)

This is great, thanks for sharing. Platform jumping is something I have yet to really grasp and get working successfully...this should go a long way to remedy that.

P#28250 2016-09-09 22:34 ( Edited 2016-09-10 02:34)
:: dw817

Just have to comment. Firefox REALLY runs these great games so slow ! And then Chrome just breezes right through them. What gives ?

P#28252 2016-09-10 00:32 ( Edited 2016-09-10 04:32)

@morningtoast: Glad you find some value in it. Let me know if you have any feedback to make it easier to use for others.

@dw817: I actually find it pretty choppy even in Chrome; especially noticeable with input lag.

P#28253 2016-09-10 00:58 ( Edited 2016-09-10 04:58)

Great engine, I'm gonna make a game out of this :P
Edit: I'm coding it on my PocketC.H.I.P. too! :P

P#28264 2016-09-10 09:37 ( Edited 2016-09-10 13:39)

With firefox, Micro Platformer is smooth for me (Intel(R) Core(TM)2 Duo CPU P8400 @ 2.26GHz)
Nice demo anyway, I might use it as basis as well...

P#28265 2016-09-10 10:09 ( Edited 2016-09-10 14:09)
:: dw817


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.

P#28275 2016-09-10 13:19 ( Edited 2016-09-10 17:19)

Keyboard is pretty bad to be honest. Took a lot of getting used to even just to type. Gaming on it is even tougher. However, its pretty cool do be able to do anything like pico 8 programming in the go so I put up with it :)

P#28289 2016-09-10 19:06 ( Edited 2016-09-10 23:06)

@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.

P#28291 2016-09-10 20:05 ( Edited 2016-09-11 00:08)

@funzrey: any tile/sprite with flag 0 enabled (red dot). Look up fget function for more info. Post a link once you have something up and running. Would love to see what you make.

P#28322 2016-09-11 14:42 ( Edited 2016-09-11 18:42)

@mhughson Oh, thanks. I'm working on it and it looks pretty good so far.

P#28325 2016-09-11 15:43 ( Edited 2016-09-11 19:43)

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:

Cart #28349 | 2016-09-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Sorry for no cart picture. I tried FN+7 (F7) on PocketC.H.I.P to take a picture but it didn't work.

P#28350 2016-09-11 19:20 ( Edited 2016-09-11 23:20)
:: JTE

My ball ends up halfway inside a wall if I jump over it and then fall down into it. :( Only one collision point in the center rather than on the corners, I guess.

P#28381 2016-09-12 06:39 ( Edited 2016-09-12 10:39)

@JTE I don't know where the collision points are either. :P

Anyway, my game has a lot more sounds now
and the map switching is implemented! Now to implement the collision changing part, because right now it only changes map display & spawn location. I'll release it as soon as I can get it working. (though would be nice if I had some help on the collision part)

//OFFTOPIC: PICO-8 emotes pack!

P#28427 2016-09-12 17:47 ( Edited 2016-09-12 21:52)

@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
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
P#28708 2016-09-17 19:25 ( Edited 2016-09-17 23:25)

@funzrey: BallQuest, the spikes are way too easy to hit. The full sprite is death when it should be just falling on it you die. :(

P#28776 2016-09-18 22:22 ( Edited 2016-09-19 02:22)
:: makz

microenginejam anyone?

P#29447 2016-09-26 17:48 ( Edited 2016-09-26 21:48)
:: dw817

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.

P#29458 2016-09-26 20:18 ( Edited 2016-09-27 18:32)


P#29497 2016-09-27 10:18 ( Edited 2016-09-27 14:18)

Thank you matt! It's a very useful base for a starter!

P#36727 2017-01-26 12:57 ( Edited 2017-01-26 17:57)

Glad you liked it @Baerius. I have a more advanced version coming out any day now, based on my game, Kid Bludd.

P#37100 2017-02-03 01:04 ( Edited 2017-02-03 06:04)
:: sax3

>>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]


P#39969 2017-04-26 16:02 ( Edited 2017-04-26 20:04)

Haha wow, I didn't know that. I need to rethink... EVERYTHING! :D

P#39972 2017-04-27 01:19 ( Edited 2017-04-27 05:19)
:: matt

If I bring the circle down on a corner and keep pressing left and down cursors, it can overlap the platform.


P#42324 2017-07-10 15:24 ( Edited 2017-07-10 19:24)

hi, thank you for this well documented code!
I just have one question: why do you divide all the offsets for the collisions by 8? to me it does not make any sense but apparently it's essential :)

P#51737 2018-04-17 17:12 ( Edited 2018-04-17 21:12)
:: Davbo


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?

P#51747 2018-04-18 04:56 ( Edited 2018-04-18 09:02)

Yup as davebo says, that is transforming a screen position into "tile coordinates". You can imagine that the first 8 pixels of the screen all map to Tile 0, the next 8 map to Tile 1 and so on.

P#53532 2018-06-13 23:09 ( Edited 2018-06-14 03:09)

Your commenting is gold. I'm just learning how to program- the comments help a ton.

P#60073 2018-12-18 05:33

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-05-31 11:01 | 0.087s | 2097k | Q:100