# How to fly enemies like galaxian game enemies?

I am developing game like galaxian and using cocos2d with box2d .I don't have idea how to create enemies like galaxian game enemies and how do they fly over the screen. http://www.youtube.com/watch?v=BmrCd5tPqpo&feature=related

Could you please help me how to do this ?

I have created the enemies but when i look at the game enemies fly how they are flying ?

-
What movement are you trying to recreate? What have you tried? – Ricket Oct 7 '12 at 7:17
I have created the enemies but when i look at the game enemies fly how they are flying ? – jubin Oct 7 '12 at 7:40
@jubin their X and Y coordinates change. – Markus von Broady Oct 7 '12 at 7:44
To make them fly curves take a loot at Bézier curves: en.wikipedia.org/wiki/B%C3%A9zier_curve – bryan226 Oct 7 '12 at 10:22
@jubin "How do I make them fly?" is really vague and broad - you just change their positions, after all! If you're asking for a specific way to make them fly, like the ones that fly in a curve, you should specify that. – doppelgreener Oct 7 '12 at 17:01

Initialise and assign a movement function to each enemy as a function of time for e.g.

``````x(t) = 5 * sin(t)
y(t) = t * 0.2

final position = Point(x(t), y(t))
``````

when they start flying, plug in the game elasped time since start of flight into x(t) and y(t) to give you the new X and Y coordinate of the enemy.

A boss movement function could be e.g.

``````x(t) = 10 * sin(0.2 * t)
y(t) = cos(0.2 * t)
``````

NOTE: depending on the coordinate system of your game, you may need negative functions.

-