so I've just made a simple snake game in WinForms and I've only got one problem left. The idea is that I'm gonna implement a power-up that speeds up the player for 10 seconds. I've tried using thread. sleep method to create a timer but that sleeps the entire program. I've also tried playing with the task.delay
method but without success.
Am I going about this problem the wrong way or am I just missing something? Do you have any tips to get me on the right path? I'm quite new to this so this might be an easy fix.
var watch = new Stopwatch();
watch.Start();
using (var task = Task.Delay(10000))
{
speedUp = true;
task.Wait();
}
watch.Stop();
speedUp = false;
This is my attempt at the delay. But it seems to pause the entire program for 10 seconds before it continues.
Thanks