Skip to content

Commit

Permalink
Lotsa rats
Browse files Browse the repository at this point in the history
  • Loading branch information
kdrzazga committed Dec 19, 2024
1 parent 0593b39 commit f81c538
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
23 changes: 21 additions & 2 deletions other/electrician/files/classdef.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand All @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions other/electrician/files/electrician.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit f81c538

Please sign in to comment.