PDA

View Full Version : Generic Board Game Stumper



dgrhm
October 8th, 2004, 12:59 PM
Hello all,

I read an earlier posting about creating a board game, and that got me wondering about how to do it. I've tinkered with a generic 16 x 16 board, with the outer squares being the coordinates I'd use for navigating a token.

I've come up with the following scripts. Parts are working, others aren't. Any suggestions? It seems pretty long to me. Thanks

//== = = = = = = = = =
//button Script
//= = = = = = = = = = =
on (press) {
_root.dieRoll = int(Math.random()*6+1);
_root.currSq = currSq + dieRoll;
checkSq();
setTokenCoords();
}
//= = = = = = = = = = = = = = = = = = = = =
script in keyframe
//= = = = = = = = = = = = = = = = = = = = =
//set up starting coords
start = (token._x = 50) && (token._y = 50);
if (start) {
currSq = 1;
}
function checkSq() {
if (_root.currSq > 12)
_root.currSq = _root.currSq -12;

}
function setTokenCoords() {
//hopefully, this'll set the token's coords
if (currSq = 1) {
token._x = 50; token._y = 50;
}else if (currSq = 2){
token._x = 150; token._y = 50;
}else if (currSq = 3) {
token._x = 250; token._y = 50;
}else if (currSq = 4) {
token._x = 350; token._y = 50;
}else if (currSq = 5) {
token._x = 350; token._y = 150;
}else if (currSq = 6) {
token._x = 350; token._y = 250;
}else if (currSq = 7) {
token._x = 350; token._y = 350;
}else if (currSq = 8) {
token._x = 250; token._y = 350;
}else if (currSq = 9) {
token._x = 150; token._y = 350;
}else if (currSq = 10) {
token._x = 50; token._y = 350;
}else if (currSq = 11) {
token._x = 50; token._y = 250;
}else if (currSq = 12) {
token._x = 50; token._y = 150;
}

//token coordinates
xPos = token._x;
yPos = token._y;
}

Dr Warm
October 9th, 2004, 10:36 PM
what exactly isn't working (i haven't tried out ur script) just so i know what to look at.
Can u call a function from an different mc? or have u got all the code in the first keyframe.
for the button i think u should have (in the main keyframe):
yourButton.onRelease = function(){//then ur code here};
or if it is calling the functions just forget that

put trace(); things everywhere to see whats happening and whats not

dgrhm
October 14th, 2004, 11:06 AM
Sorry for the delay of this reply. The token just isn't moving. I'd like it to move an appropriate number of squares to match the die roll. If I roll a 4, I'd like the token to move ahead four squares. Now, I tried to take into account that there are only 12 total squares, so I figured I'd include a script to subtract 12 from the currSq#, if the currSq# number was greater than 12.

I'll try the trace(); function. I"ve found it to be useful when I get stuck.

Thanks, Doc.

Dr Warm
October 15th, 2004, 03:04 AM
yeah i sort of get what ur trying to do, not the way i'd do it but still..


//token coordinates
xPos = token._x;
yPos = token._y; what r xPos and yPos, u just decided to throw them in at the end did u?
if u wanted to use them u would have:
if (currSq = 1) {
xPos = 50; yPos = 50;
}
and then at the end:
token._x = xPos;
token._y = yPos;

maybe u should post ur fla, i'll should be able to help u better then