Skip to content
Snippets Groups Projects
Commit 823ae066 authored by Chaowen Zeng's avatar Chaowen Zeng
Browse files

Update src/Player.java, src/Sandwich.java, src/Zombie.java files

parent b03d5e42
Branches
No related tags found
No related merge requests found
import bagel.Image;
import bagel.util.Point;
/**
* a movable entity: player
*/
public class Player{
/**
* the player's image displayed in the window
*/
private final Image image;
/**
* render position of the player in the window
*/
private Point pos;
/**
* Player's current energy value
*/
private int energy;
/**
* constructor
* @param x abscissa
* @param y ordinate
*/
public Player(double x, double y,int energy) {
this.image = new Image("res/images/player.png");
this.pos = new Point(x,y);
this.energy = energy;
}
/**
* draw player on the background
*/
public void draw() {
image.drawFromTopLeft(pos.x, pos.y);
}
}
import bagel.Image;
import bagel.util.Point;
/**
* a stationary entity: sandwich
*/
public class Sandwich{
/**
* the sandwich's image displayed in the window
*/
private Image image;
/**
* a Point object representing the position of the sandwich
*/
private Point pos;
/**
* constructor
* @param x abscissa
* @param y ordinate
*/
public Sandwich(double x, double y){
this.image = new Image("res/images/sandwich.png");
this.pos = new Point(x,y);
}
/**
* draw sandwich on the background
*/
public void draw() {
image.drawFromTopLeft(pos.x, pos.y);
}
}
import bagel.Image;
import bagel.util.Point;
/**
* a stationary entity: zombie
*/
public class Zombie{
/**
* the zombie's image displayed in the window
*/
private Image image;
/**
* a Point object representing the position of the zombie
*/
private Point pos;
/**
* constructor
* @param x abscissa
* @param y ordinate
*/
public Zombie(double x, double y){
this.image = new Image("res/images/zombie.png");
this.pos = new Point(x,y);
}
/**
* draw zombie on the background
*/
public void draw() {
image.drawFromTopLeft(pos.x, pos.y);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment