GAME MAKER: RANDOM GLOBAL VARIABLES
Posts
Pages:
1
Alright, I've been cracking down and working on my RMVX game and I decided to work on a side-project in game maker that is based around variables controlling an empire in space (Simplified of course).
So here is what I need: How to use random variables in game maker in a manner closer to C++ or to how rpg maker calculates them.
So here is what I need: How to use random variables in game maker in a manner closer to C++ or to how rpg maker calculates them.
In GML floor(random(n)) returns an integer between 0 and n-1 inclusive, which is equivalent to rand() % n in C/C++ and rand(n) in ruby (which as I understand is what VX scripting is done in, though I have no personal experience with RM)
but something tells me that doesn't answer all of your question, if not just elaborate
but something tells me that doesn't answer all of your question, if not just elaborate
This will help a bit, but what I need is similar to this code bellow:
{ int Code = randvar //# A stand in for the calling code I use in C++
if (Code=34) { //# Run So and So here}
if (Code=33) { //# Run diferent process}
else
end }
Yes, I know that I am using some strange coding, mainly due to the fact that I have not done much coding with C++ in over a year now. But I wish to simulate this in GML, so I hope that you guys can help me out with this.
{ int Code = randvar //# A stand in for the calling code I use in C++
if (Code=34) { //# Run So and So here}
if (Code=33) { //# Run diferent process}
else
end }
Yes, I know that I am using some strange coding, mainly due to the fact that I have not done much coding with C++ in over a year now. But I wish to simulate this in GML, so I hope that you guys can help me out with this.
Ah, I gotcha. What you want is a switch statement:
http://www.gmlscripts.com/gml/switch_statement
GML uses the same syntax as C/C++ in this case. In fact using a switch in any language to check the value of the same variable multiple times is faster than using a bunch of if statements so you should get into the habit of doing it :D
http://www.gmlscripts.com/gml/switch_statement
GML uses the same syntax as C/C++ in this case. In fact using a switch in any language to check the value of the same variable multiple times is faster than using a bunch of if statements so you should get into the habit of doing it :D
Pages:
1