Advertisement Jump to content


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


Enemies in Java

This topic is 5540 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

Hi im building a game as an after school project and i would like to know how to make enemies apear without end. i have a class that handles how ONE soldier moves and acts, but i wanna do is have 10 enemies on the screen at once. Whenever a soldier gets killed another one is created. I have no clue how to do that. ps: the method that handles the soldiers movment ArmyofOne.drawSoldier(); [edited by - Duekiller on November 16, 2003 8:38:24 PM]

Share this post

Link to post
Share on other sites
Use an array;

Soldier [] soldiers = new Soldier[10];

for (int i=0; i < soldiers.length; i++)
soldiers[i] = new Soldier();

// then to spawn a new one do something like

for (int i=0; i < soldiers.length; i++)
if (soldiers[i].dead) soldiers[i].reset();

[edited by - nonnus29 on November 16, 2003 10:11:06 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!