forked from udohi/GameArena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sheep.java
121 lines (106 loc) · 2.87 KB
/
Sheep.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import java.util.Random;
public class Sheep
{
public static Random rand = new Random();
private Ball head;
private Ball headCover;
private Ball mouth;
private Ball eyer;
private Ball eyel;
private Ball arse;
private Ball abdomen;
private Ball neck;
private Rectangle legBack;
private Rectangle legFront;
public Rectangle collisionBox;
public Rectangle collisionBoxLegs;
private int height;
private int x, y;
private boolean collision = false;
public int getYPosition()
{
return y;
}
public void setYPosition(int newY)
{
y = newY;
}
public int getXPosition()
{
return x;
}
public void setXPosition(int newX)
{
x = newX;
}
public Sheep(int inX, int inY, int w, int h, java.lang.String col, GameArena arena)
{
x = inX;
y = inY;
if (rand.nextBoolean())
col = "WHITE";
else
col = "GRAY";
head = new Ball(inX+50, inY-(h/2), 20, "PINK");
headCover = new Ball(inX+60, inY-(h/2)+8, 7, "PINK"); //headCover is to make it so facial features can be created
mouth = new Ball(inX+60, inY-(h/2)+10, 7, "BLACK"); //i.e. a mouth by using a headCover and a black Ball
eyer = new Ball(inX+53, inY-(h/2), 3, "BLACK");
eyel = new Ball(inX+58, inY-(h/2), 3, "BLACK");
arse = new Ball(inX-40, inY, 25, col);
abdomen = new Ball(inX, inY, 40, col);
neck = new Ball(inX+40, inY, 20, col);
legBack = new Rectangle(inX-30, inY+30, 10, 50, "BLACK");
legFront = new Rectangle(inX+30, inY+30, 10, 50, "BLACK");
collisionBox = new Rectangle(inX+5, inY, 135, 60, "RED");
collisionBoxLegs = new Rectangle (inX, inY+30, 72, 50, "BLUE");
arena.addRectangle(collisionBox);
arena.addRectangle(collisionBoxLegs);
arena.addRectangle(legBack);
arena.addRectangle(legFront);
arena.addBall(arse);
arena.addBall(abdomen);
arena.addBall(neck);
arena.addBall(head);
arena.addBall(mouth);
// arena.addBall(eyel);
arena.addBall(eyer);
arena.addBall(headCover);
height = h;
}
public void updateY(int y)
{
setYPosition(y);
head.setYPosition(y - (height/2));
legBack.setYPosition(y + 30);
legFront.setYPosition(y + 30);
arse.setYPosition(y);
abdomen.setYPosition(y);
neck.setYPosition(y);
mouth.setYPosition(y - (height/2) + 10);
eyer.setYPosition(y - (height/2));
headCover.setYPosition(y - (height/2) + 8);
collisionBox.setYPosition(y-(height/2)+12);
collisionBoxLegs.setYPosition(y-(height/2)+12);
collisionBox.setYPosition(y);
collisionBoxLegs.setYPosition(y + 30);
}
public void updateX(int x)
{
setXPosition(x);
head.setXPosition(x + 50);
legBack.setXPosition(x - 30);
legFront.setXPosition(x + 30);
arse.setXPosition(x - 40);
abdomen.setXPosition(x);
neck.setXPosition(x + 40);
mouth.setXPosition(x + 60);
eyer.setXPosition(x + 53);
headCover.setXPosition(x + 60);
collisionBox.setXPosition(x + 5);
collisionBoxLegs.setXPosition(x);
}
public void shiftLeft()
{
updateX(getXPosition() - 5);
}
}