[.net] How to do action until something else happens (snake game on console)

Started by
10 comments, last by Skibula 14 years, 10 months ago
i pasted the code u gave me and it doesnt compile

it give me error
Error 1 Use of unassigned local variable 'keyInfo'
on this line
while (keyInfo.Key != System.ConsoleKey.Escape);



i changed this to this
while (true)

just to test it

and now its half the way

casue i still need to press the key if i want to move...
i need to hold the key
(i want for 1 key press it will do that until i press another key...
Advertisement
i just wanted to say to all of you that took part of this post


thanks to you guys i have figured it up

im now using timer event
t = new Timer(250);then main loopwhile (true){                 t.Dispose();//clean the old timer for reuse(i dont know how                                to  empty time signal)                 t = new Timer(250);                 t.Elapsed += new ElapsedEventHandler(t_Elapsed);                 t.Start();                 z = Console.ReadKey();}        static void t_Elapsed(object sender, ElapsedEventArgs e)        {              GoToMove(z.KeyChar);//inside this function there is a                                     case for evey direction        }


any way thanks everybody for helping me out
:-)

This topic is closed to new replies.

Advertisement