private void HandleInput(GameTime gameTime, List <Wall> walls) { int mvSpeed = 3; float multiplier = 60 * gameTime.ElapsedGameTime.Milliseconds / 1000.0f; //Keeping gametime consistency for movement speed. KeyboardState ks = Keyboard.GetState(); Vector2 prevPosition = player.Position; if (ks.IsKeyDown(Keys.W)) { player.Position += new Vector2(0, -mvSpeed * multiplier); } if (ks.IsKeyDown(Keys.S)) { player.Position += new Vector2(0, mvSpeed * multiplier); } foreach (Wall wall in walls) { if (player.CheckCollision(playerBase)) { player.Position = prevPosition; break; } } prevPosition = player.Position; if (ks.IsKeyDown(Keys.A)) { player.Position += new Vector2(-mvSpeed * multiplier, 0); } if (ks.IsKeyDown(Keys.D)) { player.Position += new Vector2(mvSpeed * multiplier, 0); } if (player.CheckCollision(playerBase)) { { player.Position = prevPosition; } } // Handle shooting MouseState mouseState = Mouse.GetState(); if (mouseState.LeftButton == ButtonState.Pressed) { Vector2 direction = (new Vector2(mouseState.X, mouseState.Y) - player.Position); direction.Normalize(); Bullet bullet = new Bullet(player.Position + new Vector2(8, 8)); bullet.Velocity = direction; bullets.Add(bullet); } }