-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntity.java
More file actions
68 lines (54 loc) · 1.57 KB
/
Copy pathEntity.java
File metadata and controls
68 lines (54 loc) · 1.57 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
58
59
60
61
62
63
64
65
66
67
68
import java.util.*;
import processing.core.PImage;
/**
* An entity that exists in the world. See EntityKind for the
* different kinds of entities that exist.
*/
public abstract class Entity {
//private EntityKind kind;
protected String id;
protected Point position;
protected List<PImage> images;
private int imageIndex;
Random rand = new Random();
protected Entity(String id, Point position, List<PImage> images){
this.id = id;
this.position = position;
this.images = images;
this.imageIndex = 0;
}
protected String getId(){
return this.id;
}
protected Point getPosition(){
return this.position;
}
protected void setPosition(Point point){
this.position = point;
}
protected List<PImage> getImages(){
return this.images;
}
protected int getImageIndex(){
return this.imageIndex;
}
// public int getHealth(){
// return this.health;
// }
/**
* Helper method for testing. Preserve this functionality while refactoring.
*/
protected String log(){
return this.id.isEmpty() ? null :
String.format("%s %d %d %d", this.id, this.position.x, this.position.y, this.imageIndex);
}
protected void nextImage() {
this.imageIndex = this.imageIndex + 1;
}
protected int getIntFromRange(int max, int min) {
return min + rand.nextInt(max-min);
}
protected double getNumFromRange(double max, double min) {
return min + rand.nextDouble() * (max - min);
}
}