View Full Version: Code problem.

Game Maker > Questions and answers > Code problem.


Title: Code problem.


knight666 - September 20, 2003 10:35 PM (GMT)
I kinda forgot what's the code for a dice again... :blink:

Donovan_dcann - September 20, 2003 11:03 PM (GMT)
CODE
if (ceil(random(2))=true){//your code}

Burning Sheep Productions - September 21, 2003 01:57 AM (GMT)
That's for a 1 in 2 chance though.

Donovan_dcann - September 21, 2003 02:42 AM (GMT)
yes that it is but it can be change

knight666 - September 21, 2003 09:44 AM (GMT)
Yeah, just change random(). :P
ThanX, guys!

Monkster - September 21, 2003 04:35 PM (GMT)
is there any limit to the size of the number u can put in there? or is it infinite?

knight666 - September 21, 2003 05:00 PM (GMT)
I guess.
But it would take a looooooooooong time before the dice lands on 1. :D

Monkster - September 21, 2003 05:29 PM (GMT)
yeah! :lol:

Donovan_dcann - September 22, 2003 03:49 AM (GMT)
well you can try this too I call it a temp variable only for step event
CODE
// set the random number
die = floor(random(30))
//check for a number
if die = 29
{
//do some code like
score+=10;
}

Burning Sheep Productions - September 22, 2003 05:52 AM (GMT)
Why would there be a limit Monkster?

What's the point of making a limit, the number has to be finite.

Monkster - September 22, 2003 10:38 PM (GMT)
theres a limit on the variables in GM...i was wondering if there was some thing like this for this...i guess i was wrong though.

Burning Sheep Productions - September 23, 2003 12:26 PM (GMT)
A limit on variables?

What are you talking about?

knight666 - September 23, 2003 03:02 PM (GMT)
QUOTE (Donovan_dcann @ Sep 22 2003, 04:49 AM)
well you can try this too I call it a temp variable only for step event
CODE
// set the random number
die = floor(random(30))
//check for a number
if die = 29
{
//do some code like
score+=10;
}

Nice piece of code, but... what's your point? :huh:

Donovan_dcann - September 23, 2003 10:26 PM (GMT)
its like a dice but you can pick the number you self

Monkster - September 23, 2003 10:38 PM (GMT)
QUOTE
A limit on variables?

each varible (score, lives, etc.) when used in GM can have a limit of about 2 billion...i'm not sure of the exact value. You can ask Yourself if u want.

The reason is that each variable in GM, is a signed long int...meaning that the values of the variable can be anywhere from -2,147,483,647 to 2,147,483,647
If the variable became 2,147,483,648, however, it would just become negative...

This is why u should be able to chose between signed and unsigned variables...

The reasoning behind this is that, unsigned variables can ONLY BE POSITIVE. Meaning the values in a unsigned variable a be 0 to 4,294,967,295 making is so the score in a game can be larger than b4...

So there IS a limit on variables!

Donovan_dcann - September 23, 2003 10:55 PM (GMT)
I neve think of that ;)

Burning Sheep Productions - September 23, 2003 11:38 PM (GMT)
I never knew about the 2 billion limit.
But what is an unsigned variable?
One you make or one already there?

Monkster - September 24, 2003 12:19 AM (GMT)
u can define the variable in other languages than GM...like C++...but in GM all the variables are signed...but u can't change that.

Unsigned is just a different tye of variable...they both use the same amount of memory, just one is all positive while the other is positive or negative.

Burning Sheep Productions - September 24, 2003 12:44 AM (GMT)
I'm confused to a further extent.

Monkster - September 24, 2003 01:10 AM (GMT)
well, im not the best xplainer...maybe someone else here can do it better...

Burning Sheep Productions - September 24, 2003 02:01 AM (GMT)
You said Yourself knew stuff about it.
So...

Monkster - September 24, 2003 10:24 PM (GMT)
Yeah, i'm sure he can help u out!...or someone who knows C++...

Burning Sheep Productions - September 25, 2003 02:53 AM (GMT)
What's C++ got to do with it?
Isn't GM a Delphi program?

Monkster - September 25, 2003 03:13 AM (GMT)
yes, but GML is quite similar to C++...i think all programming languages have thes different types of variables...im not sure though...

Burning Sheep Productions - September 25, 2003 04:07 AM (GMT)
I shuppose.

knight666 - September 25, 2003 08:20 PM (GMT)
QUOTE (Burning Sheep Productions @ Sep 25 2003, 03:53 AM)
Isn't GM a Delphi program?

I once used Delphi.
Once and never again!
Man, that language sucks!
You need to define every single fucking function!
IT TOOK ME AGES TO LEARN HOW TO USE IT PROPERLY!!! (2 days, actually...)

Monkster - September 25, 2003 10:36 PM (GMT)
QUOTE
You need to define every single fucking function!

Its like that in a lot of languages!

Burning Sheep Productions - September 26, 2003 12:44 AM (GMT)
What's wrong with learning every single *ahem* function?

knight666 - September 26, 2003 07:34 PM (GMT)
Yes, that's what I like about GM: if you don't like the functions, create new ones! :lol:

Tropper - September 27, 2003 12:13 AM (GMT)
QUOTE
IT TOOK ME AGES TO LEARN HOW TO USE IT PROPERLY!!!

Well. I usally takes a while to learn a launge.

knight666 - September 27, 2003 10:38 AM (GMT)
Yeah, I knew that! <_<




Hosted for free by InvisionFree