void gameend(){ clearScreen(); std::string gameover; COORD c; c.Y = 6; c.X = 15; std::ifstream myfile; myfile.open("screen/gameover.txt"); for (int i = 0; myfile.good(); i++){ std::getline(myfile, gameover); console.writeToBuffer(c, gameover, 0x0E); // Prints the characters line by line after reading the text file c.Y += 1; } // Text for retry c.X = 28; c.Y = 13; console.writeToBuffer(c, "Press R to retry", 0x0E); if (keyPressed[K_R]) { levelReset(); } // Change gamestate from gameover to game and allows player to retry the stage they are at if (classes == BALANCED) { player.health = 4; player.ammo = 5; } // Adventurer/Balanced class, health 4, 4 ammo at start, 2 range else if (classes == WARRIOR) { player.health = 4; player.ammo = 1; } // Warrior class, health 6, infinite ammo, 1 range else if (classes == ARCHER) { player.health = 2; player.ammo = 8; } // Archer class, health 2 , 8 ammo at start, 3 range soundreset(); //Boss Projectile Bprojectile1.X = 0; Bprojectile1.Y = 0; Bprojectile2.X = 0; Bprojectile2.Y = 0; Bprojectile3.X = 0; Bprojectile3.Y = 0; Bprojectile4.X = 0; Bprojectile4.Y = 0; Bprojectile5.X = 0; Bprojectile5.Y = 0; Bprojectile6.X = 0; Bprojectile6.Y = 0; Bprojectile7.X = 0; Bprojectile7.Y = 0; Bprojectile8.X = 0; Bprojectile8.Y = 0; } // Boss projectile for all the 8 different directions
int levelSwitch(int id) { fprintf(stderr, "Loading level %d:\n", id); /* Checking for new id isn`t null */ if(!id) { fprintf(stderr, "%s: attempted to load 0th level.\n", __FUNCTION__); return 1; } /* Makin` sure that input ID`s not equal to current ID */ if(id == currentLevel.id) { fprintf(stderr, "%s: attempted to load the same level\n", __FUNCTION__); return 1; } /* Cleanup first */ levelReset(); currentLevel.id = id; /* Let`s load config files first */ if(loadConf(id) | loadItems(id) | loadTraps(id)) { fprintf(stderr, "%s: failed to load level's configuration file(s).\n" "Please make sure that all fields in the files are correct and there are no side entries.\n", __FUNCTION__); return 1; } if(loadBitmaps(id) | loadCollision(id)) { fprintf(stderr, "%s: some critical level's bitmaps has failed to load.\n", __FUNCTION__); return 1; } fprintf(stderr, " > Resetting objects\n"); playerReset(); bossReset(); fprintf(stderr, "Done.\n"); return 0; }