-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathship.js
More file actions
38 lines (29 loc) · 669 Bytes
/
ship.js
File metadata and controls
38 lines (29 loc) · 669 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
function Ship() {
this.x = width / 2;
this.y = height - 40;
this.diameter = 30;
this.dead = false;
this.sprite = loadImage("ship/playerModel.png");
this.show = function() {
//fill(this.sprite);
//imageMode(CENTER);
image(this.sprite, this.x - 15, this.y, this.diameter, this.diameter - 10);
}
this.move = function(dir) {
this.x += dir * 3;
}
this.die = function() {
this.dead = true;
}
this.outofbounds = function()
{
if (this.x > gameWidth)
{
this.x = gameWidth;
}
else if (this.x < 0)
{
this.x = 0;
}
}
}