I am working on a project for my school and I have created a game where the player moves around the screen avoiding the enemies. I need to make a timer that counts up to see how long the player successfully avoids the enemies. I have no idea how to do this not even my teacher knows. I also then need a way to put the times as a high score the longer you last the better please help ASAP.
adding a timer
Started by kkills, Apr 17 2012 12:47 PM
2 replies to this topic
#1
Posted 17 April 2012 - 12:47 PM
#2
Posted 17 April 2012 - 02:37 PM
I'm assuming here that you use Drag & Drop.
Make an object have a variable called 'count'. Set it to 0 in the Create event of the object, or whenever game starts and the player has to avoid the enemies. Then make 'count' increase by 1 every step. In the step event, set 'count' relative to 1.
If you want to draw the count, you can use the Draw Variable action. If you want to display the time as seconds, use this line: floor(count/room_speed) as the variable in Draw Variable.
When the player hits an enemy and you want to display the high score table, set score to 'count' before showing the high score. Or to floor(count/room_speed) if you want the score to be the number of seconds the player lasted.
count/room_speed = the exact number of seconds, with decimals, that have passed since count was set to 0. floor() rounds the the value down to the nearest integer.
Make an object have a variable called 'count'. Set it to 0 in the Create event of the object, or whenever game starts and the player has to avoid the enemies. Then make 'count' increase by 1 every step. In the step event, set 'count' relative to 1.
If you want to draw the count, you can use the Draw Variable action. If you want to display the time as seconds, use this line: floor(count/room_speed) as the variable in Draw Variable.
When the player hits an enemy and you want to display the high score table, set score to 'count' before showing the high score. Or to floor(count/room_speed) if you want the score to be the number of seconds the player lasted.
count/room_speed = the exact number of seconds, with decimals, that have passed since count was set to 0. floor() rounds the the value down to the nearest integer.
#3
Posted 24 April 2012 - 11:03 AM
.
Edited by peco, 26 April 2012 - 02:17 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











