
-----------------------------------
Master
Sat May 22, 2004 11:01 pm

For loops in applets
-----------------------------------
i have a program - type of asteroids game - in which you can shoot the asteroids. If everytime i press "shoot" i get the number of shots to appear on the screen, but everytime i have to use: 

g2.fill(shot[a])

instead i want to use a for loop so i can have it draw the amount that was pressed:

for (int i =0; i >= shotPressedl; i++)
{
      g2.fill(shot[i]
}

what i have is:
g2.fill(shot[a]) 
g2.fill(shot[b])
g2.fill(shot[c])... and for ever

what happens is that my program wont recognize my for loop or it just wont execute for some reason. Is there a restriction that i cannot use loops in a paint method of an applet?

-----------------------------------
Dan
Sat May 22, 2004 11:47 pm


-----------------------------------
try making i >= shotPressedl in to i = shotPressedl in to i = shotPressed; i++)
{
	g2.fill(fire1[i - 1]);
}

for some reason this for loop doesnt seem to be even executing. Could someone please help me
thanks

-----------------------------------
Tony
Sun May 23, 2004 11:15 pm


-----------------------------------

i understand, but this statement is always true and it will never run

*smack*
now that I got your attention... you do realize that the loop is executed while the statement is true, right?

-----------------------------------
Master
Mon May 24, 2004 10:23 pm


-----------------------------------
for (int i = 0; i >= shotPressed; i++) 
{ 
   g2.fill(fire1[i - 1]); 
}

even if this loop executes, it will not follow my instructions... it will not fill the object. Do you know what is wrong. IT FEELS LIKE THE LOOP DOESNT EXECUTE EVEN THOUGH IT MAYBE EXECUTING. I want the loop to execute and run properly atleast once, because when i tell it to run, it just wont work.

-----------------------------------
Tony
Mon May 24, 2004 11:33 pm


-----------------------------------
do you know how to read? :think: no?

for (int i = 0; i 