View Full Version : Help with board game
aquataze
05-27-2006, 02:20 PM
I need help with a board game si when I get question 1 right i will move 2 spaces if i get the question i move back 1 space.
Hi aquataze,
I have attached an example that shows 15 squares. On Preload the object names of the squares (disabled buttons in my example) are indexed in a table so they can more easily be looked-up later.
When the "Roll Dice" button is clicked, the script on the button does the following:
1) Generates a random number between 1 and 12
2) Displays the number
3) Finds the target square by looking it up in a numerically index table
4) Finds the coordinates of that square
5) Moves the "chip" to the appropriate square
There are a couple of checks added to ensure that the chip cannot be moved past the end square (that would produce an error).
This example could probably use some optimization but its a start.
One more thing to note: I cheezed out on the rolling of the dice. That button produces a staight random 1 - 12, not a statistically correct result.
Intrigued
05-28-2006, 09:17 PM
One more thing to note: I cheezed out on the rolling of the dice. That button produces a staight random 1 - 12, not a statistically correct result.
Sounds like it would be time for:
Math.RandomSeed()
aquataze
05-28-2006, 10:08 PM
Thank You both for the Help!
Intrigued
05-28-2006, 11:11 PM
TJS... 99%, Intrigued .9 and .1 percent +/- for error
:D
I played around the the previously posted example and added a few things:
1) Rolling the dice produces a realistic result
2) Added motion so that the game chip "steps" from square to square
3) Roll button gets disabled while chip is in motion
4) Added comments throughout the script
I don't know if this will help but it was fun for me. Most of the script should be easy to adjust to support things like backward motion. I image you could make Global Functions out of most of it for reuse across pages (if you game has different levels for example).
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.