• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows RNG (Read thread)

A

ArcaPlaysYT

Guest
I understand that there are different RNG tutorials in gms, but I don't know if there is one for what I need. When a sprite is created, it basically generates a random number from 30-70 and then the sprite animation lasts that number of seconds. Any help will be appreciated.
 
D

Deleted member 45063

Guest
Wouldn't something along the lines of
GML:
alarm[0] = irandom_range(30, 70) * room_speed;

// In alarm[0]

image_speed = 0;
do it?

This was typed directly here without testing but irandom_range should return a random number in a specific interval and then you rely on room_speed to turn that value into seconds (with some caveats).
 
A

ArcaPlaysYT

Guest
Wouldn't something along the lines of
GML:
alarm[0] = irandom_range(30, 70) * room_speed;

// In alarm[0]

image_speed = 0;
do it?

This was typed directly here without testing but irandom_range should return a random number in a specific interval and then you rely on room_speed to turn that value into seconds (with some caveats).
how would i make that count down?
 
Last edited by a moderator:
D

Deleted member 45063

Guest
how would i make it do something once it reaches zero?
would using "if alarm[0] = 0" do anything?
You can either add the code you want to execute in the Alarm event directly or if you want to check for it in the Step event then you could check for 0 (although if I remember correctly it might only trigger at -1, can't remember, haven't used Alarm events in a long time), for which that should work (although I would suggest you started using == for comparisons).
 
A

ArcaPlaysYT

Guest
You can either add the code you want to execute in the Alarm event directly or if you want to check for it in the Step event then you could check for 0 (although if I remember correctly it might only trigger at -1, can't remember, haven't used Alarm events in a long time), for which that should work (although I would suggest you started using == for comparisons).
thank you. with some other sources, i was able to make it work first try
 
Top