Click to See Complete Forum and Search --> : Random numbers.
Yoer88
08-06-2005, 11:56 AM
Hi!
I am making a game in 3DFA.
And I want to work with a dice.
Everything is good and all but I don't exactly know the script for a random number.
I found the functions of Blanius.
This script:
function randomRange(Min,Max){
return random(Max-Min+1)+Min;
}
And how can I get the output into a textbox. What should I insert as the variable?
Can someone help?
Thnx!
Grtz,, Yoer88
blanius
08-06-2005, 03:54 PM
put that function in your starting script.
Then when you want to get a new random number you call the function like this
die1=root.randomRange(1,6)
die1 will now equal a number between 1 and 6 if you have an editbox with the variable die1 it will show you the number
http://bretlanius.com/flash/die.html
Yoer88
08-07-2005, 03:28 AM
Thnx allot!
Another question about it :rolleyes:
My game is becoming a version of a well known game. (don't know how they call it in English).
But what I want is when; die1==1 the position of the player (just a circle with gradient) must go forward one position. And when die1==2 it has to go forward 2 positions etc.
So my questions: How can I set the positions (?? position1=element("player").x.y=145.200 ??).
And how can I make sure he counts the value of die1 to the previous values.
I hope it is clear what I mean and I hope you can help me.
Grtz,, Yoer88
blanius
08-07-2005, 09:11 AM
it depends alot on how you are displaying them, and how you are tracking where they are. I'm guessing that you may need to rethink that part of your game. This is something you needed to plan for when starting the project.
you set the position of an object with myobject.position.x and I think myobject.x works just as well. And substitute y for the x for the other dimension.
You should read up on ARRAYS as I've found that is usually the best way to do this sort of board game thing.
Yoer88
08-07-2005, 12:31 PM
I see. Alright I rethink it then.
But can you tell me anyway how to make something so the value of die1 is added to a total?
blanius
08-07-2005, 03:21 PM
just add it.... total+=die
Yoer88
08-07-2005, 07:48 PM
oOw :cow:
could of thought of that myself of course..
ConnELITE
08-08-2005, 02:19 AM
this is easy you just need to add in some editboxes or something, like in your starting script say
die=whatever the die says (create some scriot within die to make this work)
position=0 (position will be the varible)
position1=number.x and number.y
position2=number.x and number.y
(ect for hom many positions you have)
then say
if [thedierolls]{
position+=die
}
if position=1{
element (player)=position1
}
thered be a lot of scripting but this is what i first thought of, it has soem holes but you could fill em in.
ForumNewbie
08-13-2005, 08:15 AM
Hi,
With regards to random numbers, you'll notice that in the 3DFA viewer, the numbers aren't very random. If you restart the movie, the numbers are the same the second time around.
However, it seems it's OK in the exported movie, so maybe it's not a problem.
Morgan
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.