]> git.plutz.net Git - flarejs/blobdiff - engine.js
load image data dynamically
[flarejs] / engine.js
index c769ccab2a3a9acdb9d333bf80cdf93a17021cec..c70679c9c0b842d7c2ba3753ed632827b70b3c2a 100644 (file)
--- a/engine.js
+++ b/engine.js
@@ -6,6 +6,12 @@ function Mob(textdef) {
   this.previous_animation = "";
   this.frametime = performance.now();
   this.image = document.querySelector("img[src='"+ this.info.image +"']");
+  if (!this.image) {
+    this.image = document.createElement("img");
+    this.image.setAttribute("src", this.info.image);
+    this.image.setAttribute("style", "display: none;");
+    document.querySelector("body").appendChild(this.image);
+  }
 
   this.place = function(x, y) { this.position = [x, y]; return this; }
   this.direct = function(d) { this.direction = d % 8; return this; }
@@ -56,12 +62,13 @@ function Mob(textdef) {
 function Player(gender = "female", hair = "short"){
   this.x=0; this.y=0; this.direction=0;
   this.limbs = {
-    head : (gender == "female")?new Mob("/animations/avatar/female/head_long.txt"):new Mob("/animations/avatar/male/head_"+hair+".txt"),
+    head : (gender == "female")?new Mob("/animations/avatar/female/head_long.txt")
+                               :new Mob("/animations/avatar/male/head_"+hair+".txt"),
     chest: new Mob("/animations/avatar/"+gender+"/default_chest.txt"),
     hands: new Mob("/animations/avatar/"+gender+"/default_hands.txt"),
     legs : new Mob("/animations/avatar/"+gender+"/default_legs.txt"),
     feet : new Mob("/animations/avatar/"+gender+"/default_feet.txt"),
-    main : new Mob("/animations/avatar/"+gender+"/club.txt"),
+    main : new Mob("/animations/avatar/"+gender+"/dagger.txt"),
     off  : new Mob("/animations/avatar/"+gender+"/shield.txt")
   }