Ejemplo n.º 1
0
        public void ProcessInput(GameTime time)
        {
            foreach(var keyHandlerPair in KeyHandlers)
            {
                Key key = keyHandlerPair.Key;
                InputActionHandler handler = keyHandlerPair.Value;
                bool keyIsDown = Keyboard.IsKeyDown(key);

                if(keyIsDown)
                {
                    if(!handler.WasDown)
                    {
                        handler.WasDown = true;
                        KeyHandlers[key].FireKeyDown(key, time);
                    }

                    KeyHandlers[key].FireKeyPressed(key, time);
                }
                else if(handler.WasDown)
                {
                    handler.WasDown = false;
                    KeyHandlers[key].FireKeyUp(key, time);
                }

            }
        }
Ejemplo n.º 2
0
 protected virtual void RenderFrame(GameTime time)
 {
 }
Ejemplo n.º 3
0
 protected virtual void HandleInput(GameTime time)
 {
     Input.ProcessInput(time);
 }
Ejemplo n.º 4
0
        private void DrawSnakes(GameTime time)
        {
            for(int i = 0; i < Snakes.Count; i++)
            {
                Rect snake = Snakes[i];
                Image snakeImage = SnakeImages[i];

                snake.Offset(time.ElapsedSeconds * -(Container.ActualWidth / 5), 0);

                Snakes[i] = snake;

                snakeImage.SetValue(Canvas.LeftProperty, snake.Left);
                snakeImage.SetValue(Canvas.TopProperty, snake.Top);

                if(snake.X + snake.Width < 0)
                {
                    SnakeImages.Remove(snakeImage);
                    Container.Children.Remove(snakeImage);
                    Snakes.Remove(snake);
                    RemainingSnakes--;
                }
            }
        }
Ejemplo n.º 5
0
        private void CheckCollisions(GameTime time)
        {
            Rect girlBox = GetBoundingBox(GirlImage);

            foreach(var snake in Snakes)
                if(girlBox.IntersectsWith(snake))
                    EndGame();
        }
Ejemplo n.º 6
0
        protected override void RenderFrame(GameTime time)
        {
            base.RenderFrame(time);

            if(GameOver || Advancing)
                return;

            DrawSnakes(time);
            CheckCollisions(time);

            if(RemainingSnakes <= 0)
                GetGoldenCup();
        }
Ejemplo n.º 7
0
        protected void GirlJump(Key key, GameTime time)
        {
            if(GameOver)
                return;

            if(Jumping)
                return;

            Jumping = true;

            WalkStoryboard.Stop(this);
            JumpStoryboard.Begin(this, true);
        }
Ejemplo n.º 8
0
 public void FireKeyUp(Key key, GameTime time)
 {
     if(KeyUp != null)
         KeyUp(key, time);
 }
Ejemplo n.º 9
0
 public void FireKeyPressed(Key key, GameTime time)
 {
     if(KeyPressed != null)
         KeyPressed(key, time);
 }
Ejemplo n.º 10
0
 public void FireKeyDown(Key key, GameTime time)
 {
     if(KeyDown != null)
         KeyDown(key, time);
 }