Last modified: March 15, 2024
In this lab, you will kick-start your Lode Runner project by creating the basic components of the game: MyWorld, Platform, and Player.
Please download the demo for this lab here. You will need to use the images under the "/images" folder. Direct link to the latest images with updated player heights.
(optional) To make your game look and sound like the original, you can download and use the complete Lode Runner Visual and Sound Library here.
Since this is a large project with many parts, you will need to log your progress in a journal so you can get credit for the work you do. Rather than grading you on completion of each assignment, you will work on making progress each day and will be graded on your development journal and code development. You will be expected to make progress each time an assignment is assigned even if your work is going toward fixing an earlier stage. You should always submit your latest code and the google doc link to the latest assignment before the due date to get credit for an on-time submission.
PX_LastName_FirstName_LodeRunner_Journal
Change the constructor in MyWorld so the world has dimensions 600 X 480. This will make the grid system for the walls fit perfectly inside the world. Each grid will be the size of the width of a wall which goes evenly into 600 and 480.
Set the background image of your MyWorld to an image filled with black using the method setBackground(GreenfootImage image). Here is how you can make such an image:
Next create a Wall class and set the image to the bricks.png
image from the starter code.
Create a method that draws a row of walls. The method should take parameters for the number of walls in the row and the position of the row.
Create a method that draws walls in a rectangular grid. The method should take the number of walls in each row, the number of rows, and the position of the grid. Each wall should be centered in a grid square with side lengths equal to the width of a wall. Note that the height of the wall is less than the width, so this will create a small gap between rows which will make the rows fit together seamlessly as shown in the picture below.
Use the methods to draw some platforms as shown below:
Here is another picture with labels showing how many rows are between the platforms and how many walls are in each row.
Create a player class with the following behaviors:
When the player is on a platform:
When the player walks off a platform and falls:
Finally, add a player to the world as shown in the picture above.
000
, 001
, 002
, 003
, ...etc., you can also build a String that matches the filename you need based on the frame number.Think about how you want to detect collisions. There are multiple methods that can be useful for gathering different types of information.
isTouching(Wall.class)
will return true if ANY part of the wall image touches ANY part of the player image.getOneIntersectingObject(Wall.class)
will return a reference to a wall the player is touching or null if the player is not touching a wallgetOneObjectAtOffset(dx, dy, Wall.class)
will detect a wall that contains the point (getX() + dx, getY() + dy). Note that the getX() and getY() are already included, so you should ONLY pass the amount you want to offset from the center of the player.Examples for getOneObjectAtOffset(dx, dy, Wall.class)
:
Note that if you are using getOneObjectAtOffset(dx, dy, Wall.class)
to find out if a wall is below/left/right/above the player, you should use more than one collision point. For example, to check if a wall is below the player, you should check points on the left and right side below the bottom edge. You can also check below the middle of the bottom edge, but you can't only check the middle because then your player will fall off edges prematurely. It is also best if you use offsets based on the width of a brick rather than the width of a player so the varying player image widths will not cause you player to fall through the edge of a wall. In particular, i recommend the left and right points be offset by dx values one pixel less than the width of a brick and the dy values be one pixel more than the player height.
Here is a picture with red dots marking suggested collision detection points:
You should create helper methods that answer questions about the player's immediate surroundings. There are some ideas for helper methods below. You may use only some of these for now and may add more when you work on adding other game features such as ladders. Since all of these methods are asking a yes/no question, they each should return a boolean.
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