Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //// ////
- //// Name: game.h ////
- //// ////
- //// Purpose: establishing the game class ////
- //// ////
- //// Author: Sebastian Toy ////
- //// ////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // the new way of making sure this is accessed only once
- #pragma once
- #define MAX_LINE_CHAR 37 // there will be 37 lines set aside for guessing the real number
- #define MAX_LINE_WIDTH 50 // 50 characters are allocated per line
- // like a struct only different, more on this later
- class Game : public Window {
- public:
- // game functions
- void setUpGame(int a_width, int a_height); // initialize the variables
- void mainGameLoop(); // this is the game
- void drawMenuChoices(int a_lineNum); // draw the 'a' to 'c' choices in white or green
- void refreshLines(); // print all the lines with guesses in them
- void refreshBorder(int a_width, int a_height); // Refresh the border if the player overwrites it
- int findArrayLength(char a_array[]);
- enum eInput { NUM, NUM_RANGE, CHAR };
- int interceptInput
- (int a_lineNum, int a_lineDrawPoint, int a_maxDigits, char a_validChars[], int a_validCharLength, eInput a_inputType, int a_minRange = 0, int a_maxRange = 0); // Stop the player from entering in garbage
- void pauseTillEscapeHit(); // wait ...
- private:
- // game data
- int mMaxGuess; // current high guess
- int mMinGuess; // current low guess
- bool mGameOver; // is game over
- bool gQuitGame; // quit the game
- int mLinesX; // x location where the numbers are entered
- int mAdviceX; // x location where the high or low is mentioned
- int mMaxNum; // maximum number
- int mGuessNum; // current number to guess
- char mGameType; // game type 'a' 'b' or 'c'
- char mLines[MAX_LINE_CHAR][MAX_LINE_WIDTH]; // lines for the entries
- int mCurrentLineNumber; // current line you are up to
- int guessNumber; // current number of guesses
- // Valid character inputs
- char validModes[4] = { 'a', 'b', 'c', NULL };
- char validGuesses[3] = { 'l', 'h', NULL };
- char numbers[11] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', NULL };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement