MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / Coin

Class Coin

Coin.js:1–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Coin{
2 constructor(x,y, type = "reward") {
3 this.levelNo = 0;
4 this.x = x;
5 this.y= y;
6 this.radius = 50;
7 this.type = type;
8 }
9
10
11 collidesWithPlayer(playerToCheck){
12 let playerMidPoint = playerToCheck.currentPos.copy();
13 playerMidPoint.x += playerToCheck.width/2;
14 playerMidPoint.y += playerToCheck.height/2;
15 if(dist(playerMidPoint.x,playerMidPoint.y,this.x,this.y)<this.radius + playerToCheck.width/2){
16 return true;
17 }
18 return false;
19 }
20
21 show(){
22 push();
23 if(this.type == "reward"){
24
25 fill(255,150,0);
26 }else{
27 fill(0,200,0,100);
28 }
29 noStroke();
30 ellipse(this.x,this.y,this.radius*2);
31 pop();
32
33
34 }
35
36}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected