public async void MainLoop() { IsRunning = true; //while the game is running.. while (IsRunning) { MoveObjects(); CheckForCollisions(); ManagePipes(); //send a notification that a property changed on the Bird //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Bird))); ****REFACTORED //send a notification that a property changed on the Pipe //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Pipe))); ****REFACTORED //raising an event that triggers the listener in the game container MainLoopCompleted?.Invoke(this, EventArgs.Empty); //not supplying info, just raising an event //wait for 20 milliseconds await Task.Delay(20); } }
public async void MainLoop() { IsRunning = true; while (IsRunning) { MoveObjects(); CheckForCollisions(); ManagePipes(); MainLoopCompleted?.Invoke(this, EventArgs.Empty); await Task.Delay(20); } }
public async void MainLoop() { IsRunning = true; while (IsRunning) { MoveObjects(); CheckForCollision(); ManagePipes(); score += 1; //notifico che l'interfaccia è variata MainLoopCompleted?.Invoke(this, EventArgs.Empty); await Task.Delay(20); } }