GameMaker: Studio

GameMaker: Studio

View Stats:
Alarms in for / while loops?
Hey,
i basicely just want to accelerate an object using a "for" loop.
Eatch time time till x <= 100, i want x to be increased by 1.
I want the acceleration to be the sqrt of x.

var x; for (x = 0; x <= 100; x+=1){ global.accs = sqrt(x); }

but now i want to have a delay ("alarm") in the loop,
before the code gets executed again, so that there is a 1 second pause.

neither

var x; for (x = 0; x <= 100; x+=1){ global.accs = sqrt(x); alaram[0] = 1*room_speed; }

or

var x; for (x = 0; x <= 100; x+=1){ if (alarm[0] == -1) { alarm[0] = 1 * room_speed; } global.accs = sqrt(x); }

worked for me.
It would be awesome if one of you could help me ouit with this!☺
< >
Showing 1-2 of 2 comments
MrDave Dec 2, 2017 @ 2:41pm 
You just need to put it in the alarm event
Create code:
alarm[0] = 1 * room_speed count = 100
Alarm 0 event:
count -- If (count > 0) { alarm[0] = 1 * room_speed } global.accs = sqrt(x);
Der Einverleiber Dec 2, 2017 @ 3:10pm 
Originally posted by MrDave:
You just need to put it in the alarm event
Create code:
alarm[0] = 1 * room_speed count = 100
Alarm 0 event:
count -- If (count > 0) { alarm[0] = 1 * room_speed } global.accs = sqrt(x);

thank you
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: Dec 2, 2017 @ 12:54pm
Posts: 2