Example #1
0
        public TankAGame()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = 1000;
            graphics.PreferredBackBufferHeight = 750;
            graphics.ApplyChanges();

            this.IsFixedTimeStep = false;
            random = new Random();

            Content.RootDirectory = "Content";

            config = TankAConfig.Instance;
            config.LoadFromConfigFile();

            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            // Active first screen
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(), null);

            network = new NetworkManager(this);
            Components.Add(network);
            Services.AddService(typeof(INetworkManager), network);
            thisGame = this;
        }
Example #2
0
 // Private methods
 void HandleGamePlayInput(KeyboardState keyboardState, TankAConfig config, byte playerIndex)
 {
     // Fire
     if (keyboardState.IsKeyDown(config.controllers[playerIndex].fireKey))
         map.FireUserTank(playerIndex);
     // Movement
     if (keyboardState.IsKeyDown(config.controllers[playerIndex].upKey))
         map.MoveUserTank(playerIndex, Direction.Up);
     else if (keyboardState.IsKeyDown(config.controllers[playerIndex].downKey))
         map.MoveUserTank(playerIndex, Direction.Down);
     else if (keyboardState.IsKeyDown(config.controllers[playerIndex].leftKey))
         map.MoveUserTank(playerIndex, Direction.Left);
     else if (keyboardState.IsKeyDown(config.controllers[playerIndex].rightKey))
         map.MoveUserTank(playerIndex, Direction.Right);
     else
         map.MoveUserTank(playerIndex, Direction.None);
 }