Need some help Please
Hi, Iam making a Space Invaders type game for my first game ever and well I have been wanting to know how I can make the enemies go left to right. I need for this to be a pattern were enemy one goes here and enemy two goes here just like in the space invaders, but I keep getting this probably when I find a way to move them, how do I add all the enemies in and put them in those diffenert positons and move them according to how each indiviual goes. Someone told me to use a class for it, but I don''t see how this works. Thanks to anyone who helps.
Daniel
i don''t know what language you are using, so i''ll try to stay general...
make a class called "AlienClass". it should have members for X and Y coordinates, as well as other stuff (like what graphic to use, etc)...
then either make an array of objects of this class (10 by 4 or whatever), or make a collection of 40 of them...
then, set up each object to have the proper graphic, and assign an X and Y coordinate (so they are spread out in a grid)...
now, when you want them to move "d" pixels to the right, just add "d" to the X member of each objectin your array/collection... to move left, subtract "d" from it... when you want them to drop lower because the hit the edge of the screen, add some number to the Y member of each alien.
that should get you the basics of a grid of aliens moving back and forth, and down...
HTH
--- krez (krezisback@aol.com)
make a class called "AlienClass". it should have members for X and Y coordinates, as well as other stuff (like what graphic to use, etc)...
then either make an array of objects of this class (10 by 4 or whatever), or make a collection of 40 of them...
then, set up each object to have the proper graphic, and assign an X and Y coordinate (so they are spread out in a grid)...
now, when you want them to move "d" pixels to the right, just add "d" to the X member of each objectin your array/collection... to move left, subtract "d" from it... when you want them to drop lower because the hit the edge of the screen, add some number to the Y member of each alien.
that should get you the basics of a grid of aliens moving back and forth, and down...
HTH
--- krez (krezisback@aol.com)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement