im trying to make a game where it counts the amount of guesses you make, but cuts you off to retry or go to menu. when i get the guess right, it wont display my dbPrint or go to my new input (exit = atoi(dbInput() ). and if i hit ESC, it goes to a never ending loop and my game crashes. can anyone help?
GuessGame
class guessGame
{
public:
int myNumber;
int guess;
int exit;
int exit2;
int count;
void executeness();
};
void guessGame::executeness()
{
dbSetWindowTitle("Guess Game");
dbLoadMusic("SKRILLEX.mp3", 2);
const int MAX_NUMBER = 10;
dbRandomize( dbTimer() );
myNumber = dbRND(MAX_NUMBER);
dbPlayMusic(2);
dbSetMusicVolume(2, 1);
dbLoadBitmap("Think_Awesome.bmp", 0);
dbPrint("Welcome to the GUESSING GAME!!!");
dbPrint("");
dbPrint("I'm thinking of a number...");
dbPrint("Between 1 and 10");
dbPrint("");
dbPrint("Enter your guess");
guess = atoi( dbInput() );
while(guess != myNumber)
{
for(count = 1; count <= 10; count++)
{
if(guess < myNumber)
{
dbPrint("Too Low");
}
if(guess > myNumber)
{
dbPrint("Too High");
}
guess = atoi( dbInput() );
}
if(count > 10)
{
dbPrint("You Failed. Press 1 to Try again, 2 to go back to Menu");
exit2 = atoi( dbInput() );
if(exit2 == 1)
{
dbCLS();
executeness();
}
if(exit2 == 2)
{
dbStopMusic(2);
dbCLS();
DarkGDK();
}
}
else if(count < 10 && guess == myNumber)
{
dbPrint("Congratulations!!! You Won $1,000,000,000!!");
dbPrint("Not really.... but good effort :)");
dbPrint("You got the guess right in");
dbPrint( dbStr(count) );
if(count < 3)
{
dbPrint("Great Guesser!!");
}
if(count > 3 && count < 6)
{
dbPrint("Eh, It's an alright guess");
}
if(count > 6)
{
dbPrint("Need better psychic skills O.o");
}
dbPrint("Press 1 to go back to menu, 2 to play again, ESC to quit");
}
}
exit = atoi( dbInput() );
if(exit == 2)
{
dbCLS();
executeness();
}
if(exit == 1)
{
dbStopMusic(2);
dbCLS();
DarkGDK();
}
}
this is a class code. the DarkGDK(); is my main menu.
Main Menu
#include "DarkGDK.h"
#include "guessGame3.h"
#include "monkeyNess.h"
void menuReturn();
void DarkGDK()
{
menuReturn();
}
void menuReturn()
{
dbSetWindowTitle("Main Menu");
DWORD red = dbRGB(255, 0, 0);
dbLoadMusic("august_burns_red_composure.wav", 1);
dbSetMusicVolume(1, 25);
int menuChoice;
guessGame myGuess;
monkeyNess myMonkey;
dbLoadBitmap("Biohazard.bmp", 0);
dbInk(red, red);
dbCenterText(310, 20, "Welcome to the EPIC MENU!!!!!");
dbCenterText(310, 80, "Press 1 to play Guessing Game");
dbCenterText(310, 110, "Press 2 to play Feed The Monkey");
dbCenterText(310, 140, "Press 3 to play Picture Play");
dbCenterText(310, 170, "Press ESC to Quit");
dbPlayMusic(1);
menuChoice = atoi( dbInput() );
if(menuChoice == 1)
{
dbStopMusic(1);
dbCLS();
myGuess.executeness();
}
if(menuChoice == 2)
{
dbStopMusic(1);
dbCLS();
myMonkey.monkeyGame();
}
else
{
dbPrint("Unkown Command. Please choose a number");
}
}
w00t! ^_^