A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

Probably not gonna get much here....

1.1k views · started by gotxbrain ·
#1
Probably not gonna get much here....
but it's worth a try. I'm working on something, a project in school. Anyone heard of Game Maker? It has its own programming language and I need help, I can't make it do what I want it to do...

What I'm trying to do is set a variable to a random number, and then test that number and if it equals a certain thing, have it go to a different room.

round(random(2)) Will generate a random number, I'm not sure how to assign it to a variable

room_goto(mg_00x) Will go to the room i specify. God this'd be so much more easier if they just put in a function for go to random room...
#2
Minora wrote:
but it's worth a try. I'm working on something, a project in school. Anyone heard of Game Maker? It has its own programming language and I need help, I can't make it do what I want it to do...

What I'm trying to do is set a variable to a random number, and then test that number and if it equals a certain thing, have it go to a different room.

round(random(2)) Will generate a random number, I'm not sure how to assign it to a variable

room_goto(mg_00x) Will go to the room i specify. God this'd be so much more easier if they just put in a function for go to random room...


Is game maker by yo yo games?
YoYo Games | Game Maker
#3
Heh. I haven't seen Game Maker in ages. I can't imagine how much it's changed over the years.

Generally, to assign a variable, you do:
variable_name = value
So
random_number = round(random(2))

Not sure if this is how Game Maker does it specifically, but there you go.
Also, you don't have to assign it to a variable if it's used only once.

if (round(random(2)) == 1) { /* do random action */ }

This isn't Game Maker code specifically, I don't think, but it's how most programming languages go about doing such things, so it will be silly is Game Maker strayed too far from these codes.
#4
GAMEchief wrote:
Heh. I haven't seen Game Maker in ages. I can't imagine how much it's changed over the years.

Generally, to assign a variable, you do:
variable_name = value
So
random_number = round(random(2))

Not sure if this is how Game Maker does it specifically, but there you go.
Also, you don't have to assign it to a variable if it's used only once.

if (round(random(2)) == 1) { /* do random action */ }

This isn't Game Maker code specifically, I don't think, but it's how most programming languages go about doing such things, so it will be silly is Game Maker strayed too far from these codes.


Thanks you helped a bit. Set variable room_number to random number, then called a test on that variable and if results are true, go to that room. Thanks!
#5
Yeah, as proper coding technique always verify that the "room" in question exists and that it is possible to load it at that state in time.

More beginner game creators forget this step and end in some major glitches, not saying that you do not know what you're doing just trying to give a word of wisdom :P

It is always important to make sure data is set before attempting to use it.

You do not want any pesky memory leaks :P