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;
}