🎉 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!

unanswered question

Started by
1 comment, last by JM 24 years, 5 months ago
Hey guys I''ve posted this question in several boards to see if I ca get a answer but either nobody knows how to do it or I''m not explainig myself very well but here it goes nothing: I''m trying to do a kind of Invaders clone and I want to draw each alien one next to the other, and it seems that I don''t know how to do it(I used nested for)it only display one alien, the thing that I want to achieve is draw two lines and 5 or 6 columns of aliens, like this: ***** ***** /\ the arterisk in the top are the alien and the two slashes are the hero ship. if anyone can help, thanks in advance.
Yo soy yo!!!!!!
Advertisement
Hey. Space Invaders is the first (and last) game I did. To do the enemy drawing, you should be able to just have something like this:
for(int i = 0; i < ENEMY_NUM_ROWS; i++) for(int j = 0; j < ENEMY_NUM_COLS; j++)   DrawSprite(enemies(i)(j));     

*I used the () instead of brackets in the array because the brackets were messing up with the bulliten board, but you should of course have brackets*

This is assuming that the coordinates are included in the enemy struct. If not, then you need to add coordinates to the loop, something like this:

for(int i = 0, int y = ENEMY_START_Y; i < ENEMY_NUM_ROWS; i++, y += ENEMY_HEIGHT + ENEMY_Y_OFFSET) for(int j = 0, int x = ENEMY_START_X; j < ENEMY_NUM_COLS; j++, x += ENEMY_WIDTH + ENEMY_X_OFFSET)   DrawSprite(enemies(i)(j),x,y); 


Or, of course, if you are doing the enemy array in x,y format instead of row,col then you could change the loop a little bit. If you want the source code for my Space Invaders game (with the working enemy code ) go here:
http://www.crosswinds.net/~uselessknowledge
and click on Invasion in the top frame. You can download the game and source and everything there. I hope I could be of help. I hope this was clear...

Edited by - Qoy on 1/12/00 12:45:41 AM
GREAT GREAT GREAT GREAT THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS

OH BTW THANKS

_José
Yo soy yo!!!!!!

This topic is closed to new replies.

Advertisement