From 38109227eeb902bdb79b8dde7ff45e3a76dddd7a Mon Sep 17 00:00:00 2001 From: Mikhail Novikov Date: Thu, 15 May 2014 11:28:47 +0300 Subject: [PATCH] Returning to map. --- src/Asteroids.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Asteroids.js b/src/Asteroids.js index dc2f380..b227436 100644 --- a/src/Asteroids.js +++ b/src/Asteroids.js @@ -78,6 +78,20 @@ var Game = React.createClass({ diff ); + var newLatPos = latResult.pos; + + if (newLatPos[0] < 0 - this.props.shipHeight) { + newLatPos[0] = this.props.width; + } else if (newLatPos[0] > this.props.width + this.props.shipHeight) { + newLatPos[0] = this.props.width - newLatPos[0]; + } + + if (newLatPos[1] < 0 - this.props.shipHeight) { + newLatPos[1] = this.props.height; + } else if (newLatPos[1] > this.props.height + this.props.shipHeight) { + newLatPos[1] = this.props.height - newLatPos[1]; + } + var rotResult = Physics.simulateOffset( rotation, this.state.playerRotVel,