Beispiel #1
0
        public Application()
        {
            _window = new RenderWindow(new VideoMode(800, 600), "Flappy bird", Styles.Titlebar | Styles.Close);

            _sheet  = new SpriteSheet("spriteSheet.png");
            _player = new Player(_window, _window.Size.X * 0.2f, _sheet);
            _sheet.SetTutorialSprite(ref _tutorial);
            _tutorial.Position = (Vector2f)_window.Size / 2f;
            _tutorial.Scale    = new Vector2f(3, 3);
            _obstacleManager   = new ObstacleManager(_window, _player, _sheet);

            _obstacleManager.OnPlayerHitObstacle += OnPlayerHitObstacle;
            _window.Closed     += OnWindowClosed;
            _window.KeyPressed += OnKeyPressed;
        }
Beispiel #2
0
 private void OnKeyPressed(object?sender, KeyEventArgs e)
 {
     if (e.Code == Keyboard.Key.Space)
     {
         if (!_isUpdating && _tutorial != null)
         {
             _isUpdating = true;
             _tutorial   = null;
         }
         else if (!_isUpdating && _tutorial == null)
         {
             _isUpdating      = true;
             _player          = new Player(_window, _window.Size.X * 100f, _sheet);
             _obstacleManager = new ObstacleManager(_window, _player, _sheet);
         }
     }
 }