Mathematica Asked on June 19, 2021
I am making a connect four game and I need to figure out which graphic to use (red or black) by how many times the mouse has been clicked. So I need a counter for mouse clicks. That way I can make an If statement: if the counter is odd, use graphic1, if the counter is even use graphic2. This is my code for the graphics then I put them in a list of lists, and make a graphics grid for the game board. Thank you so much!
graphic1 =
DynamicModule[{color = White},
EventHandler[
EventHandler[
Dynamic[Graphics[{EdgeForm[Thick], color,
Disk[{1, 1}, 1]}]], {"MouseDown" :> (color =
color /. {White -> Red})}], {"MouseDown" :> (p =
MousePosition["Graphics"])}, PassEventsDown -> True]];
graphic2 =
DynamicModule[{color = White},
EventHandler[
EventHandler[
Dynamic[Graphics[{EdgeForm[Thick], color,
Disk[{1, 1}, 1]}]], {"MouseDown" :> (color =
color /. {White -> Black})}], {"MouseDown" :> (p =
MousePosition["Graphics"])}, PassEventsDown -> True]];
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP