public bool OnHit() { nrg--; Heart heart = LifeMng.GetAliveHeart(); heart.IsCursed = true; if (nrg <= 0) { IsAlive = false; } return(true); }
public bool GameOver() { if (!StillAlive() || nrg <= 0) { for (int i = 0; i < nrg; i++) { Heart heart = LifeMng.GetAliveHeart(); heart.IsCursed = true; nrg--; } return(true); } return(false); }
public static void Play() { while (isAlive && isPlayble) { GfxTools.Clean(); //Input if (GfxTools.Win.GetKey(KeyCode.P)) { Exit(); } player.Input(); //Update Update(); Background.Update(); coin.Update(); AsteroidMng.Update(); platform.Update(); player.Update(); LifeMng.Update(); //Draw Background.Draw(); coin.Draw(); AsteroidMng.Draw(); platform.Draw(); player.Draw(); Explosion.Draw(); scoreText.Draw(); LifeMng.Draw(); gui.Draw(); GfxTools.Win.Blit(); } if (!isAlive && !isPlayble && isSavable) { SaveData(); } }
public static void Reset() { //PLAYER Vector2 playerPos; playerPos.X = GfxTools.Win.width / 2; playerPos.Y = GfxTools.Win.height - 100; float fpsPalyer = 20; int numSpritePlayer = 8; int verticalMaxSpeedPlayer = Gravity.gravity * 3; int horizontalMaxSpeedPlayer = Gravity.gravity * 3; int numOfLifes = 3; player = new Player(playerPos, numSpritePlayer, fpsPalyer, verticalMaxSpeedPlayer, horizontalMaxSpeedPlayer, numOfLifes); //COIN Vector2 coinPosition = new Vector2(50, RandomGenerator.GetRandom(50, GfxTools.Win.height - 50)); float fpsCoin = 8; int numSpriteCoin = 6; float verticalMaxSpeedCoin = Gravity.gravity * 150f; float horizontalMaxSpeedCoin = Gravity.gravity * 100f; coin = new Coin(coinPosition, numSpriteCoin, fpsCoin, verticalMaxSpeedCoin, horizontalMaxSpeedCoin); //ASTEROID Vector2 asteroidPosition = new Vector2(80, RandomGenerator.GetRandom(50, GfxTools.Win.height - 50)); float fpsAsteroid = 24; int numSpriteAsteroid = 64; float verticalMaxSpeedAsteroid = Gravity.gravity * 7.52f; float horizontalMaxSpeedAsteroid = Gravity.gravity * 2.5f; int numOfAsteroid = 4; asteroid = new Asteroid(numSpriteAsteroid, fpsAsteroid, verticalMaxSpeedAsteroid, horizontalMaxSpeedAsteroid); AsteroidMng.Init(numOfAsteroid, numSpriteAsteroid, fpsAsteroid, verticalMaxSpeedAsteroid, horizontalMaxSpeedAsteroid); //LIFE Vector2 lifePosition = new Vector2(GfxTools.Win.width - 50, 20); int offSetX = 30; LifeMng.Init(lifePosition, numOfLifes, offSetX); //PLATFORM Vector2 platformPosition = new Vector2(GfxTools.Win.width / 2, GfxTools.Win.height - 30); float fpsPlatform = 0; int numSpritePlatform = 1; //int verticalMaxSpeedPlatform = 0; //int horizontalMaxSpeedPlatform = 0; platform = new SpaceStation(platformPosition, numSpritePlatform, fpsPlatform); //SCORE score = 0; scoreText = new SpriteText(new Vector2(GfxTools.Win.width / 4, 20), "000000"); //GUI Vector2 guiPosition = new Vector2(GfxTools.Win.width / 2, GfxTools.Win.height / 2); int numSpriteGui = 2; gui = new GUI(guiPosition, numSpriteGui); //AUDIOGAMEOVER string[] audioPath = { @"Assets\media\gameover\decrease_bell_3.wav" }; audio = new Audio(audioPath, false); }