Exemplo n.º 1
0
 public override void Update(GameTime gameTime, IInput input)
 {
     if (input != null)
     {
         if (input.IsKeyDown(Keys.Left) && direction != Direction.Right)
         {
             Direction = Direction.Left;
             return;
         }
         if (input.IsKeyDown(Keys.Right) && direction != Direction.Left)
         {
             Direction = Direction.Right;
             return;
         }
         if (input.IsKeyDown(Keys.Up) && direction != Direction.Bottom)
         {
             Direction = Direction.Top;
             return;
         }
         if (input.IsKeyDown(Keys.Down) && direction != Direction.Top)
         {
             Direction = Direction.Bottom;
             return;
         }
     }
 }
Exemplo n.º 2
0
Arquivo: Field.cs Projeto: K0bin/Snake
 public virtual void Update(GameTime gameTime, IInput input)
 {
 }
Exemplo n.º 3
0
Arquivo: Game.cs Projeto: K0bin/Snake
        public void Update()
        {
            GameTime gameTime = new GameTime(new TimeSpan(watch.ElapsedTicks), new TimeSpan(watch.ElapsedTicks - lastElapsedTicks));
            lastElapsedTicks = watch.ElapsedTicks;

            //Update
            if (world != null)
                world.Update(gameTime, input);

            //Update
            if (gameTime.TotalGameTime.TotalMilliseconds - lastMilliseconds > Rules.Duration)
            {
                if (world != null)
                    world.SnakeTick();

                lastMilliseconds = (long)gameTime.TotalGameTime.TotalMilliseconds;
            }

            //Render
            renderer.Clear();

            if(world != null)
                world.Render(renderer);
        }
Exemplo n.º 4
0
Arquivo: World.cs Projeto: K0bin/Snake
        public void Update(GameTime gameTime, IInput input)
        {
            if (Head != null)
                Head.Update(gameTime, input);

            if (Treat != null)
                Treat.Update(gameTime, input);

            for (int i = 0; i < blocks.Count; i++)
                if (blocks != null && blocks[i] != null)
                    blocks[i].Update(gameTime, input);

            for (int i = 0; i < bodies.Count; i++)
                if (bodies != null && bodies[i] != null)
                    bodies[i].Update(gameTime, input);

            for (int i = 0; i < clearPowerups.Count; i++)
                if (clearPowerups != null && clearPowerups[i] != null)
                    clearPowerups[i].Update(gameTime, input);

            for (int i = 0; i < speedPowerups.Count; i++)
                if (speedPowerups != null && speedPowerups[i] != null)
                    speedPowerups[i].Update(gameTime, input);
        }