Example #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            controllerList = new List <IController>();

            KeyboardController keyboard = new KeyboardController(this);
            GamePadController  gamepad  = new GamePadController(this);

            keyboard.RegisterCommand(Keys.Q, new QuitCommand(this));
            keyboard.RegisterCommand(Keys.W, new StaticCommand(this));
            keyboard.RegisterCommand(Keys.E, new AnimatedNotMovingCommand(this));
            keyboard.RegisterCommand(Keys.R, new MovingNotAnimatedCommand(this));
            keyboard.RegisterCommand(Keys.T, new AnimatedAndMovingCommand(this));

            gamepad.RegisterCommand(Buttons.Start, new QuitCommand(this));
            gamepad.RegisterCommand(Buttons.A, new StaticCommand(this));
            gamepad.RegisterCommand(Buttons.B, new AnimatedAndMovingCommand(this));
            gamepad.RegisterCommand(Buttons.X, new MovingNotAnimatedCommand(this));
            gamepad.RegisterCommand(Buttons.Y, new AnimatedAndMovingCommand(this));


            this.controllerList.Add(keyboard);
            this.controllerList.Add(gamepad);

            startPosition = new Vector2(InitialPosX, InitialPosY);

            base.Initialize();
        }
Example #2
0
 protected override void Initialize()
 {
     keyboard       = new KeyboardController();
     gamepad        = new GamePadController();
     controllerList = new ArrayList();
     location.X     = 200;
     location.Y     = 200;
     controllerList.Add(gamepad);
     controllerList.Add(keyboard);
     this.RegisterCommands();
     base.Initialize();
 }