public void ResolveCollision(Player player, DrawData item) { Rectangle overlap = Rectangle.Intersect(player.Destination, item.Destination); player.Position -= new Vector2(overlap.X, overlap.Y); player.Velocity = new Vector2(0, 0); player.VelocityGravity = new Vector2(0, 0); }
public Level01(Texture2D terrainArt, Texture2D enemyArt, GameState gameState, int gameStateCheck, Player player) { _levelObjects = new List<DrawData>(); _terrainArt = terrainArt; _enemyArt = enemyArt; GameState = gameState; GameStateCheck = gameStateCheck; _player = player; AddLevelObjects(); }
public void Update(GameTime gameTime, Player player) { // _centre = new Vector2(player.Destination.X , player.Destination.Y); //_centre = new Vector2(player.Position.X + (player.Destination.Width / 2), player.Position.Y + (player.Destination.Height / 2)); _centre = new Vector2(player.Position.X - 300, player.Position.Y + (_view.Height / 2)- 500); transform = Matrix.CreateScale(new Vector3(1, 1, 0)) * Matrix.CreateTranslation(new Vector3(-_centre.X, -_centre.Y, 0)); // * Matrix.CreateTranslation(new Vector3(-player.Position.X + (player.Destination.Width / 2), -player.Position.Y + (player.Destination.Height / 2), 0)); }
public bool IsCollision(Player player, DrawData item) { if (player.Destination.Intersects(item.Destination)) return true; return false; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); _backgroundMusic = Content.Load<SoundEffect>("endless"); SoundEffectInstance instance = _backgroundMusic.CreateInstance(); instance.IsLooped = true; _backgroundMusic.Play(); Texture2D _buttonArt = Content.Load<Texture2D>("meny"); Texture2D _keysBindingArt = Content.Load<Texture2D>("keysSprite2"); _keyMenu = new KeyBindingsMenu(_keysBindingArt, _screenWidth, _screenHeight, _gameState, _gameStateCheck); _startMenu = new StartMenu(_buttonArt, _screenWidth, _screenHeight, _gameState, _gameStateCheck); Texture2D _playerArt = Content.Load<Texture2D>("spritesheettest1"); Rectangle playerRect = new Rectangle(0, 0, 100, 117); _player = new Player(_playerArt, 5, playerRect); Texture2D terrainArt = Content.Load<Texture2D>("spriteTerrain"); _level01 = new Level01(terrainArt, _playerArt, _gameState, _gameStateCheck, _player); }