www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/18/16:24:55

From: ChrHenz <ChrHenz AT aol DOT com>
Message-ID: <75962f0d.35103ad7@aol.com>
Date: Wed, 18 Mar 1998 16:21:21 EST
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Q:Implement of enemy's moves

In einer eMail vom 17.03.98 20:02:03 MEZ, schreiben Sie:

>> Hi,
>hello...
>
>> 	I'm writing a shooting game using DJGPP & Allegro.
>
>where can i go to see it???
> 
>> 	Can someone tell me how to implement the enemy's movement ?
>> 	Just like enemies in "Nemesis", having their own path.
>> 	I've got a demo source code but the enemies only move one 	
>> 	direction (only move down or left).
> 
>i dont understand very well your question... like the enemys moves up or
>left you can do it in every directions...!!! just program that!
> 

I guess the question is how to implement certain movement-patterns...

Just an idea... (i haven't tried it and don't know if it is a reasonable way
to do it)

Perhaps you could create an array of 'modifiers' for the coordinates of your
alien spaceships (or whatever).
(Each array would then define a certain movement-pattern)

int PosModifiers[2][MAX_LENGHT];

Here you could then store values that you would like to add to your X/Y-
Coordinates...

In your loop to update the enemy positions you could then have something like
this:

EnemyShip.X+=PosModifiers[0][EnemyShip.ModifierIndex];
EnemyShip.Y+=PosModifiers[1][EnemyShip.ModifierIndex];

For example, if your ship should move straight down, the array would look
like:
 0/1
 0/1
 0/1 etc...

or straight up:
 0/-1
 0/-1
 0/-1 etc...

Using a method like this you could easily alternate moving speed (still
straight down).
 0/1
 0/2
 0/3 etc for an acceleration...

Any comments ?

Christian.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019