Windows How can We Make a Random Value & Change It every 40 Seconds ?

D

Dark Unicorn Gamer

Guest
As The Title Says...
How can We Make a Random Value & Change It every 40 Seconds ?
for example
i = random(10);

and changing value of i every 40 seconds(unlimited times)?
 

Mornedil

Member
Easiest way is to use an alarm:
Code:
i = random(10);
alarm[0] = room_speed*40;
if you put that code in both the create event and the alarm0 event, the variable will update every 40 seconds.
 
D

Dudeidu

Guest
1. use an alarm:
Code:
//call this code only once:
alarm[0] = room_speed * 40;

//then in "alarm 0" event:
i = random(10);
alarm[0] = room_speed * 40;
this will start counting down 40 seconds, then randomize the number and call the alarm again, making it repeat all the time.

2. use a variable that represents a timer:
Code:
//in the create event:
myTimer = 0;
//call this only once:
myTimer = room_speed*40;

//in the step event:
if (myTimer > 0 ) myTimer--;
else{
    i = random(10);
    myTimer = room_speed * 40;
}
 

jazzzar

Member
Hey, cool you got it solved, i don't want to be harsh or something, but this was too simple to even ask about, whatever you're doing now isn't going to benefit you, not knowing about alarms and how they work is too bad, didn't you read any tutorials or something before attempting to make a thing? You're not going to learn that way, believe me i'm talking for your own improvement, hope you'll do yourself a good thing and practice tutorials and stuff, good luck!
 

Mornedil

Member
Eh, it's easy for us to forget what it's like to be new to GameMaker. I'd say there's no harm in asking on a help forum, that's what it's here for.
 
Last edited:

jazzzar

Member
Eh, it's easy for us to forget what it's like to be new to GameMaker. I'd say there's no harm in asking on a help forum, that's what it's here for.
No. I'd say it's not okay to make the game for him right? Alarms are too basic and every beginner should read everything about the engine before asking simple and obvious stuff right?
 
C

CedSharp

Guest
I agree with @jazzzar the forum should not contain questions that are answered in the tutorials provided with GameMaker. Starting right now at this moment i will give the name of the official yoyogames turorial
when questions like this one are asked as to let beginners learn GameMaker in what I consider being the right way :)
 
Top