-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.js
102 lines (87 loc) · 1.97 KB
/
player.js
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
function Player(x, y, img) {
this.x = x;
this.y = y;
this.life = 3;
this.checkpoint = 0;
this.level = 3;
this.infos = 0;
this.img = img;
this.grabbedlife=0;
this.show = function() {
// fill(255, 0, 0);
// rect(this.x, this.y, scl, scl);
image(this.img, this.x, this.y);
}
this.lostlife = function() {
this.life--;
// RELOCATING DEPENDING ON CHECKPOINT
if ( player.checkpoint === 0){
this.x = playerInitialX;
this.y = playerInitialY;
}
if ( player.checkpoint === 1){
this.x = 20*scl;
this.y = 24*scl;
}
if ( player.checkpoint === 2){
this.x = 6*scl;
this.y = 3*scl;
}
if ( player.checkpoint === 3){
this.x = 19*scl;
this.y = 21*scl;
}
if ( player.checkpoint === 4){
this.x = 38*scl;
this.y = 36*scl;
}
if ( player.checkpoint === 5){
this.x = 60*scl;
this.y = 29*scl;
}
}
this.pickup = function(something) {
if (this.x === something.x && this.y === something.y) {
return true;
} else {
return false;
}
}
// BUMPING INTO THINGS---------------------------------------------------
// boolean function
this.bumpinto = function(other) {
if (this.x === other.x && this.y === other.y) {
return true;
} else {
return false;
}
}
this.bumpIntoUpWall = function(wall) {
if (this.x === wall.x && this.y - scl === wall.y) {
return true;
} else {
return false;
}
}
this.bumpIntoDownWall = function(downwall) {
if (this.x === downwall.x && this.y + scl === downwall.y) {
return true;
} else {
return false;
}
}
this.bumpIntoRightWall = function(rightwall) {
if (this.x + scl === rightwall.x && this.y === rightwall.y) {
return true;
} else {
return false;
}
}
this.bumpIntoLeftWall = function(leftwall) {
if (this.x - scl === leftwall.x && this.y === leftwall.y) {
return true;
} else {
return false;
}
}
}