Ejemplo n.º 1
0
        // Draws a player's bike
        private void drawPlayer(TronLogic.Player player)
        {
            int offset = player.updateTimer / (int)player.speed;
            int x      = player.x * cellSize;
            int y      = player.y * cellSize;

            //Drawing offset depends on the players direction
            if (player.direction == Player.Direction.Up)
            {
                y -= offset;
            }
            else if (player.direction == Player.Direction.Down)
            {
                y += offset;
            }
            else if (player.direction == Player.Direction.Left)
            {
                x -= offset;
            }
            else if (player.direction == Player.Direction.Right)
            {
                x += offset;
            }

            spriteBatch.Draw(basicTexture,
                             new Rectangle(
                                 gridOffset + x,
                                 gridOffset + y,
                                 cellSize,
                                 cellSize),
                             getColor(player));
        }
Ejemplo n.º 2
0
        // Takes a Tron Player Color and returns the correct xna color
        private Color getColor(TronLogic.Player player)
        {
            if (player.color == TronLogic.Player.Color.Blue)
            {
                return(bluePlayerColor);
            }
            if (player.color == TronLogic.Player.Color.Yellow)
            {
                return(yellowPlayerColor);
            }

            return(Color.White);
        }