Ejemplo n.º 1
0
        public KeyboardHandler(GameContext context)
        {
            IsEnabled = Environment.OSVersion.Platform != PlatformID.Xbox;
            KeyboardState = new Dictionary<Keys, InputState>();

            if (IsEnabled)
            {
                keyboardBuffer = new KeyboardBuffer(context.Game.Window.Handle);
                keyboardBuffer.KeyPress += keyboardBuffer_KeyPress;
                keyboardBuffer.KeyDown += keyboardBuffer_KeyDown;
            }
        }
Ejemplo n.º 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()
        {
            this.IsMouseVisible = true;

            this.graphics.PreferredBackBufferWidth  = ScreenWidth;
            this.graphics.PreferredBackBufferHeight = ScreenHeight;
            this.graphics.ApplyChanges();

            this.keyboardBuffer = new KeyboardBuffer();
            this.mouse          = new MouseHelp();
            this.actorQueue     = new PriorityQueue <IActor>();

            base.Initialize();
        }
Ejemplo n.º 3
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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            this.spriteBatch = new SpriteBatch(GraphicsDevice);

            this.graphics.PreferredBackBufferWidth  = ScreenWidth;
            this.graphics.PreferredBackBufferHeight = ScreenHeight;
            this.graphics.ApplyChanges();
            this.IsMouseVisible = true;

            this.keyboardBuffer = new KeyboardBuffer();

            base.Initialize();
        }
Ejemplo n.º 4
0
 public void Action(GameTime time, KeyboardBuffer keyboard, MouseBuffer mouse)
 {
     if (keyboard.IsKeyDown(Key.W))
     {
         Position.Y -= 1;
     }
     if (keyboard.IsKeyDown(Key.S))
     {
         Position.Y += 1;
     }
     if (keyboard.IsKeyDown(Key.A))
     {
         Position.X -= 1;
     }
     if (keyboard.IsKeyDown(Key.D))
     {
         Position.X += 1;
     }
 }