Commit 4c19275a authored by Konrad McClure's avatar Konrad McClure

Made high score screen an integreated it into 2048 with Kyle's SaveLoad...

Made high score screen an integreated it into 2048 with Kyle's SaveLoad classes. Next task is to make a game over screen and use that to add new scores to the file
parent 56235ca7
NAME SCORE
Mal 54234
BVB 9240
BND 6564
CDS 6544
NKV 5453
KAL 2434
#include <iostream>
#include "2048MenuState.h"
#include "2048GameState.h"
#include "2048ScoreState.h"
#include <string>
#include <fstream>
......@@ -35,7 +36,8 @@ void C2048MenuState::Init()
}
// Set first input and draw the menu
input = ' ';
input = 0;
menuPos = 0;
Draw(nullptr);
}
......@@ -84,8 +86,8 @@ void C2048MenuState::Update(CGameEngine* game)
game->PushState(C2048GameState::Instance());
break;
case 1: //Snake
//game->PushState(CHighScore::Instance());
case 1: // High Scores
game->PushState(C2048ScoreState::Instance());
break;
case 2: //Quit
......
......@@ -10,17 +10,25 @@ C2048ScoreState C2048ScoreState::m_2048ScoreState;
void C2048ScoreState::Init()
{
// Load in main menu title
ifstream fs("2048ScoreTitle.txt");
fs.seekg(0, ios::end);
menuTitle.reserve(fs.tellg());
fs.seekg(0, ios::beg);
menuTitle.assign((istreambuf_iterator<char>(fs)),
istreambuf_iterator<char>());
// Set name for debugging
stateName = "2048score";
if (!isInit)
{
// Load in main menu title
ifstream fs("2048ScoreTitle.txt");
fs.seekg(0, ios::end);
menuTitle.reserve(fs.tellg());
fs.seekg(0, ios::beg);
menuTitle.assign((istreambuf_iterator<char>(fs)),
istreambuf_iterator<char>());
// Set name for debugging
stateName = "2048score";
// Read in score data
highscores.LoadContainers();
isInit = true;
}
// Set first input and draw the menu
input = ' ';
......@@ -71,7 +79,7 @@ void C2048ScoreState::Draw(CGameEngine* game)
system("stty cooked");
cout << menuTitle << endl;
cout << "\n\n\n" << "Press w and s to move up and down, d to select" << endl;
highscores.displayScores();
system("stty raw");
}
......
......@@ -2,6 +2,7 @@
#define C2048SCORESTATE_H
#include "GameState.h"
#include "../Testings/SaveLoad/SL2048.h"
#include <iostream>
#include <string>
......@@ -26,6 +27,9 @@ class C2048ScoreState : public CGameState
private:
static C2048ScoreState m_2048ScoreState;
char input;
string menuTitle;
SL2048 highscores;
bool isInit = false;
};
......
g++ -std=c++11 -pthread *.cpp ../2048/*.cpp ../Testings/Snake/ReadInput.cpp && ./a.out
\ No newline at end of file
g++ -std=c++11 -pthread *.cpp ../2048/*.cpp ../Testings/Snake/ReadInput.cpp ../Testings/SaveLoad/SaveLoad.cpp ../Testings/SaveLoad/SL2048.cpp && ./a.out
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment