/******* UPDATE ENEMY COLLISION METHOD *******/ public void UpdateEnemyCollision(Enemy enemy) { if (health > 0 && playerRectangle.Intersects(enemy.destinationRectangle)) health--; }
protected override void Initialize() { player = new Player(); enemy = new Enemy(); largeEnemy = new LargeEnemy(); playerHealth = new HealthBar(); stats = new Stats(player); background1 = new Scrolling(Content.Load<Texture2D>("Backgrounds/background1"), new Rectangle(0, 0, screenWidth, screenHeight)); background2 = new Scrolling(Content.Load<Texture2D>("Backgrounds/background1"), new Rectangle(screenWidth, 0, screenWidth, screenHeight)); base.Initialize(); }
/************ UPDATE METHOD ************/ public void Update(GameTime gametime, Enemy enemy) { currentState = Keyboard.GetState(); theKeyboardState = Keyboard.GetState(); particleTarget = new Vector2(position.X + 45, position.Y + 51); // TODO: Add your update logic here UpdateWalking(); UpdateJumping(); UpdateRunning(); UpdateBorderCollision(); UpdateEnemyCollision(enemy); oldKeyboardState = theKeyboardState; sourceRectangle = new Rectangle(frameSize.X * currentFrame.X, frameSize.Y * currentFrame.Y, frameSize.X, frameSize.Y); playerRectangle = new Rectangle((int)position.X, (int)position.Y, characterTexture.Width / sheetWidth , characterTexture.Height / sheetHeight); base.Update(gametime, speed, direction); }