I am working on a "Dice" roll game, a bit about the game mechanics:
Throw the dice (a button is generating a random number <1-6> and place it on a field),
move the player on the grid to his new location. Player2 throw the Dice and moves the player
to his new location. The player who reaches the last grid position wins the game.
What I try to accomplish:
If the player1 location is grid5 and the Dice roll is 5 I want to change the grid6 to grid10 collor to Red,
when the player1 reached his new location grid10 the grid6 to grid10 will change color back to Yellow.
(player1 is a button which checks intersection with button grid1 to grid 30) - i accomplished this with this:
Code: Select all
on pIntGrid --playerIntersectGrid
repeat with x=1 to 30
if intersect (button "player1", button ("grid"&x), "pixels") then
set the backgroundColor of button ("grid"&x) to "Red"
else
set the backgroundColor of button ("grid"&x) to "Yellow"
end if
end repeat
end pIntGrid
I try to put into a "global" variable the current location of player1
(sort of say: hey I am player1 and my current location is grid5).
Here is what I have for that:
Code: Select all
on player1Loc
repeat with x=1 to 30
if intersect (button "player1", button ("grid"&x), "pixels") then
do ("put true into" && (player1LocG&x))
end if
end repeat
end player1Loc
A "box" where I put something (tru/false, numbers, text)
So now I can say:
if the "box" contains player1 location and the "Dice" roll = 5
set the color for grid(player1 location + 5) to color "Red"
Any guidance/help is welcomed.
Thanks,
Catalin