scale rendering
This commit is contained in:
parent
80bd84230d
commit
0ceea5f4af
7 changed files with 70 additions and 17 deletions
|
@ -1,8 +1,27 @@
|
|||
var SCALE = 32;
|
||||
|
||||
function World() {
|
||||
this.bodies = {};
|
||||
this.playerShip = false;
|
||||
this.playerShipId = false;
|
||||
|
||||
this.getCenter = function() {
|
||||
if (!this.playerShip) return { x: 0, y: 0 };
|
||||
|
||||
var x = this.playerShip.getPos().x;
|
||||
var y = this.playerShip.getPos().y;
|
||||
var comx = this.playerShip.com.x;
|
||||
var comy = this.playerShip.com.y;
|
||||
var r = this.playerShip.r;
|
||||
var d = Math.sqrt(comx * comx + comy * comy);
|
||||
var a = Math.atan2(comy, comx);
|
||||
|
||||
x += Math.cos(a + r) * d;
|
||||
y += Math.sin(a + r) * d;
|
||||
|
||||
return { x: x, y: y };
|
||||
}
|
||||
|
||||
this.clear = function() {
|
||||
this.bodies = {};
|
||||
this.playerShip = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue