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

2013/12/28

hey

alosh alosh

2013/12/28

#
i have a problem with while-loop , i tried studying from many sources but no result. my problem comes when for example use a while loop to create a 20 fish in the same line with a space between them i have no idea to do that if anyone one could help i will be thankful
erdelf erdelf

2013/12/28

#
a for loop would solve it better i think
for(int x = 20; x<230;x+=10)
{
     addObject(new Fish(), x, 20);
}
if i got it right, it should spawn a new fish every 10nth cell in a while loop it looks like this:
int x = 20;
while(x<230)
{
    addObject(new Fish(), x, 20);
    x+=10;
} 
You need to login to post a reply.