Skip to main content
gamedev.net
🔒 Locked

Alien attack patterns

Started by Indy 6 replies 200+ views
Original Post
Indy
Indy
I need help with scripting alien attack patterns. How do I store in an array the x,y positions of aliens. I known the obvious solution is to store the screen co-ordinates in the array, and then just access those sequentially. Any help will be much appreciated. Infact, all thoses that can help me with this will have their name added to the credits of the game (I promise) and a copy. Awaiting your thoughts..... Indy
Indy
Buster
Buster
Do you want simple patterns, in which the alien does the exact same thing with every dive (Galaga, etc)? Or do you want some easy-type of AI so the alien does almost the same thing, but a little different each time?

If you want patterns which are the same every time, create some type of waypoint list. Go to point 1, point 2, point 3, etc... Of course, make this relative to the alien''s position so they can start from anywhere on the screen. Something like this:


int wayPoints(10)(2) = {
0,20, // move down 20
20,0, // then move right 20
0,20 // then move down 20
-20,0, // now move left 20
-999,-999, // this could mean repeat the loop or something
...};


Did that make sense?
Indy
Indy
Yeah...I think you''re thinking exactly what I''m thinking. But the problem is when I access the array, how do I split the values.i.e 0,20 - I need the 20 in say the xpos and 0 in the ypos.


Indy
Darkor
Darkor
You access them like this:

int wayPoints[10][2];
int x, y;

x = wayPoints[0][0];
y = wayPoints[0][1];

or maybe in a loop:

int wayPoints[10][2];
int wx, wy;
int moveTo[2];

for (int r=0; r<10; r++)
{
for (int c=0; c<2; c++)
{
moveTo [c] = wayPoints [r][c];
//this reads the value until the end of the array
}
//after one inside loop
//move the creature
}
//Of coures you'd have to implement this in the main game loop
//and wait for the alien to reach each point first


Hope this helps and how did the anonymous poster get do the source thingie?

PS: Does my name go into the credits?
email me jaryl@catcha.com

Edited by - Darkor on June 17, 2000 4:23:08 AM
Muzzafarath
Muzzafarath
>> Hope this helps and how did the anonymous poster get do the source thingie? <<

He/she put all the source withing [ source] [ /source] tages (without spaces).

    
int void double struct typedef


/. Muzzafarath
Mad House Software
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Darkor
Darkor
Oh thanks

//hi

Indy, so how's the alien attack patterns going?

Edited by - Darkor on June 22, 2000 10:33:33 AM
Darkor
Darkor
Hey hey,
Indy u avoiding me?
Why don''t you answer?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.