This site requires JavaScript, please enable it in your browser!
Greenfoot back
Daave
Daave wrote ...

2017/10/13

Space Invaders

Daave Daave

2017/10/13

#
Im making a version of space invaders for school and I've got quite far but i'm stuck. I have 3 actors - Enemy1, Enemy2, Enemy3. I have got them to move how i like etc but i need them to shoot. And the only way i can think of them shooting is by making all of the same actor shoot at once but i want it more random. Any way to do this? Thanks
danpost danpost

2017/10/13

#
You should be able to generate a random number, check it for a specific value (or more than one), for the condition of an enemy to shoot. If you can only get all of a type to shoot at once, you may want to post what code you are using so we (hopefully) can tell you where you are going wrong. Also, in any column (vertical line) of enemies, only the bottom-most one should be allowed to shoot, so another condition could be added for that.
Daave Daave

2017/10/27

#
Have you got an example for the second thing you said
Danpost wrote...
Also, in any column (vertical line) of enemies, only the bottom-most one should be allowed to shoot, so another condition could be added for that.
As it would be very helpful!
danpost danpost

2017/10/27

#
I have an uploaded scenario called Space Invaders Movement Demo from which a review of its code might help you. EDIT: I just looked at it again myself. It might not be the best coding for determining if an invader has another below it. I probably decided not to use the 'getObjectsAtOffset' method because one could be found quite a margin below it (with invaders killed off from rows in between) and the way I did it only required one check.
You need to login to post a reply.