-
Notifications
You must be signed in to change notification settings - Fork 0
Part 1
Altan Gulen edited this page Nov 6, 2020
·
7 revisions
Welcome to the Pacman Java lesson plan! I hope you find this repository useful for learning and and creating a fun & visually rewarding project. Before getting started with coding, you will need to set up a proper Java development environment. To do that, you will need to download and install the latest Java Development Kit and a Java IDE. Java SE 14 was used when this was written. For the IDE, I would recommend Eclipse.
Steps
- Create a
Pacmanclass. It should contain:- Member Variables
- An integer for a x-coordinate
- An integer for a y-coordinate
- An Image for a Pacman image
- Functions
- A Pacman constructor to initialize the 3 member variables. In order to load the Pacman image properly, you can load in an image from a file path using
new ImageIcon(<file path here>).getImage(). If you store the images in animgfolder, then the file path to pass into the ImageIcon constructor would beimg/pacman.jpg - Getter for each member variable
- A
public void draw()function to draw Pacman to the screen. You can pass in thegraphicsobject fromGame'spaint()function to draw the Pacman image to the screen. Utilize thegraphics.drawImage()function too!
- A Pacman constructor to initialize the 3 member variables. In order to load the Pacman image properly, you can load in an image from a file path using
- Member Variables
You are given:
- The
Gameclass, which will render a window to the screen for you. Read through the comments to understand how the code works. Try running the program before writing any code to see the window appear. - The
imgfolder, which holds all of the necessary images for the project. You only needpacman.jpgfor this part in order to render Pacman.