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.


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?

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

  • \$\begingroup\$ ill try this now and post the results. This may actually be what i was after. \$\endgroup\$ – Ryan white Dec 21 '16 at 9:47
  • \$\begingroup\$ 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. \$\endgroup\$ – Ryan white Dec 21 '16 at 9:51
  • 1
    \$\begingroup\$ ups, yeah that's true. fixed my answer \$\endgroup\$ – Jeggy Dec 21 '16 at 14:11
  • \$\begingroup\$ It's better to use the room_speed variable, like alarm[0] = room_speed / 3; \$\endgroup\$ – Dmi7ry Dec 22 '16 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.