forked from DreamTeamDZG/dubious-broccoli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ENTITY.java
66 lines (54 loc) · 1.64 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
65
66
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Provides the positions of a Entity existing in the game
*
* @author (your name)
* @version (a version number or a date)
*/
public abstract class ENTITY extends Actor
{
private POSITION position;
private boolean visible;
public ENTITY(){
this.position = new POSITION(0,0);
this.visible = true;
}
public ENTITY(int x, int y, boolean visible){
this.position = new POSITION(x, y);
this.visible = visible;
}
public ENTITY(POSITION position, boolean visible){
this.position = position;
this.visible = visible;
}
public ENTITY(POSITION position){
this.position = position;
}
public ENTITY(int x, int y){
this.position = new POSITION(x, y);
this.visible = true;
}
public void move(int x, int y){
System.out.println("Old Pos" + get_x() +"|"+ get_y() + " " + getX() + "|" + getY());
position.add(new POSITION(x, y));
// this is very unsafe but will get the job done
// consider adding an if block to this.
((MAINWORLD) getWorld()).update_view();
System.out.println("New Pos" + get_x() +"|"+ get_y() + " " + getX() + "|" + getY());
}
public POSITION get_position(){
return position;
}
public int get_x(){
return position.get_x();
}
public void set_x(int x){
position.set_x(x);
}
public int get_y(){
return position.get_y();
}
public void set_y(int y){
position.set_y(y);
}
}