-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.java
66 lines (42 loc) · 1.06 KB
/
Entity.java
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
import java.util.List;
import java.util.Optional;
import processing.core.PImage;
/*
Entity ideally would includes functions for how all the entities in our virtual world might act...
*/
public class Entity {
private final String id;
private Point position;
private final List<PImage> images;
private int imageIndex;
protected String getId(){
return id;
}
protected Point getPosition(){
return position;
}
protected List<PImage> getImages(){
return images;
}
protected int getImageIndex(){
return imageIndex;
}
public PImage getCurrentImage()
{
return(this.getImages().get(this.getImageIndex()));
}
protected void setPosition(Point position){
this.position = position;
}
public Entity(String id, Point position,
List<PImage> images) {
this.id = id;
this.position = position;
this.images = images;
this.imageIndex = 0;
}
public void nextImage()
{
this.imageIndex = (this.imageIndex + 1) % this.images.size();
}
}