enemy movement

Started by
5 comments, last by djsteffey 23 years, 10 months ago
Allright..... anyone played Galaga ? I figure so because.....well just because. I guess this question is the same for all space shoot-em-ups though.......alright, you have your little critters that you are trying to shoot at right........one way to do their AI would be to set waypoints or give them random directions with random speeds.......this is conerning the waypoint method.... Say I want it to go in a circle......I could set ALOT of waypoints to make it look like a circle but will still consist of going in very small straight lines to form a circle.......kinda like an octagon.....but alot more side and points....... is there a way to make them move in a circle better then this......I am somehow seeing visions of sin and cos in my mind but cant really figure out how to implement it......any idea please ? "Now go away or I shall taunt you a second time" - Monty Python and the Holy Grail themGames Productions
Advertisement
a bit less points, a bit more structure...
and we all would be able to understand what you''re actually going to tell us about
for enemy movement in a galaga type of game, well, i think they had some standard-movement-scripts, which were played randomly or just one after the other... very easy, but foreseeable...
for this circular movement, think you''re on the right way, but maybe you should have the sin/cos thingies preprocessed, too time-intensive to do realtime. just take the coord points and the movement vecs you have and interpolate with the preprocessed values

hope it helps

pi~
Jan PieczkowskiBrainwave Studios
Ncsu,

Well, basically of you use a standard algorithm to get close to a circle you could mimic one very well if you use 36 waypoints.
That should give a very close comparison to a circle.

You might want to go for a real circle and then you''ll need the parametric equation of a circle which is :

x = r * cos u
y = r * sin u

with x and y your coordinates,
r your radius,
u your parameter which should go from 0 to 2*pi representing the angle.

Hope that helps!

******************************
Stefan Baert

On the day we create intelligence and consciousness, mankind becomes God.
On the day we create intelligence and consciousness, mankind becomes obsolete...
******************************
******************************StrategicAllianceOn the day we create intelligence and consciousness, mankind becomes God.On the day we create intelligence and consciousness, mankind becomes obsolete...******************************
If you had a quick way to calculate beizer curves, all you need
is two points and the info that defined the path between them and
you could create a bunch of crazy patterns.

Have I done this? Nope. The though just came to mind. Anyone
have an opinion on this idea?


Wayfarer
In my opinion Béziercurves are too complicated to use for defining a circle. Keep in mind that polynomal Bézier curves can never define a circle, you need rational Bézier curves for that, and that is just too much math to implement for a circle.

Circles are a basic form like lines. They occur in many places in your program so they should be calculated and drawn as fast as possible. The best way to do it are either waypoints or if you insist the parametric equation for absolute accuracy.

******************************
Stefan Baert

On the day we create intelligence and consciousness, mankind becomes God.
On the day we create intelligence and consciousness, mankind becomes obsolete...
******************************
******************************StrategicAllianceOn the day we create intelligence and consciousness, mankind becomes God.On the day we create intelligence and consciousness, mankind becomes obsolete...******************************
If you just want to "draw" circles or ellipses, you can use Bresenham algorithm (approx. spelling). It is simple to code and it is very fast.

Be reading you,
David
Ok, maybe beizer curves aren''t that hot, but what about those polar equations
from your calculus days? You know, the ones that crisscross like a figure
eight and other shapes? Something could probably be done with them if you
wanted to calculate your waypoints on the fly.

On the circle patterns, you could probably pick like 30-40 points on
an unit circle and save them in a floating point lookup table. What you
can do then is expand that unit circle to any radius-sized circle pattern
you wanted by simply multiplying them by the radius.


Wayfarer

This topic is closed to new replies.

Advertisement