diff --git a/src/jsds.js b/src/jsds.js index 251a8db..2b416c1 100644 --- a/src/jsds.js +++ b/src/jsds.js @@ -248,10 +248,25 @@ $('#uiatt').html(outstr); - $('#att').bind("change", function() {cur_sel.att=this.value;}); + $('#att').bind("change", function() { + cur_sel.att=this.value; + cur_sel.printoutput(); + }); $('#defendible').bind("change", - function() { cur_sel.defendible = (this.value === "true" ? true : false);}); + function() { + cur_sel.defendible = (this.value === "true" ? true : false); + cur_sel.printoutput(); + }); $("#"+this.att).get(0).selected="true"; + }, + + calc_dist: function() { + var g = this.graphelement; + g.calc_center(); + var dx = Math.abs(g.cx - g.old_pos["cx"]); + var dy = Math.abs(g.cy - g.old_pos.cy); + var distpx= Math.sqrt(dx*dx + dy*dy); + return (distpx/meters).toFixed(1); } }); @@ -323,6 +338,7 @@ outstr += this.info.cname + " (gespielt von "+this.info.pname +")
"; outstr += "Greift derzeit durch " + this.att + " mit einer Stärke von " + this.battle[this.att] + " an.
"; + outstr += "Ist "+this.calc_dist()+"m von der alten Position entfernt (max ??)
"; outstr += "Verteidigungsstärke: " + this.battle.defense + "
"; outstr += "Kraftpunkte: " + this.life; outstr += "

"; @@ -348,6 +364,7 @@ outstr += "Ein "+ this.info.race + "
"; outstr += "Greift derzeit durch " + this.att + " mit einer Stärke von " + this.battle[this.att] + " an.
"; + outstr += "Ist "+this.calc_dist()+"m von der alten Position entfernt (max ??)
"; outstr += "Verteidigungsstärke: " + this.battle.defense + "
"; outstr += "Kraftpunkte: " + this.life; outstr += "

"; diff --git a/src/jsds_crafty.js b/src/jsds_crafty.js index c94888d..d003681 100644 --- a/src/jsds_crafty.js +++ b/src/jsds_crafty.js @@ -90,9 +90,11 @@ if(e.mouseButton === Crafty.mouseButtons.LEFT) { if( cur_sel != player[this.id] ) { this.calc_center(); + this.old_pos["cx"]=this.cx; + this.old_pos["cy"]=this.cy; + this.old_pos["x"]=this.x; + this.old_pos["y"]=this.y; }; - this.old_pos["x"]=this.x; - this.old_pos["y"]=this.y; Crafty("Creature").each( function() { this.disableControl(); }); @@ -117,6 +119,11 @@ }; }; }); + this.bind('MouseUp', function(e) { + if(e.mouseButton === Crafty.mouseButtons.LEFT) { + cur_sel.printoutput(); + } + }); return this; },