• Bruce

Creating Crusher/Lifts with MPAGD

Updated: Nov 17

Out of the box, MPAGD includes a script for a vertical moving platform (Lifts/Elevators). It's fairly basic and wasn't what I was looking for, but with a bit of work I managed to get an effect I was happy enough to use in my first game, Cocoa and the Time Machine. I also wrote a script for that game for Crushers, blocks that would rise and fall that the player would need to dodge else suffer a crushing blow. I couldn't help notice the similarities in the code for the two events, so when I set about writing 24 Hour Parsley People I combined the two, so I could use the same script for a Lift and a Crusher, saving a few precious bytes in the process.

First let's take a look at the stock moving platform. In the video below the Yellow block is the standard MPAGD vertical moving platform (the cyan ones are my version...we'll come on to those later)

The standard version works well enough as a moving platform, the player can jump on and off it ok. When the Lift is going down it's not visually great...you can see the player sprite bouncing. Another thing that I wasn't keen on was the fact that the player can seemingly walk right through it, which never looks good - and wasn't going to be suitable for working as a Crusher. Also, the standard version will stop rising if the player is potentially going to get trapped at the top - again I wanted it to work slightly differently - for added danger I want the player to get hurt if he stays on the Lift (it's a Crusher Lift after all!)

Another effect I was keen to add was having the lift go upward slowly and then fall more quickly.

Here's a video running a simplified version of my code that we'll use for this tutorial:

If you notice (if you look at the Health value) the Crusher Lifts will inflict damage if the player gets crushed at the top and if a crusher falls on top of them.

And here's the code:

Also, we're going to need to put a few settings into the Sprite Initialisation script...

   LET SETTINGA = 0        ; the initial direction of the crusher/lift
   LET SETTINGB = 0        ; the counter for waiting at the top/bottom
   LET DIRECTION = 16      ; the number of cycles to wait

As you can see the main code is split into two parts, the first is what to do if the player collides with Crusher/Lift - either on top of it and hitching a ride, or getting crushed either at the top or the bottom, it also handles what to do if the player walks into the side of it.

The second part are the four main actions of the Crusher Lift, it's either going up, waiting at the top, falling, or waiting at the bottom.

I can't remember why I used SETTINGA for, effectively, the directions, and the the DIRECTION parameter as the number of cycles which controls the waiting time that SETTINGB increments to when the Crusher/Lift is at the top/bottom!...but if its not broke I'm not going to fix it!

There's a lot going on in this script but it's quite flexible and can give you two new features in one, obviously feel free to adapt it to the needs of your own games and environments.

Hope this helps!


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 :)

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

Subscribe Form

  • Twitter

©2020 by Minilop Retroware