-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet.java
More file actions
57 lines (45 loc) · 1.71 KB
/
Copy pathGet.java
File metadata and controls
57 lines (45 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//Gets are entities that the player wants to collide with, as they increase
//their score.
public class Get extends Entity implements Consumable, Scrollable {
//Location of image file to be drawn for a Get
public static final String GET_IMAGE_FILE = "game_assets/Get.gif";
//Dimensions of the Get
public static final int GET_WIDTH = 50;
public static final int GET_HEIGHT = 50;
//Speed that the Get moves (in pixels) each time the game scrolls
public static final int GET_DEFAULT_SCROLL_SPEED = 5;
//Amount of points received when player collides with a Get
public static final int GET_POINT_VALUE = 20;
private int scrollSpeed = GET_DEFAULT_SCROLL_SPEED;
public Get(){
this(0, 0);
}
public Get(int x, int y){
super(x, y, GET_WIDTH, GET_HEIGHT, GET_IMAGE_FILE);
}
public Get(int x, int y, String imageFile){
super(x, y, GET_WIDTH, GET_HEIGHT, imageFile);
}
public Get(int x, int y, int getWidth, int getHeight, String imageFileName){
super(x, y, GET_WIDTH, GET_HEIGHT, imageFileName);
}
public int getScrollSpeed(){
return this.scrollSpeed;
}
//Sets the scroll speed to the argument amount
public void setScrollSpeed(int newSpeed){
this.scrollSpeed = newSpeed;
}
//Move the Get left by its scroll speed
public void scroll(){
setX(getX() - this.scrollSpeed);
}
//Colliding with a Get increases the player's score by the specified amount
public int getPoints(){
return GET_POINT_VALUE;
}
//Colliding with a Get does not affect the player's HP
public int getDamage(){
return 0;
}
}