• Bruce

Let's add pushable crates we can jump on to reach higher

Updated: Feb 27

This came out of an MPAGD forum request, and as I had already created the mechanic in Cocoa and the Time Machine and expanded/improved it in 24 Hour Parsley People, it wasn't too difficult to create a simplified version that you can use as a building block and then adapt and expand for your MPAGD games.


Our objective is to create a Crate that the player can push left and right, and jump on to reach higher platforms.


In addition we will make it subject to gravity, such that if the player pushes it off a platform it will drop to the platform beneath.


There is a stock Pushable Sprite script in standard MPAGD, but its not really suitable for a 2D platform game, originally I used it as a starting point but in the end I rewrote it and stripped it back (I was trying to save as many bytes as possible!.


So, here's what you should end up with...



OK, so the first thing were going to need is a couple of variables that will store the X an Y co-ords of the Player, in my demo I am using V & W, so in your player script add the following lines:


LET V = X
LET W = Y

Now create an event for your crate, this is where all the work will take place, and add the following code (not substitute V & W if you already have other variable for your Player's X & Y values)



This is a much simplified version of what I used within my games, but is the core mechanic, obviously you can adapt it for your game. Things you can expand it with include:


What should happen if an enemy collides with a crate?

What should happen if a crate is pushed onto an enemy? (maybe squash them against the wall!)

What happens if a crate is pushed onto another crate (in Cocoa 2: 24 Hour Parsley People I have crates that can be stacked on top of each other)


Hopefully this building block mechanic will help you with your own game development and give you some idea for creating new, unique mechanics!


*UPDATE: I've changed the code above so that it now uses the UNDOSPRITEMOVE command rather than adding and subtracting from the Players X when a push fails, I think this is a better use of MPAGDs scripting language

251 views0 comments

Recent Posts

See All

Want to support my work?....Buy my games!

aboutME

Hello, I'm Bruce and I write games for old 8bit computers using Jonathan Cauldwell's excellent Multi-Platform Arcade Games Designer (MPAGD)

I've written a few successful* games for the Sinclair ZX Spectrum and MSX platforms that have been (largely) well received with my most recent game - Twenty Four Hour Parsley People scoring a 10 out of 10 on Planeta Sinclair.

In my blog I am sharing lots of the code that I wrote for my games, in a way that you can use in your own games.   I've commented it so that you'll learn some of the techniques I use to create interesting new mechanics and help your games stand out from the pack.

MPAGD includes lots of standard scripts, they're great to get you started, but if you're new (or just rusty) when it comes to writing code, hopefully my tutorials will help you get started and  turn your imagination into awesome 8 bit games!

All my code is free to use and do with as you please, but if you find them useful please feel free to buy me a coffee ...or better still - buy or download my games :)

*successful is a very relative term in 8bit computer games