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

2016/6/22

Is there a boolean for Greenfoot.stop()?

rebeccarsn rebeccarsn

2016/6/22

#
I'm programming something, where an object should do something until the application has stopped. //if (Greenfoot.stop)<-? { int i=0; move(i); i=i+0.25 } The object should move faster after every run until the application has stopped... help?
danpost danpost

2016/6/22

#
Whatever it is you want to actor to stop doing when the application has stopped will stop automatically when the application is stopped. So, do what you want the actor to do when the application is running:
move(i); // does nothing if 'i' is zero, which is what the last line sets it to
i  = i+0.25; // this will cause an error if 'i' is declared as an 'int' variable
without worrying about what happens when the scenario stops (all scenario actions stop when the scenario is stopped). There is probably an issue with placing 'int i = 0;' before the move statement. With that statement, it is meaningless to move 'i' steps after it because no movement will occur (which will be the case if you did not call 'move' at all there). Another issue is the changing of the value of 'i' on the line after the move line. Since the variable 'i' is declared within the block, it only lasts until the block completes its execution. Also, it is declared to be an int value and you are attempting to add a non-integer value to it which should throw a compilation error. Maybe you should explain what the code is trying to do in general (provide some background as to what object this code is for and what behavior you are wanting it to have in more detail).
rebeccarsn rebeccarsn

2016/6/24

#
I'm working on a space shooter game, where the attackining space ships, who are coming down to the player's ship, are getting faster and faster. So the degree of difficulty increases but not to fast.
danpost danpost

2016/6/24

#
rebeccarsn wrote...
I'm working on a space shooter game, where the attackining space ships, who are coming down to the player's ship, are getting faster and faster. So the degree of difficulty increases but not to fast.
To slow down the speeding up of the space ships, you could do something like this:
move(i/300); // adjust slow down value as needed
i++;
(have the value of 'i' start at the slow down value)
You need to login to post a reply.