BlueGit

blue-star speeltuin

Files

speeltuin / src / minigame / frog / frogFruit.js

frogFruit.js

a6acb1c9 History
frogFruit.js 968 B Download Raw
1class FrogFruit extends GameObject
2{
3 speed = 10;
4
5 constructor (x, y, sprite, layer)
6 {
7 super(x, y, sprite, layer);
8
9 this.transform.scale = new vector(0.7, 0.7);
10 this.renderer.subImage = Math.floor(Math.randomRange(0, 15));
11
12 this.collider.enabled = true;
13 }
14
15 onCollision (obj)
16 {
17 if (obj instanceof FrogFloorTile)
18 {
19 obj.destroy();
20 this.scene.destroyFruit(this);
21 }
22 }
23
24 onDestroy ()
25 {
26 this.scene.addObject(new FrogDestroyer(this.transform.position.x, this.transform.position.y, this.scene.game.images.tile_floor_explosion, 0, .05, true));
27 }
28
29 update (deltaTime)
30 {
31 super.update(deltaTime);
32
33 this.transform.position.y += this.speed * this.scene.gameSpeed * this.scene.gameSpeed * deltaTime;
34
35 if (this.transform.position.y > this.scene.real_size.y)
36 {
37 this.scene.destroyFruit(this);
38 }
39 }
40}