• Advertisement

Archived

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

Guest Anonymous Poster

Alien Waves

This topic is 6790 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
Hi Indy !

If I understood you right, you want them to show a predetermined behaviour , they should follow a simple "program". You could give a virtual CPU to every alien , that would be a data structure containing :
- An array of commands with arguments
for example : Move Left, Move LeftAndUp,
Fire ( maybe some commands won't need an
argument ! )
!! Jumpto- and If- Commands !!

- An integer pointing to the current Command

- Some variables , for example counters, "constants" ( Radius and Position of the circle ! )...


For each alien in a frame, you look up the current command and its argument, perform the corresponding action and increase the command-counter by one (or set it to a jump-adress). You could le it do one command per frame, 200 or some until a Move- or Fire-Command is reached. Sounds weird but is relatively easy.
The result is something like assembler; if you use the same Program for many aliens, of course all of them will show the same behaviour. if they come in one by another, they should march nicely in a line or whatever you can code.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hi Gecko

Hey !! thanks for the tips.

I think I know what you mean. I have been working on a method. I'm storing alien path patterns in arrays and calling in each alien after a number of iteration. Each alien has been defined as a individual alien. i.e has it's own structure.

Example:

int DirX[]={1,1,1,1,1,1,1,1}; // xpos
int DirY[]={1,2,3,4,5,6,7,8}; // ypos

then using a counter

int alienQue=0; // alien que

I'm updating this every...say 2 iterations

alienQue+=0.5 // update alien number

then when this reaches '1' , it send in the next alien.

Do you think this is a efficient method? It's the only one I can come up with.

BTW, any advice on scrolling? still stuck with that.

Thanks

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi Indy !

Well, it's not exactly what I meant, I thought of a more general approach, but your solution seems to be very efficient for the task you need to do.Don't forget about the "Command Counter" for each alien, so it knows wich values in the Arrays to use, and this should work fine. ( What I had in mind would be much harder to code )

About Scrolling : You could store the background graphics in an array with the height of the screen, but the length of the entire level/world/stage/whatever ( I will assume you scroll from left to right at a resolution of 640*...).
In iteration 1, you put columns 1 to 640 to the screen. In interation 2, you display columns 2 to 641, and so on. Maybe like this:

xg = where_to_start
for (x=0;x<640;x++,xg++)
{ if (xg>length_of_background)
xg -= length_of_background;
/* Place here something that places
column xg of the background to column x on the screen or graphic buffer */
}
where_to_start++;

this should work, but there may be a faster way.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi ALL

Need some help. I'm programming a game similar to "XENON2 ".
What I want to know is
1) How to create "waves" of aliens that swoop down, go in circles, shoot, and dissappear?

2. How and What is the best method of scrolling a background(parrallex)?

All help will be appreciated

Thankyou

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
and for parallax scrolling : use one scrolling routine for each scrolling part, but replace the last line with something like:

where_to_start += scrolling_speed

Share this post


Link to post
Share on other sites

  • Advertisement