-2
\$\begingroup\$

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 ?

\$\endgroup\$
5
  • \$\begingroup\$ What movement are you trying to recreate? What have you tried? \$\endgroup\$
    – Ricket
    Commented Oct 7, 2012 at 7:17
  • \$\begingroup\$ I have created the enemies but when i look at the game enemies fly how they are flying ? \$\endgroup\$
    – jubin
    Commented Oct 7, 2012 at 7:40
  • 2
    \$\begingroup\$ @jubin their X and Y coordinates change. \$\endgroup\$ Commented Oct 7, 2012 at 7:44
  • 1
    \$\begingroup\$ To make them fly curves take a loot at Bézier curves: en.wikipedia.org/wiki/B%C3%A9zier_curve \$\endgroup\$
    – bandrewk
    Commented Oct 7, 2012 at 10:22
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Oct 7, 2012 at 17:01

1 Answer 1

3
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .