Game Development Community

Randomizer Behavior...?

by Steven Smith · in Torque Game Builder · 10/18/2008 (11:33 pm) · 2 replies

Is there a randomizer behavior? something that will display a random number or color or player piece...etc.

What i'm trying to do is make a whack a mole type game called "whack a code".
Where I could put in a list of codes into it (using 1 though 40) and give it to the player. then when the player hits the right number that pops up, it would complete the code that's displayed. if the player hits the wrong number a red X would be displayed in that space in the code....i hope that made sense....anyway i'm an artist not a programmer but i'm trying to learn....any help would be great....thanks.

#1
10/19/2008 (12:08 am)
You could probably use the GuiInputCtrl for grabbing key presses.
#2
12/15/2008 (3:11 am)
Hi steven,

i didn't quite understand what exacly you want.
But here's how you could get a random value between two values:
//-----------------------------------------------------------------------------------------------
if (!isObject(RandomizerBehavior))
{
%template = new BehaviorTemplate(RandomizerBehavior);

%template.friendlyName = "Randomizer";
%template.behaviorType = "Game";
%template.description = "Randomizes values";

%template.addBehaviorField(inputfrom, "Input from", int, 1);
%template.addBehaviorField(inputto, "Input to", int, 40);
}

function RandomizerBehavior::onBehaviorAdd(%this)
{
%random_number = getRandom(%this.inputfrom, %this.inputto);

// Now you do what every you want with your %random_numer
}
//-----------------------------------------------------------------------------------------------

- Michael

edit: typos