How to get consolegetkey from 2 users
I am trying to learn F # by creating a game, Tron. So this is a multiplayer game and I need to have a console key for both players. One uses ZQSD, the other uses arrows.
let mutable switchb = new pos(-1, 0)
let mutable switcha = new pos(1, 0)
let key_info = Console.ReadKey().Key
if key_info = ConsoleKey.UpArrow then
switchb.y <- switchb.y - 1
else if key_info = ConsoleKey.DownArrow then
switchb.y <- switchb.y + 1
else if key_info = ConsoleKey.RightArrow then
switchb.x <- switchb.x + 1
else if key_info = ConsoleKey.LeftArrow then
switchb.x <- switchb.x - 1
if key_info = ConsoleKey.Z then
switcha.y <- switcha.y - 1
else if key_info = ConsoleKey.S then
switcha.y <- switcha.y + 1
else if key_info = ConsoleKey.D then
switcha.x <- switcha.x + 1
else if key_info = ConsoleKey.Q then
switcha.x <- switcha.x - 1
The problem is that I can only have one input over the round loop.
Do I need to create a thread that will catch the input of the second player? I don't know what I can do.
Thanks in advance.
+3
source to share
No one has answered this question yet
Check out similar questions: