Impact animations
This commit is contained in:
@@ -14,6 +14,7 @@ export class ProjectileTileFactory extends TileFactory {
|
||||
spin: number;
|
||||
speed: number;
|
||||
loft: number;
|
||||
duration: number;
|
||||
|
||||
tile_factory: TileFactory;
|
||||
|
||||
@@ -41,6 +42,8 @@ export class ProjectileTileFactory extends TileFactory {
|
||||
vertex_offset = h1_distance / total_distance;
|
||||
}
|
||||
|
||||
this.duration = total_distance / speed * 100;
|
||||
|
||||
copy.add_animation(
|
||||
'launch-x',
|
||||
[
|
||||
@@ -57,7 +60,7 @@ export class ProjectileTileFactory extends TileFactory {
|
||||
},
|
||||
],
|
||||
{
|
||||
'duration': total_distance / speed * 100,
|
||||
'duration': this.duration,
|
||||
'iterations': 1,
|
||||
},
|
||||
);
|
||||
@@ -81,7 +84,7 @@ export class ProjectileTileFactory extends TileFactory {
|
||||
},
|
||||
],
|
||||
{
|
||||
'duration': total_distance / speed * 100,
|
||||
'duration': this.duration,
|
||||
'iterations': 1,
|
||||
},
|
||||
);
|
||||
|
||||
18
ts/tiles.ts
18
ts/tiles.ts
@@ -78,12 +78,12 @@ export const TOWER_FIREBALL1 = new LayeredTileFactory([
|
||||
export const FIREBALL = new SimpleTileFactory('projectile', 2, 2, 'fireball');
|
||||
|
||||
export const FIREBALL_IMPACT = new SequenceTileFactory([
|
||||
new SimpleTileFactory('surface', 4, 4, 'fireball-impact1'),
|
||||
new SimpleTileFactory('surface', 4, 4, 'fireball-impact2'),
|
||||
new SimpleTileFactory('surface', 4, 4, 'fireball-impact3'),
|
||||
new SimpleTileFactory('surface', 4, 4, 'fireball-impact4'),
|
||||
new SimpleTileFactory('surface', 4, 4, 'fireball-impact5'),
|
||||
new SimpleTileFactory('surface', 4, 4, 'fireball-impact6'),
|
||||
new SimpleTileFactory('surface', 4, 4, 'fireball-impact7'),
|
||||
new SimpleTileFactory('surface', 4, 4, 'fireball-impact8'),
|
||||
], 100, false);
|
||||
new SimpleTileFactory('surface', 2, 2, 'fireball-impact1'),
|
||||
new SimpleTileFactory('surface', 2, 2, 'fireball-impact2'),
|
||||
new SimpleTileFactory('surface', 2, 2, 'fireball-impact3'),
|
||||
new SimpleTileFactory('surface', 2, 2, 'fireball-impact4'),
|
||||
new SimpleTileFactory('surface', 2, 2, 'fireball-impact5'),
|
||||
new SimpleTileFactory('surface', 2, 2, 'fireball-impact6'),
|
||||
new SimpleTileFactory('surface', 2, 2, 'fireball-impact7'),
|
||||
new SimpleTileFactory('surface', 2, 2, 'fireball-impact8'),
|
||||
], 50, false);
|
||||
|
||||
13
ts/tower.ts
13
ts/tower.ts
@@ -83,16 +83,21 @@ export function main() {
|
||||
grid.add_tile(tiles.BRIDGE_LR, 46, 10);
|
||||
|
||||
function rand(min: number, max: number): number {
|
||||
return Math.random() * (max - min) + min;
|
||||
return Math.round(Math.random() * (max - min) + min);
|
||||
}
|
||||
|
||||
const tower = grid.add_tile(tiles.TOWER_FIREBALL1, 30, 28);
|
||||
setInterval(() => {
|
||||
tower.play('fire');
|
||||
grid.add_tile(new ProjectileTileFactory(tiles.FIREBALL, rand(-20, 20), rand(-10, 20), 5, 1.5, 5), 31, 27);
|
||||
const target_relative_x = rand(-20, 20);
|
||||
const target_relative_y = rand(-10, 20);
|
||||
const factory = new ProjectileTileFactory(tiles.FIREBALL, target_relative_x, target_relative_y, 5, 1.5, 5);
|
||||
grid.add_tile(factory, 31, 27);
|
||||
setTimeout(() => {
|
||||
console.log('impact!', 31 + target_relative_x, 27 + target_relative_y);
|
||||
grid.add_tile(tiles.FIREBALL_IMPACT, 31 + target_relative_x, 27 + target_relative_y);
|
||||
}, factory.duration);
|
||||
}, 3250);
|
||||
|
||||
grid.add_tile(tiles.FIREBALL_IMPACT, 15, 15);
|
||||
};
|
||||
|
||||
main();
|
||||
|
||||
Reference in New Issue
Block a user