# Score over time

I have the following code for adding 1 to global.score in the step event:

global.score +=1;


The problem is this adds the score at an alarmingly fast rate, I want to slow this down so I can give a semi realistic score that is going to represent distance. I am making an endless runner. I have tried to slow the room down but it just messes everything up. I tried to create an alarm event but to no avail.

using

alarm[0] = 10;


But I'm not 100% sure how to use the alarm properly. How would I go about slowing down how much global.score takes?

• what about using a timer? – realUser404 Dec 20 '16 at 13:23
• how do i use a timer? and how would i use it in this context? im struggling to figure a way out. – Ryan white Dec 20 '16 at 13:25
• I believe a timer is about the same thing as what you called an "alarm event". You can look for "how to timer gamemaker". – realUser404 Dec 20 '16 at 13:43
• How about you use real numbers instead? – Vaillancourt Dec 20 '16 at 13:59
• I don't know game maker at all, but why don't you add the actual distance travelled? – Vaillancourt Dec 20 '16 at 15:34

You can do this with a timer like this:

In your Create event (or where you want to start your counting):

alarm[0] = 1;


Then in your Alarm 0 event:

global.score +=1;
alarm[0] = 10; // how many gamemaker steps until this alarm get's called again


A step in gamemaker is the same as fps, default is 30 so 1÷30 = 0.033334 seconds.

• ill try this now and post the results. This may actually be what i was after. – Ryan white Dec 21 '16 at 9:47
• I changed alarm[0] = 0; to = 1 otherwise it wont instantiate the alarm, but this does work how i wanted and fits in nicely with my code, thank you. – Ryan white Dec 21 '16 at 9:51
• ups, yeah that's true. fixed my answer – Jeggy Dec 21 '16 at 14:11
• It's better to use the room_speed variable, like alarm[0] = room_speed / 3; – Dmi7ry Dec 22 '16 at 4:38