BlueGit

blue-star speeltuin

tile explosion

timfa wsadhelios · pushed by timfa

Authored 2022-10-19 · 4 years ago

Hash
d12b84a680e90e8a646eff407ae85282b44dff29
Parent
00ce5843
6 files changed +42 −7
build/images/object/fruit.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/tile/tile_floor_explosion_anim.png added Binary file +0 −0

The contents of this binary file are not shown.

src/game.js +4 −3
@@ -29,11 +29,14 @@ window.onload = function()
29 29 {name:"chao_red", url:"images/character/chao/red.png", subImgTotal: 67, perRow: 9},
30 30 {name:"chao_white", url:"images/character/chao/white.png", subImgTotal: 67, perRow: 9},
31 31 {name:"chao_yellow", url:"images/character/chao/yellow.png", subImgTotal: 67, perRow: 9},
32 {name:"tile_floor_brown", url:"images/tile/tile_floor_brown.png"}
32 {name:"tile_floor_brown", url:"images/tile/tile_floor_brown.png"},
33 {name:"tile_floor_explosion", url:"images/tile/tile_floor_explosion_anim.png", subImgTotal:10, perRow:5},
34 {name:"fruit", url:"images/object/fruit.png", subImgtotal: 15, perRow: 8}
33 35 ]
34 36 , function()
35 37 {
36 38 game.images.frog_basic.addAnimationCycle("walk", [0,1,2,1], true);
39 game.images.tile_floor_explosion.addAnimationCycle("destroy", [0,1,2,3,4,5,6,7,8,9], false);
37 40 this.setupChaoAnimations(game.images.chao_default)
38 41 this.setupChaoAnimations(game.images.chao_blue)
39 42 this.setupChaoAnimations(game.images.chao_cyan)
@@ -123,11 +126,9 @@ createSubScene = function(scene)
123 126 scene.loadChildScene(subScene);
124 127
125 128 frog = new Frog(60,555, game.images.frog_basic, 0);
126 console.log(game.images.tile_floor_brown);
127 129 for(tx = 10; tx < subScene.real_size.x; tx += 15)
128 130 {
129 131 subScene.addObject(new FloorTile(tx, 570, game.images.tile_floor_brown, 0));
130 132 }
131 133 subScene.addObject(frog);
132
133 134 }
@@ -29,11 +29,14 @@ window.onload = function()
29 {name:"chao_red", url:"images/character/chao/red.png", subImgTotal: 67, perRow: 9},
29 {name:"chao_red", url:"images/character/chao/red.png", subImgTotal: 67, perRow: 9},
30 {name:"chao_white", url:"images/character/chao/white.png", subImgTotal: 67, perRow: 9},
30 {name:"chao_white", url:"images/character/chao/white.png", subImgTotal: 67, perRow: 9},
31 {name:"chao_yellow", url:"images/character/chao/yellow.png", subImgTotal: 67, perRow: 9},
31 {name:"chao_yellow", url:"images/character/chao/yellow.png", subImgTotal: 67, perRow: 9},
32 {name:"tile_floor_brown", url:"images/tile/tile_floor_brown.png"}
32 {name:"tile_floor_brown", url:"images/tile/tile_floor_brown.png"},
33 {name:"tile_floor_explosion", url:"images/tile/tile_floor_explosion_anim.png", subImgTotal:10, perRow:5},
34 {name:"fruit", url:"images/object/fruit.png", subImgtotal: 15, perRow: 8}
33 ]
35 ]
34 , function()
36 , function()
35 {
37 {
36 game.images.frog_basic.addAnimationCycle("walk", [0,1,2,1], true);
38 game.images.frog_basic.addAnimationCycle("walk", [0,1,2,1], true);
39 game.images.tile_floor_explosion.addAnimationCycle("destroy", [0,1,2,3,4,5,6,7,8,9], false);
37 this.setupChaoAnimations(game.images.chao_default)
40 this.setupChaoAnimations(game.images.chao_default)
38 this.setupChaoAnimations(game.images.chao_blue)
41 this.setupChaoAnimations(game.images.chao_blue)
39 this.setupChaoAnimations(game.images.chao_cyan)
42 this.setupChaoAnimations(game.images.chao_cyan)
@@ -123,11 +126,9 @@ createSubScene = function(scene)
123 scene.loadChildScene(subScene);
126 scene.loadChildScene(subScene);
124
127
125 frog = new Frog(60,555, game.images.frog_basic, 0);
128 frog = new Frog(60,555, game.images.frog_basic, 0);
126 console.log(game.images.tile_floor_brown);
127 for(tx = 10; tx < subScene.real_size.x; tx += 15)
129 for(tx = 10; tx < subScene.real_size.x; tx += 15)
128 {
130 {
129 subScene.addObject(new FloorTile(tx, 570, game.images.tile_floor_brown, 0));
131 subScene.addObject(new FloorTile(tx, 570, game.images.tile_floor_brown, 0));
130 }
132 }
131 subScene.addObject(frog);
133 subScene.addObject(frog);
132
133}
134}
src/minigame/frog/floorTile.js +11 −3
@@ -1,13 +1,21 @@
1 1 class FloorTile extends GameObject{
2
2
3 3 constructor(x,y,sprite,layer)
4 4 {
5 5 super(x,y,sprite,layer);
6 6 this.collider.enabled = true;
7 7 }
8 8
9 draw(context)
9 update(deltaTime)
10 10 {
11 super.draw();
11 super.update(deltaTime);
12
13 if(GameInput.mousePressed(GameInput.MouseButtons.Left))
14 {
15 if(this.collider.isInBounds(new vector(GameInput.mousePosition.x - this.scene.real_position.x, GameInput.mousePosition.y - this.scene.real_position.y))) {
16 this.scene.addObject(new FloorTileDestroyer(this.transform.position.x, this.transform.position.y, this.scene.game.images.tile_floor_explosion,0, .05, true));
17 this.destroy();
18 }
19 }
12 20 }
13 21 }
@@ -1,13 +1,21 @@
1class FloorTile extends GameObject{
1class FloorTile extends GameObject{
2
2
3 constructor(x,y,sprite,layer)
3 constructor(x,y,sprite,layer)
4 {
4 {
5 super(x,y,sprite,layer);
5 super(x,y,sprite,layer);
6 this.collider.enabled = true;
6 this.collider.enabled = true;
7 }
7 }
8
8
9 draw(context)
9 update(deltaTime)
10 {
10 {
11 super.draw();
11 super.update(deltaTime);
12
13 if(GameInput.mousePressed(GameInput.MouseButtons.Left))
14 {
15 if(this.collider.isInBounds(new vector(GameInput.mousePosition.x - this.scene.real_position.x, GameInput.mousePosition.y - this.scene.real_position.y))) {
16 this.scene.addObject(new FloorTileDestroyer(this.transform.position.x, this.transform.position.y, this.scene.game.images.tile_floor_explosion,0, .05, true));
17 this.destroy();
18 }
19 }
12 }
20 }
13}
21}
src/minigame/frog/floorTileDestroyer.js added +26 −0
@@ -0,0 +1,26 @@
1 class FloorTileDestroyer extends GameObject{
2
3 timeOfDestroy = 0;
4 timer = 0;
5
6 constructor(x,y,sprite,layer, animationLength, destroyAfter)
7 {
8 super(x,y,sprite,layer);
9
10 this.renderer.setAnimation("destroy",0 , animationLength);
11
12 this.timeOfDestroy = this.renderer.sprite.subImages * animationLength;
13 }
14
15 update(deltaTime)
16 {
17 super.update(deltaTime);
18
19
20 this.timer += deltaTime;
21 if(this.timer > this.timeOfDestroy)
22 {
23 this.destroy();
24 }
25 }
26 }
@@ -0,0 +1,26 @@
1class FloorTileDestroyer extends GameObject{
2
3 timeOfDestroy = 0;
4 timer = 0;
5
6 constructor(x,y,sprite,layer, animationLength, destroyAfter)
7 {
8 super(x,y,sprite,layer);
9
10 this.renderer.setAnimation("destroy",0 , animationLength);
11
12 this.timeOfDestroy = this.renderer.sprite.subImages * animationLength;
13 }
14
15 update(deltaTime)
16 {
17 super.update(deltaTime);
18
19
20 this.timer += deltaTime;
21 if(this.timer > this.timeOfDestroy)
22 {
23 this.destroy();
24 }
25 }
26}
src/minigame/frog/frog.js +1 −1
@@ -74,7 +74,7 @@ class Frog extends GameObject {
74 74
75 75 if(this.idle && this.tongue_retracted && !this.retracting)
76 76 {
77 this.renderer.setAnimation("walk", 0, -1);
77 this.renderer.setSubImage(0);
78 78 }
79 79
80 80
@@ -74,7 +74,7 @@ class Frog extends GameObject {
74
74
75 if(this.idle && this.tongue_retracted && !this.retracting)
75 if(this.idle && this.tongue_retracted && !this.retracting)
76 {
76 {
77 this.renderer.setAnimation("walk", 0, -1);
77 this.renderer.setSubImage(0);
78 }
78 }
79
79
80
80