I'm making a Time Pilot / Bosconian type of game: it's a kind of space shooter where your guy sits immobile in the center of the screen and rotates, while all the stars move around him, giving the impression that he's flying through space.
Anyhow, the problem is this.
To my surprise (I'm new at this), I successfully designed the engine that rotates the ship and moves the stars and everything.
The problem I'm having is this: my enemies are dead, boring lumps of nothing.
I have no idea how to code the enemies in this situation, to fly about the player's ship.
I can either
a) get them to sit there
b) get them to fly down the screen, without paying attention to the player, or
c) make a dead beeline for the player
None of which will do.
Does anybody know how I can code it so that the enemy ships kind of circle about the player menacingly without making a direct kamikaze run for him?
If you want your enemies to move in set locations, you can make them collide with (invisible) detectors - and on collision telling the ships where to go and how fast. Course, you want to ensure that your ships' direction is always facing that of your position.
You could also set x and y to variables, and +1 and -1 from each every however many seconds.. Or I suppose you could even give them 'ball movement' and make them bounce randomly off of the edges of the screen!
I think ball movement would be rather cool Though I'm not sure if you can fire at a player with that?! You should be able to though - I've just never tried. Using the ball movement, the ships can go at various speeds and bounce of various places and random vertices, and you could tweak the movement in places so they look like they are randomly flying around your perimeter rather than bouncing off of the edge of the screen
That'd be my plan until someone comes up with something less retarded-sounding anyway. Boomerang style would be funny Hope that helps..
A simple way to make them circle around you is to give them a ball movement, and then do this:
* Always
- Enemy: Look in direction of "Player"
- Enemy: Set direction to dir("Enemy") - 8
If you do dir("Enemy") - 7 they'll slowly spiral inwards, towards the player. Dir("Enemy") - 9 will make them spiral outwards, away from the player. Then just go from there, play around with it.
You can always have many different kinds of enemies, with different movement and attack patterns. For instance, you could have one enemy that circles around the player for a few seconds, shoots stuff and then leaves, or an enemy that just flies kamikaze straight into the player, or an enemy that just flies by randomly (Enemy: Set direction to dir("enemy") + Random(3) - 1) and shoots stuff.