Ok RoomObjects are now actually actors
This commit is contained in:
parent
452969c7be
commit
60e8054ce8
@ -27,10 +27,15 @@ export default class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
this.currentRoom = this.assets.get("sampleRoom")
|
this.loadRoom(this.assets.get("sampleRoom"))
|
||||||
requestAnimationFrame(this.loop.bind(this))
|
requestAnimationFrame(this.loop.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadRoom(room) {
|
||||||
|
this.currentRoom = room
|
||||||
|
this.currentRoom.objects.forEach(roomObject => this.actors.push(roomObject))
|
||||||
|
}
|
||||||
|
|
||||||
loop(timestamp) {
|
loop(timestamp) {
|
||||||
const dt = timestamp - this.timestamp
|
const dt = timestamp - this.timestamp
|
||||||
this.timestamp = timestamp
|
this.timestamp = timestamp
|
||||||
@ -42,7 +47,6 @@ export default class Game {
|
|||||||
|
|
||||||
tick(dt) {
|
tick(dt) {
|
||||||
this.actors.forEach(actor => actor.tick(dt))
|
this.actors.forEach(actor => actor.tick(dt))
|
||||||
this.currentRoom.tick(dt)
|
|
||||||
Object.values(this.events).forEach(e => e.nextFrame())
|
Object.values(this.events).forEach(e => e.nextFrame())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ export default class Room {
|
|||||||
|
|
||||||
draw(ctx) {
|
draw(ctx) {
|
||||||
this.json.layers.forEach(this.drawLayer.bind(this, ctx))
|
this.json.layers.forEach(this.drawLayer.bind(this, ctx))
|
||||||
this.objects.forEach(object => object.draw(ctx))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawLayer(ctx, layer) {
|
drawLayer(ctx, layer) {
|
||||||
|
Loading…
Reference in New Issue
Block a user