From f81c5387920a02b0a88ae81a0a533ced3bd525d3 Mon Sep 17 00:00:00 2001 From: kdrzazga Date: Thu, 19 Dec 2024 18:41:25 +0100 Subject: [PATCH] Lotsa rats --- other/electrician/files/classdef.js | 23 +++++++++++++++++++++-- other/electrician/files/electrician.js | 6 ++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/other/electrician/files/classdef.js b/other/electrician/files/classdef.js index 60bc42c..8eb1514 100644 --- a/other/electrician/files/classdef.js +++ b/other/electrician/files/classdef.js @@ -275,7 +275,7 @@ class Rat extends Enemy{ } init(physics, y){ - this.sprite = physics.add.sprite(180 + (this.id + 1)*110, y, 'rat' + this.id); + this.sprite = physics.add.sprite(180 + (this.id + 1)*44, y, 'rat' + this.id); this.sprite.velocity = { x: this.speed }; } @@ -295,12 +295,31 @@ class Creator{ const rat1 = new Rat(1); rat1.init(physics, 589); + const rat2 = new Rat(2); rat2.init(physics, 104); rat2.minX = 2 * 6 * Wire.SIZE; rat2.maxX = (6 + 22) * Wire.SIZE; - building.enemies.push(rat1, rat2); + const rat3 = new Rat(3); + rat3.init(physics, 589); + rat3.sprite.velocity = { x: 1.2 }; + + const rat4 = new Rat(4); + rat4.init(physics, 589); + rat4.sprite.velocity = { x: 1.4 }; + + const rat5 = new Rat(5); + rat5.init(physics, 328 - Floor.HEIGHT /2); + rat5.minX = 2*Floor.WIDTH/3 + 18; + rat5.sprite.velocity = { x: 1.4 }; + + const rat6 = new Rat(6); + rat6.init(physics, 328 - Floor.HEIGHT /2); + rat6.minX = 2*Floor.WIDTH/3 + 18; + rat6.sprite.velocity = { x: 0.8 }; + + building.enemies.push(rat1, rat2, rat3, rat4, rat5, rat6); return building; } diff --git a/other/electrician/files/electrician.js b/other/electrician/files/electrician.js index 9b8c80a..6ae2126 100644 --- a/other/electrician/files/electrician.js +++ b/other/electrician/files/electrician.js @@ -6,8 +6,10 @@ class MainScene extends Phaser.Scene { preload() { this.load.image('sprite', 'files/electrician.png'); - this.load.image('rat1', 'files/rat.png'); - this.load.image('rat2', 'files/rat.png'); + for (let i = 1; i <= 8; i++) { + this.load.image(`rat${i}`, 'files/rat.png'); + } + this.load.image('ladder', 'files/ladder.png'); this.load.image('floor0', 'files/attic.png');