public void updateFuelCell() { if (fuelCellY < 472 && fuelCellLanded == false && pickedUpCell == false) { fuelCellY++; if (fuelCellY >= 472) { fuelCellLanded = true; } } //Intersect with ledges if (fuelCellRect.Intersects(Ledge1BoundingRect) || fuelCellRect.Intersects(Ledge2BoundingRect) || fuelCellRect.Intersects(Ledge3BoundingRect)) { fuelCellY -= 1; fuelCellLanded = true; } if (ManBoundingRect.Intersects(fuelCellRect) && fuelCellLanded == true) { pickedUpCell = true; } if (pickedUpCell == true && fuelCellX != 430) { fuelCellX = JetPac.x; fuelCellY = JetPac.y + 20; } if (fuelCellX == 430 && fuelCellY < 472) { fuelCellY++; if (fuelCellY >= 472) { JetPac.fuelLevel += 25; fuelCellX = rand.Next(30, 770); fuelCellY = -30; if (JetPac.fuelLevel < 100) { fuelCellLanded = false; } else { JetPac.fullTank = true; } pickedUpCell = false; } } }
public void collide() { // Check if meteor hits ledges if (MeteorRect.Intersects(ledge1Rect) == true || MeteorRect.Intersects(ledge2Rect) == true || MeteorRect.Intersects(ledge3Rect) == true) { JetPac.explosionX = MeteorX; JetPac.explosionY = MeteorY; MeteorX = rand.Next(800, 1200); MeteorY = rand.Next(50, 400); JetPac.explosionFrame = 0; JetPac.explode = true; } // Check if player hits meteor if (ManBoundingRect.Intersects(MeteorRect) == true) { JetPac.lives--; JetPac.x = 200; JetPac.y = 360; MeteorY = rand.Next(50, 400); MeteorX = rand.Next(800, 1200); JetPac.died.Play(); if (JetPac.lives == 0) { JetPac.gameOn = false; } } KeyboardState keyboard = Keyboard.GetState(); foreach (Bullet b in JetPac.fireRight) { if (b.bulletRightRect.Intersects(MeteorRect) == true) { JetPac.deleteFireRight.Add(b); JetPac.explosionX = MeteorX; JetPac.explosionY = MeteorY; MeteorX = rand.Next(800, 1200); MeteorY = rand.Next(50, 400); JetPac.explosionFrame = 0; JetPac.explode = true; JetPac.score += 10; JetPac.collision = true; JetPac.hit.Play(); } } foreach (BulletLeft b in JetPac.fireLeft) { if (b.bulletLeftRect.Intersects(MeteorRect) == true) { JetPac.explosionX = MeteorX; JetPac.explosionY = MeteorY; MeteorX = rand.Next(800, 1200); MeteorY = rand.Next(50, 400); JetPac.explosionFrame = 0; JetPac.explode = true; JetPac.score += 10; JetPac.collision = true; JetPac.hit.Play(); } } }