🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Galaga style AI

Started by
4 comments, last by LokustX 21 years, 6 months ago
I''ve been messing around with creating a galaga style game (with some modifications) for a while. Im having problems with the enemy AI. I want the enemy ships to fly in patterns. I have prerotated graphics for each ship. It''s a 2d top down shooter also. How do i a) Store the patterns and use them? Im guessing just use a state table or something similar. b) Synchronize the pattern movements with the frames so that the ship will always be pointing in the directin its going? Vir prudens non contra ventrum mingit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Vir prudens non contra ventrum mingit.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advertisement
well, this is all off the top of my head, but you could do something like this:

for each "spot" an enemy is supposed to go to, have a little ''script'' file.

an example of what the file would look like:

file: bug_ship1.dat
FlyTo     100, 200  // coordinates to fly toRotateToPlayer      // when it''s flown to the FlyTo coord, rotate toward the playerFireUntil 5000      // fire in the direction rotated until 5000ms (5 seconds) has elapsedFlyTo     300, 200  // fly over someRotateToPlayer      // here we go againFireUntil 5000      // yadda yaddaWait      1000      // wait a second.. give the player a chance to kill itFlyAway   400, 0    // fly away in the direction specified 


you can load something like that into a linked list, and
every frame, check to see if it''s time to go to the next node.
of course, if the enemy actually dies somewhere in there, you''d
just terminate the loop and kill the enemy.

not too complex.. just break it down into steps and everything
becomes alot simpler.

if i need to clarify anything, let me know.. but keep in mind, this
is all off the top of my head.

-eldee
;another space monkey;
[ Forced Evolution Studios ]

::evolve::

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!

-eldee;another space monkey;[ Forced Evolution Studios ]
but what about during the flight to where the ship is going?
how would i incorporate animations while the ship is in motion?
i don''t really have any experience with scripting especially when it comes to ai type problems.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Vir prudens non contra ventrum mingit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Vir prudens non contra ventrum mingit.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You have to seperate your graphics from your AI.
Changing the image of the ship should happen in your move function.
I would guess that the function (if one exists) takes a vector or at least a direction. You can use that to determine which shape the ship takes.

I hope that helps.

Peace Out!
Or if you are using absolute x,y values, simply compare your current value to your previous, derive your direction thru any number of equations, and then que up the appropriately tagged image.
"Let Us Now Try Liberty"-- Frederick Bastiat
I give each ship a set of Beizer curves (usually one is enough for most actions) and have it move along that path for a certain amount of time after it appears on screen. The path also leads it offscreen again. For the animations, I just change them after a certain amount of time has passed.

tj963
tj963

This topic is closed to new replies.

Advertisement