Output now shows the air-line distance of old position
This commit is contained in:
parent
c4ad471099
commit
a100fca3ef
2 changed files with 28 additions and 4 deletions
21
src/jsds.js
21
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 +")<br>";
|
||||
outstr += "Greift derzeit durch " + this.att + " mit einer Stärke von "
|
||||
+ this.battle[this.att] + " an.<br>";
|
||||
outstr += "Ist "+this.calc_dist()+"m von der alten Position entfernt (max ??)<br>";
|
||||
outstr += "Verteidigungsstärke: " + this.battle.defense + "<br>";
|
||||
outstr += "Kraftpunkte: " + this.life;
|
||||
outstr += "</p>";
|
||||
|
@ -348,6 +364,7 @@
|
|||
outstr += "Ein "+ this.info.race + "<br>";
|
||||
outstr += "Greift derzeit durch " + this.att + " mit einer Stärke von "
|
||||
+ this.battle[this.att] + " an.<br>";
|
||||
outstr += "Ist "+this.calc_dist()+"m von der alten Position entfernt (max ??)<br>";
|
||||
outstr += "Verteidigungsstärke: " + this.battle.defense + "<br>";
|
||||
outstr += "Kraftpunkte: " + this.life;
|
||||
outstr += "</p>";
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue