Skip to content

Commit 91f3a1d

Browse files
committed
add damage taken starter
1 parent 30af170 commit 91f3a1d

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/client/game.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ export class Game {
2222
document.body.appendChild(this.app.canvas)
2323

2424
const monsters = [
25-
new Bigfoot(this.app),
25+
new Bigfoot(this.app, 1026),
2626
new Bigfoot(this.app),
2727
]
2828

2929
this.monsterManager = new MonsterManager(this.app, monsters)
3030
this.likeEventManager = new LikeEventManager(this.app, this.monsterManager)
3131

32-
const socket = io('http://localhost:3000?u=tbell112')
32+
const socket = io('http://localhost:3000?u=live_arcade_')
3333

3434
socket.on('connect', () => {
3535
console.log('Connected to server')

src/client/healthBar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class HealthBar {
2828
this.healthBar.rect(0, 0, 200, 24)
2929
this.healthBar.fill(0x00CC00)
3030
this.healthBar.x = initialX
31+
this.healthBar.scale.x = Math.max(monster.getHealthPercentage(), 0)
3132
this.healthBar.y = initialY
3233
this.container.addChild(this.healthBar)
3334

src/client/monster.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export class Monster extends EventEmitter {
1515

1616
constructor(app: PIXI.Application) {
1717
super()
18-
this.damageTaken = 0
1918
this.killed = false
2019
this.app = app
2120
}

src/client/monsters/bigfoot.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import * as PIXI from 'pixi.js'
22
import { Monster } from '../monster'
33

44
export class Bigfoot extends Monster {
5-
constructor(app: PIXI.Application) {
5+
constructor(app: PIXI.Application, startHealth?: number) {
66
super(app)
77
this.name = 'Bigfoot'
8-
this.hp = 200
8+
this.hp = 10000
9+
this.damageTaken = startHealth ?? 0
910
this.sprites = {
1011
idle: './sprites/bigfoot/idle.json',
1112
die: './sprites/bigfoot/die.json',

0 commit comments

Comments
 (0)