Archived

This topic is now archived and is closed to further replies.

tryforfulluse

galaga AI! spooty

Recommended Posts

no matter what i do i cant get this games ai to work. ive tried so many different ways, all i want is for the enemies to go left to right. i can get them to go in a circle, but not left to right. please someone help me. my email/ ip add. is trynotforfulluse@msn.com i have 4funcs for the enemies init,move,delete,draw(). in the move_enemie() func. i have the enemies AI. the newest method i just tried to get the enemies moving was just an idea so it may not be the best. please someone help heres the code for init and move functions. just so you know i have 2 rows of enemie1''s with 8 on each row. void Init_Enemies(void) { // intiate and load all enemies /*FIRST ROW OF ENEMIE1*/ for (int index=0; indexenemie1[14].x) { enemie1[index].x--; } if (enemie1[0].x == 150) { enemie_mode = EN_RIGHT; } } // end for index } break; case EN_RIGHT: { for (int index2=0; index2

Share this post


Link to post
Share on other sites
Well if Galaga is the game I''m thinking about (the one you play while Tekken loads) then there is no AI. The enemies just follow a set pattern round the screen. Just define a pattern using a series of offsets (you can do this in an array), then have the enemies follow this.

Share this post


Link to post
Share on other sites
Hi there!!

The following code is from my game that had aliens going left, right and down..

/***********************************************************
FUNCTION : MoveDrawAliens(void)
DESCRIPTION : Update and draw alien ships
VERSION : 0.11
DATE : 20/8/99
AUTHOR : I. Singh
**********************************************************/
void MoveDrawAliens(void)
{
int index;
int transfer;
if(DirectionChange) // aliens to change direction
{
RowDir=AlienVelocity; // update alien velocity
}
else if(!DirectionChange) // aliens not to change
{
RowDir=-AlienVelocity;
}
for(index=0;index {
if(Alien[index].state) // process only if alive
{
Alien[index].x+=RowDir; // update position of each alien
if(Alien[index].x<10 && RowDir==-AlienVelocity)
{
DirectionChange=TRUE;
DropAliens();
}
else if(Alien[index].x>460 && RowDir==AlienVelocity)
{
DirectionChange=FALSE;
DropAliens();
}
Set_Pos_BOB(&Alien[index],Alien[index].x,Alien[index].y);
Draw_BOB(&Alien[index],lpddsback);//draw the bitmap
int inf=rand()%MaxMissile; // decision to fire by aliens is randomly selected
if(inf==5 && Alien[index].misspermit && !Alien[index].missile)
{
int misspeed=rand()%10; // as is their missile speed
Alien[index].xv=Alien[index].x+15;
Alien[index].yv=Alien[index].y+25;
Alien[index].missile=TRUE;
if(misspeed==3 || misspeed==5 || misspeed==8)
{
Alien[index].missvel=LOne;
}
else
{
Alien[index].missvel=3;
}
}
if(HeroAlreadyFired) // check whether the alien has been hit by hero''s missile
{
if(Collision(Alien[index].x,Alien[index].y,40,40,HeroMissile.x,HeroMissile.y,8,14))
{
HeroAlreadyFired=FALSE; // player loses his missile of-course
Alien[index].shield-=1;
Set_Pos_BOB(&AlienMask,Alien[index].x,Alien[index].y);
Draw_BOB(&AlienMask,lpddsprimary);//draw the bitmap
Play_Sound(hit_id);
if(Alien[index].shield<=0)
{
DropEnergyHeart(Alien[index].x); // give the player chance to revive
Alien[index].state=BOB_STATE_DEAD; // alien is DEAD
Play_Sound(explode_id);
transfer=index-7; // permit the alien above to fire
if(transfer>=0) // but make sure there is an alien above the dead one
{
Alien[transfer].misspermit=TRUE;
Alien[transfer].missile=FALSE;
}
InitAlienExplosion(Alien[index].x,Alien[index].y); // begin explosion
PlayerScore+=10; // increment player score
DeadAliens++; // another one bites the dust
break; // no need to check anymore aliens
} // end if alien shirld
} // end if collision
} // end if hero already fired
} // end if alien alive
} // end if maxaliens loop
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
thankyou so much. ill take some time later to go through all that and make sure i understand it. heh, thanks man

Share this post


Link to post
Share on other sites