From ee680009ef7310b126c9bd3507742b040b5a53c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Wed, 24 Sep 2014 16:11:06 +0200 Subject: [PATCH] "Beast" and "Player" now inherit from "Creature". --- src/jsds.js | 37 ++++++++++++++++++++----------------- src/jsds_crafty.js | 4 ++-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/jsds.js b/src/jsds.js index f388689..e1b905b 100644 --- a/src/jsds.js +++ b/src/jsds.js @@ -1,14 +1,11 @@ { - function Player(info,attributes,properties,drawinfo){ // x,y,w,h,col) { + function Creature(info,attributes,properties,drawinfo){ /* info: pname, cname,class, level, experience, race, size * attributes: body, agility, spirit * properties: strength, hardness, movement, skill, mind, aura * drawinfo: x,y,w,h,col */ - - // player.push(Crafty.e("Creature").player(x,y,w,h,col); - this.info = {"pname": info["pname"]+"", "cname": info["cname"]+"", "class": info["class"]+"", - "level": info["level"]*1, "experience": info["experience"]*1, "race":info["race"]+"", + this.info = {"pname": info["pname"]+"", "experience": info["experience"]*1, "race":info["race"]+"", "size":info["size"]*1}; this.attributes = {"body": attributes["body"]*1, "agility": attributes["agility"]*1, "spirit": attributes["spirit"]*1}; @@ -17,7 +14,22 @@ "mind": properties["mind"]*1, "aura": properties["aura"]*1}; this.graphelement = Crafty.e("Creature").creature(this.info["pname"],drawinfo["x"],drawinfo["y"],drawinfo["w"], - drawinfo["h"],drawinfo["col"]); + drawinfo["h"],drawinfo["col"]); + + }; + + function Player(info,attributes,properties,drawinfo){ // x,y,w,h,col) { + /* info: pname, cname,class, level, experience, race, size + * attributes: body, agility, spirit + * properties: strength, hardness, movement, skill, mind, aura + * drawinfo: x,y,w,h,col + */ + + Creature.apply(this, arguments); + this.info["cname"]= info["cname"]+""; + this.info["class"]= info["class"]+""; + this.info["level"]= info["level"]*1; + }; Player.prototype.printoutput = function() { @@ -31,23 +43,14 @@ * properties: strength, hardness, movement, skill, mind, aura * drawinfo: x,y,w,h,col */ - - this.info = {"pname": info["pname"]+"", "experience": info["experience"]*1, "race":info["race"]+"", - "size":info["size"]*1}; - this.attributes = {"body": attributes["body"]*1, "agility": attributes["agility"]*1, - "spirit": attributes["spirit"]*1}; - this.properties = {"strength": properties["strength"]*1 , "hardness": info["hardness"]*1, - "movement": info["movement"]*1, "skill": properties["skill"]*1, - "mind": properties["mind"]*1, "aura": properties["aura"]*1}; - this.graphelement = Crafty.e("Creature").creature(this.info["pname"],drawinfo["x"],drawinfo["y"],drawinfo["w"], - drawinfo["h"],drawinfo["col"]); + Creature.apply(this,arguments); }; Beast.prototype.printoutput = function() { $('#output').empty(); $('#output').html(this.info.race+"
"+this.info.pname); }; - + } diff --git a/src/jsds_crafty.js b/src/jsds_crafty.js index 1f662a6..c359361 100644 --- a/src/jsds_crafty.js +++ b/src/jsds_crafty.js @@ -78,8 +78,8 @@ this.enableControl(); }; /* if(e.mouseButton === Crafty.mouseButtons.RIGHT) { - cur_sel.attack(player[this.id]); - };*/ + cur_sel.attack(player[this.id]);*/ + }; }); return this;