-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNormalPig.pde
More file actions
47 lines (41 loc) · 815 Bytes
/
NormalPig.pde
File metadata and controls
47 lines (41 loc) · 815 Bytes
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
class NormalPig extends Pig
{
// Constructor
NormalPig(float x, float y)
{
super(x, y, 60, 60);
m_hp = 100;
}
// Drawing the box
void onDraw(float x, float y, float a)
{
imageMode(CENTER);
pushMatrix();
translate(x, y);
rotate(a);
fill(0, 200, 0);
stroke(0, 100, 0);
if(!isDying()){
image(imgPig, 0, 0, m_w, m_h);
}else{
image(imgPigDying, 0, 0, m_w, m_h);
}
popMatrix();
}
Shape getShape()
{
CircleShape cs = new CircleShape();
cs.m_radius = box2d.scalarPixelsToWorld(m_w / 2);
return cs;
}
FixtureDef getFixture()
{
// Define a fixture
FixtureDef fd = new FixtureDef();
// Parameters that affect physics
fd.density = 30;
fd.friction = 3.0;
fd.restitution = 0.0;
return fd;
}
}