Game: Algorithm for spawning enermies at game/window egdes
<p>I'm looking for an algorithm for spawning enermies at the egdes for the gameboard/window for an Android game. I'm doing the old SpaceWars/Shooting asteriods with spaceship and i need the asteroids to spawn at random locations outside the gameboard, where after they will move into the gameboard in different directions and speeds.</p>

<p>It's easy to place the asteroids at random locations, but the tuff part (at least for me) is to give them the right move direction based on the random location they are giving.</p>

<p>For example:</p>

<p>Gameboard = 1280 x 720</p>

<p>Asteroid random location = 1100, 0 (x, y)</p>

<p>Right move direction:</p>

<p>asteroid.x &lt; gameboard.x/2 - possible move directions = south and south east</p>

<p>asteroid.x > gameboard.x/2 - posiible move directions = south and south west</p>

<p>Then the asteroid have two possible move directions (that's how i define the gameplan for now): Direct south or south west.</p>

<p>I could do a lot of if statements, but i'm hoping someone can help me with some kind of algorithm for the problem?</p>
