Listing 1 Player class

class Player
    {
        public string name = "Unknown";
        public PlayerIndex index;
        public Texture2D car;
        public Vector2 carPosition = new Vector2(300, 150);
        public Vector2 carLastGoodPosition;
        public float carRotation = 0;
        public Color color;
        public Keys up;
        public Keys down;
        public Keys left;
        public Keys right;
        public BoundingBox bb;
        public int round = 0;
        public float bestLapTime = 120.0f;
        public float currentLapTime;
        public bool onFinishLine = false;
        public bool passedWaypoint = false;
        public int points = 0;
    }

Listing 2: The LevelHandler class

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace XNACarCupSimple
{
    class LevelHandler
    {
        static public int MaxPlayers = 4;
        static public Vector2[,] PlayerStartPositions = new Vector2[4, 4];
        static public float[] PlayerStartRotation = 
              new float[] { 3.15f, 0, 0, 0 };
        static public Color[] PlayerColors = new Color[] { 
            Color.Gold, Color.ForestGreen, 
            Color.DodgerBlue, Color.DeepPink };
        static public Keys[,] PlayerKeys = new Keys[,] { 
            { Keys.Up, Keys.Down, Keys.Left, Keys.Right }, 
            { Keys.W, Keys.S, Keys.A, Keys.D }, 
            { Keys.T, Keys.G, Keys.F, Keys.H }, 
            { Keys.I, Keys.K, Keys.J, Keys.L } };
        static LevelHandler()
        {
            PlayerStartPositions[(int)(PlayerIndex.One), 0].X = 530;
            PlayerStartPositions[(int)(PlayerIndex.One), 0].Y = 500;
            PlayerStartPositions[(int)(PlayerIndex.Two), 0].X = 530;
            PlayerStartPositions[(int)(PlayerIndex.Two), 0].Y = 530;

            PlayerStartPositions[(int)(PlayerIndex.Three), 0].X = 580;
            PlayerStartPositions[(int)(PlayerIndex.Three), 0].Y = 500;
            PlayerStartPositions[(int)(PlayerIndex.Four), 0].X = 580;
            PlayerStartPositions[(int)(PlayerIndex.Four), 0].Y = 530;
        }
    }
}


Listing 3

for (int i = 0; i < LevelHandler.MaxPlayers; i++)
{
    Player player = new Player();
    player.index = 
       (PlayerIndex)System.Enum.Parse(typeof(PlayerIndex), i.ToString());
    player.car = Content.Load<Texture2D>("Car");
    player.carPosition.X =
        LevelHandler.PlayerStartPositions[(int)player.index, 0].X;
    player.carPosition.Y = 
        LevelHandler.PlayerStartPositions[(int)player.index, 0].Y;
    player.carRotation = LevelHandler.PlayerStartRotation[0];
    player.color = LevelHandler.PlayerColors[(int)player.index];
    player.up = LevelHandler.PlayerKeys[i,0];
    player.down = LevelHandler.PlayerKeys[i, 1];
    player.left = LevelHandler.PlayerKeys[i, 2];
    player.right = LevelHandler.PlayerKeys[i, 3];
    //player.up = Keys.Up;
    //player.down = Keys.Down;
    //player.left = Keys.Left;
    //player.right = Keys.Right;
    players[i] = player;
}

Listing 4

// TODO: Add your update logic here
KeyboardState pKeyboard = Keyboard.GetState();

int toMove = (int)(200 * gameTime.ElapsedGameTime.TotalSeconds);

foreach (Player player in players)
{
    GamePadState pGamePad = GamePad.GetState(player.index);

    //Rotate the Car sprite with the Left Thumbstick or the down arrow
    player.carRotation += (float)(pGamePad.ThumbSticks.Left.X * 3.0f * gameTime.ElapsedGameTime.TotalSeconds);
    if (pKeyboard.IsKeyDown(player.left) == true)
    {
        player.carRotation -= (float)(3.0f * gameTime.ElapsedGameTime.TotalSeconds);
    }
    else if (pKeyboard.IsKeyDown(player.right) == true)
    {
        player.carRotation += (float)(3.0f * gameTime.ElapsedGameTime.TotalSeconds);
    }

    player.currentLapTime += (float)gameTime.ElapsedGameTime.TotalSeconds;

    player.carPosition.X += (float)(toMove * Math.Cos(player.carRotation));
    player.carPosition.Y += (float)(toMove * Math.Sin(player.carRotation));

}


Listing 5

if (player.index == PlayerIndex.One)
{
    spriteBatch.DrawString(font, player.name, 
        new Vector2(x1ScoreBoard, y1ScoreBoard), 
        LevelHandler.PlayerColors[(int)player.index]);
    spriteBatch.DrawString(font, "Round: " + player.round, 
        new Vector2(x1ScoreBoard, y1ScoreBoard + nextLineScoreBoard), 
        Color.White);
    spriteBatch.DrawString(font, string.Format("LAP:  {0:00}:{1:00.00}", 
        (player.currentLapTime / 60.0f), (player.currentLapTime % 60)), 
        new Vector2(x1ScoreBoard, y1ScoreBoard + (nextLineScoreBoard * 2)), 
        Color.White);
    spriteBatch.DrawString(font, string.Format("BEST: {0:00}:{1:00.00}", 
        (player.bestLapTime / 60.0f), (player.bestLapTime % 60)), 
        new Vector2(x1ScoreBoard, y1ScoreBoard + (nextLineScoreBoard * 3)), 
        Color.White);
}