Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        public async void MainLoop()
        {
            IsRunning = true;
            while (IsRunning)
            {
                MoveObjects();
                CheckForCollisions();
                ManagePipes();

                MainLoopCompleted?.Invoke(this, EventArgs.Empty);
                await Task.Delay(20);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }