Archived

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

Duekiller

Enemies in Java

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