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

2017/3/24

N Turns

rockon411 rockon411

2017/3/24

#
I have to have my actors do something (throw something, create something) every 40 turns for a code that I am working on, but I am not sure how to make them act every n turns instead of every time. Any information on the subject would be appreciated.
danpost danpost

2017/3/24

#
You just need an int field to count the 'turns':
private int turns = 0;

// then, in act
turns++;
if (turns == 40)
{
    turns = 0;
    // throw whatever here
}
rockon411 rockon411

2017/3/25

#
Thank you so much!
You need to login to post a reply.