Let's create an MPAGD game - Part 12 - Adding Ladders
Updated: Oct 30, 2021
So far, in our game, its pretty much a standard platform affair, with controls for left, right and jump. But what if we wanted to add ladders for Stinky Dog to climb up and down?
First, we're going to need to add some Ladder Blocks, so open up the Block editor, we're going to need to create two blocks, one for the left side and one for the right side. We need to create two because our sprites are 16 pixels wide, but blocks are only 8 pixels. You can try doing it with a single block but its a bit ropey from a playability perspective.
I always try and keep my ladders as simple as possible, this is because of the way that MPAGD displays a sprite when it is over a non Empty block.
Something like this will do:
Remember to click the Block type box to cycle through to the correct type.
Once you've create your ladder blocks we can add a ladder to our screen, open up the Screens editor , select the blocks in turn and draw a ladder on your screen:
Now that we have a ladder, it would probably be a good idea for us to have a version of the Stinky Dog sprite that we will display when he is going up or down the ladder. Open up the Sprite Editor and create a new sprite.
(it's supposed to be Stinky Dog from behind....if you haven't guessed )
Now we're going check we have set the Keyboard Controls for Up and Down, from the Editor menu select Keyboard controls, and as we did before, choose the keys that you want to control Stinky Dogs up and Down movement.
QAOP....just how it should be :)
Next, were going to need to add the code for up and down ladders movement. But rather than use the script generator (since that might overwrite our code to date) we're going to write it ourselves, but before we do that we're going to edit our screen...don't worry, it will all make sense soon.
So far our screen is entirely walled-in - there is no exit or entrance to another screen...so lets make one, remove two blocks from the right hand wall, just above the floor:
Then press X, this will create a new blank screen, make sure the floor of the screen is two blocks high, design your screen with walls and ceilings, but this time leave two blocks open in the bottom LEFT corner, and continue designing your screen, something like this...
Note that our first screen is Screen 0 and our second screen is screen 1.
Now, we need to tell MPAGD how our screens are connected, to do that we use the Map editor. From the Editor menu, select Map