-
Notifications
You must be signed in to change notification settings - Fork 2
/
expOrb.js
40 lines (34 loc) · 1.09 KB
/
expOrb.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
class ExpOrb {
/**
*
* @param {Int16Array} x - the x cord for the orb
* @param {Int16Array} y - the y cord for the orb
* @param {Int16Array} [amount] - the amount of exerience the orb contains: default is 25
*/
constructor(x,y, amount = 25){
this.expOrb = new non_colliding.Sprite(x,y);
this.expOrb.image ="assets/Exp1.png"
this.expOrb.collides(player.returnPlayerObject())
this.expOrb.overlaps(itmBoxes)
this.expOrb.overlaps(non_colliding)
orbs.push(this.expOrb);
// this.expOrb.color = 'lime';
this.expOrb.amount = amount;
this.expOrb.visible = true;
}
/**
*
* @returns the amount of experience the orb contains
*/
getExp(){return this.amount;}
static createExp(x,y,amount = 25){
if(orbs.length < 10){
new ExpOrb(x,y,amount);
}
else{
orbs[orbs.length-1].amount += amount;
// orbs[orbs.length-1].color = 'red'
orbs[orbs.length-1].addAnimation('assets/exp2.png')
}
}
};