I'm making a game program in Alice where objects are constantly moving towards another object. For example a car is constantly chasing another car. What i need help with is how to pause the game. Like when i press a certain button, "p" for example, everything stops. Like all objects stop moving. Please help me. If you could build this for me that would be great, a visual would be nice too.I need help with the programming tool Alice?
In Alice, you could create a new variable (we'll use "pause"). Make a new event for the key press "p". Remember the events are in the top right corner. Make it so when you press p on the keyboard, it changes pause to 1, if it is 0, or change to 0, if it is 1. That way you have a nice variable that toggles between 0 and 1 when you press "p". Now go to your code and write something to the effect of:
if pause = 0 then
(objects move towards each other)
else
(Do nothing, objects dont move or do anything, simulating the effect of a paused game.)
end if
There is also a pause button at the top of the Alice window when your program is running.
No comments:
Post a Comment