Пример #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()
        {
            Window.AllowUserResizing = true;
            //graphics.ToggleFullScreen();
            IsMouseVisible = true;
            sprite         = new Sprite1(this);
            spriteWidth    = 16;
            spriteHeight   = 16;
            spriteScale    = 6;
            offsetx        = 7;
            offsety        = 16;
            space          = 5;
            //this.GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
            //graphics.PreferMultiSampling = false;
            KeyboardController kbcntrl = new KeyboardController();
            MouseController    mcntrl  = new MouseController(graphics);

            ICommand[] commandlist = { new ExitCommand(this), new ChangeSprite1(this), new ChangeSprite2(this), new ChangeSprite3(this), new ChangeSprite4(this) };

            kbcntrl.mapCommand(Keys.D0, commandlist[0]);
            kbcntrl.mapCommand(Keys.D1, commandlist[1]);
            kbcntrl.mapCommand(Keys.D2, commandlist[2]);
            kbcntrl.mapCommand(Keys.D3, commandlist[3]);
            kbcntrl.mapCommand(Keys.D4, commandlist[4]);
            kbcntrl.mapCommand(Keys.NumPad0, commandlist[0]);
            kbcntrl.mapCommand(Keys.NumPad1, commandlist[1]);
            kbcntrl.mapCommand(Keys.NumPad2, commandlist[2]);
            kbcntrl.mapCommand(Keys.NumPad3, commandlist[3]);
            kbcntrl.mapCommand(Keys.NumPad4, commandlist[4]);

            mcntrl.mapMouse(commandlist);

            controllerList = new List <IController>
            {
                kbcntrl,
                mcntrl
            };

            font = Content.Load <SpriteFont>("Font");

            base.Initialize();
        }
Пример #2
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()
        {
            controllerList = new ArrayList();
            GamepadController  gamePadState  = new GamepadController(PlayerIndex.One);
            KeyboardController keyboardState = new KeyboardController();

            keyboardState.Register(Keys.Q, new CommandQuit(this));
            keyboardState.Register(Keys.W, new CommandStatic(this));
            keyboardState.Register(Keys.E, new CommandAnimated(this));
            keyboardState.Register(Keys.R, new CommandDead(this));
            keyboardState.Register(Keys.T, new CommandRunning(this));

            gamePadState.Register(Buttons.Start, new CommandQuit(this));
            gamePadState.Register(Buttons.A, new CommandStatic(this));
            gamePadState.Register(Buttons.B, new CommandAnimated(this));
            gamePadState.Register(Buttons.X, new CommandDead(this));
            gamePadState.Register(Buttons.Y, new CommandRunning(this));

            controllerList.Add(keyboardState);
            controllerList.Add(gamePadState);

            base.Initialize();
        }