-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbolinha.js
83 lines (51 loc) · 1.22 KB
/
bolinha.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
function Bola(sprite, x, y, classename, val) {
this.on = false;
this.val = val;
h = 40;
w = 40;
this.dep01 = null;
this.dep02 = null;
GameObject.call(this, sprite, x, y, classename, h,w);
}
//fazendo herança
Bola.prototype = Object.create(GameObject.prototype);
Bola.prototype.update = function () {
if(!this.on){
if( (this.dep01 == null ) || (this.dep01.getOn())) {
this.currentAnimation = 1;
}else{
this.currentAnimation = 0;
}
}else{
if( (this.dep02 == null ) || (!this.dep02.getOn())) {
this.currentAnimation = 1;
}else{
this.currentAnimation = 0;
}
}
};
Bola.prototype.getVal = function () {
return this.val;
}
Bola.prototype.getOn = function () {
return this.on;
}
Bola.prototype.setDependence = function (dep01,dep02) {
this.dep01 = dep01;
this.dep02 = dep02;
}
Bola.prototype.click = function () {
if(!this.on){
if( (this.dep01 == null ) || (this.dep01.getOn())) {
this.x = 110 + this.x;
this.on = true;
valor += this.val;
}
}else{
if( (this.dep02 == null ) || (!this.dep02.getOn())) {
this.x = this.x - 110;
this.on = false;
valor -= this.val;
}
}
};