Skip to content

Commit

Permalink
Enemy laser beams no longer wrap around game screen bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
colinkiama committed Dec 29, 2024
1 parent 1ac86be commit 1b5212c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "last-one-flying",
"description": "An arcade survival shooter made with Phaser 3.",
"version": "0.4.1",
"version": "0.5.0",
"type": "module",
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion src/poolObjects/LaserBeam.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class LaserBeam extends Physics.Arcade.Image {

update(time, delta) {
this.lifespan -= delta;
this.scene.physics.world.wrap(this, this.width / 2);

if (this.lifespan <= 0) {
this.disableBody(true, true);
Expand Down
12 changes: 12 additions & 0 deletions src/poolObjects/PlayerLaserBeam.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { LaserBeam } from './LaserBeam.js';

export class PlayerLaserBeam extends LaserBeam {
update(time, delta) {
this.lifespan -= delta;
this.scene.physics.world.wrap(this, this.width / 2);

if (this.lifespan <= 0) {
this.disableBody(true, true);
}
}
}
3 changes: 2 additions & 1 deletion src/scenes/Battle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ScoreSystem } from '../systems/scoreSystem.js';
import { StatusSystem } from '../systems/statusSystem.js';

import { LaserBeam } from '../poolObjects/LaserBeam.js';
import { PlayerLaserBeam } from '../poolObjects/PlayerLaserBeam.js';
import { BasicEnemy } from '../poolObjects/BasicEnemy.js';
import { Explosion } from '../poolObjects/Explosion.js';

Expand Down Expand Up @@ -46,7 +47,7 @@ export class Battle extends Scene {
this.cameras.main.setBackgroundColor(0x000000);

this._laserPool = this.physics.add.group({
classType: LaserBeam,
classType: PlayerLaserBeam,
maxSize: 50,
runChildUpdate: true,
});
Expand Down

0 comments on commit 1b5212c

Please sign in to comment.