Jump to content
  • Advertisement

Archived

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

Duekiller

Enemies in Java

This topic is 5453 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
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!