Player can move off screen?
<p>So, I'm creating a simple 2D video game.  I noticed recently that the player can move off the screen, so I added this code:</p>

<pre><code>if (newX &lt;= SIZE * TagsCanvas.SCALE) {
            newX = SIZE * TagsCanvas.SCALE;
        } else if (newX &gt;= TagsCanvas.CANVAS_WIDTH - (SIZE * TagsCanvas.SCALE) - getAABB().getRadX()) {
            newX = TagsCanvas.CANVAS_WIDTH - (SIZE * TagsCanvas.SCALE) - getAABB().getRadX();
        }

        if (newY &lt;= SIZE * TagsCanvas.SCALE) {
            newY = SIZE * TagsCanvas.SCALE;
        } else if (newY &gt;= TagsCanvas.CANVAS_HEIGHT - (SIZE * TagsCanvas.SCALE) - getAABB().getRadY()) {
            newY = TagsCanvas.CANVAS_HEIGHT - (SIZE * TagsCanvas.SCALE) - getAABB().getRadY();
        }
</code></pre>

<p>TagsCanvas.CANVAS_WIDTH is the width of the canvas object. Height is the height of the canvas object.  Size is the size of the player, and scale is the scale of the game (At the moment it's 2).  getAABB().getRadX() returns the radius from the center of the player to the edge (The 'player' is a square box).</p>

<p>Now, the x works fine, but the Y part doesn't.  It'll block the player from moving up off the map (The first statement), but it will let the player go about 20 points too far down.  Any help would be appreciated!</p>
