Last modified: March 28, 2023
In this lab, you will add ladders to your Lode Runner world and allow your player to move up and down ladders.
You can download a demo of this lab here.
Please thoroughly explore the demo; it is super helpful for you to understand this lab's requirements.
Start with the level you had from HW 1.
Create a Ladder class; give it the appropriate image.
Then, in MyWorld, add some code that draws columns of ladders leading up to the platforms. You can even have some ladders go nowhere and some ladders horizontally adjacent to each other.
Note that the picture above looks very different than your HW 1 layout, but it is fine if you just add ladders to your existing HW 1 layout. Make sure each ladder is centered in a grid square with side lengths equal to the width of a wall so ladders are in the same grid as walls.
Add code in your player class that makes your player go up or down a ladder when pressing the up or down arrow key.
When entering ladder, your player should initially be positioned in the horizontal middle of the ladder.
Advanced option: Your game will look better if the player moves one pixel toward the center of the ladder each time the player moves up or down rather than being snapped instantly to the middle.
While climbing, your player should:
The player should also be able to get up onto platforms from a ladder.
Rather than writing super-long if-else statements to check if the Player is on a ladder, about to fall off, etc., you can make helper methods that return the answers as suggested in HW 1. You just need to add some helper methods that answer questions like:
Then, you can simply say if (someMethod())
instead of writing all the details out.
You should review the collision methods from HW 1 to help you implement these methods.
Read about isTouching in the Actor API.
Read about getOneIntersectingObject in the Actor API.
Read about getOneObjectAtOffset in the Actor API.
Once you have these methods defined, you can write simple expressions like:
if (onPlatform() && !touchingLadder()) {
// do something
}
Zip your entire project folder and submit it below.
PX_LastName_FirstName_LodeRunner
.PX_LastName_FirstName_LodeRunner.zip
. For example if you were in 3rd period and named Michael Wang, then you would name the file P3_Wang_Michael_LodeRunner.zip
You must Sign In to submit to this assignment