From 0524f455104bd399ee2f6b9a9a812480fb0ac007 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 12 Feb 2020 19:34:13 +0100 Subject: [PATCH] allow player graphics to be null --- engine.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/engine.js b/engine.js index d0a87c4..8f5291a 100644 --- a/engine.js +++ b/engine.js @@ -223,8 +223,8 @@ function Hero(gender = "female", hair = "short"){ hands: new Mob("/animations/avatar/"+gender+"/default_hands.txt"), legs : new Mob("/animations/avatar/"+gender+"/cloth_pants.txt"), feet : new Mob("/animations/avatar/"+gender+"/default_feet.txt"), - main : new Mob("/animations/avatar/"+gender+"/default_hands.txt"), - off : new Mob("/animations/avatar/"+gender+"/default_hands.txt") + main : null,// new Mob("/animations/avatar/"+gender+"/default_hands.txt"), + off : null // new Mob("/animations/avatar/"+gender+"/default_hands.txt") } this.dress = function(limb, item) { @@ -236,21 +236,21 @@ function Hero(gender = "female", hair = "short"){ this.place = function(x,y) { this.position[0] = x, this.position[1] = y; - for (var limb in limbs) limbs[limb].place(x,y); + for (var limb in limbs) limbs[limb] && limbs[limb].place(x,y); return this; } this.direct = function(d) { direction = d; - for (var limb in limbs) limbs[limb].direct(d); + for (var limb in limbs) limbs[limb] && limbs[limb].direct(d); return this; } this.animate = function(anim){ animation = anim; - for (var limb in limbs) limbs[limb].animate(anim); + for (var limb in limbs) limbs[limb] && limbs[limb].animate(anim); return this; } this.draw = function(x, y){ - layers.layer[direction].forEach(limb => limbs[limb].draw(x, y)); + layers.layer[direction].forEach(limb => limbs[limb] && limbs[limb].draw(x, y)); return this; } @@ -329,6 +329,7 @@ window.addEventListener("resize", function(){ canvas.canvas.height = window.innerHeight; }); +// player = new Mob("animations/enemies/zombie.txt"); player.stats = { speed: 3 }; player = new Hero(); map = new Map("/maps/arrival.txt"); player.place(map.info.header.hero_pos.split(/,/)[0] * map.info.header.tilewidth, -- 2.39.2