Commit bd4d4e41 authored by Konrad McClure's avatar Konrad McClure

Added 2048GameOverState

parent 523a5e90
#include <iostream>
#include "2048GameOverState.h"
#include <string>
#include <fstream>
#include <streambuf>
using namespace std;
C2048GameOverState C2048GameOverState::m_2048GameOverState;
void C2048GameOverState::Init()
{
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 = ' ';
Draw(nullptr);
}
void C2048GameOverState::Pause()
{
}
void C2048GameOverState::Resume()
{
input = 0;
}
void C2048GameOverState::Cleanup()
{
}
void C2048GameOverState::HandleEvents(CGameEngine* game)
{
while (game->newInput == false)
{
input = ' ';
}
input = game->input;
game->newInput = false;
}
void C2048GameOverState::Update(CGameEngine* game)
{
switch(input)
{
case 'x':
// Erase Scores
break;
default:
game->PopState();
break;
}
}
void C2048GameOverState::Draw(CGameEngine* game)
{
system("stty cooked");
cout << menuTitle << endl;
highscores.displayScores();
system("stty raw");
}
#ifndef C2048GAMEOVERSTATE_H
#define C2048GAMEOVERSTATE_H
#include "GameState.h"
#include "../Testings/SaveLoad/SL2048.h"
#include <iostream>
#include <string>
class C2048GameOverState : public CGameState
{
public:
void Init();
void Cleanup();
void Pause();
void Resume();
void HandleEvents(CGameEngine* game);
void Update(CGameEngine* game);
void Draw(CGameEngine* game);
static C2048GameOverState* Instance() { return &m_2048ScoreState; }
protected:
C2048GameOverState() {}
private:
static C2048GameOverState m_2048GameOverState;
char input;
string menuTitle;
SL2048 highscores;
bool isInit = false;
};
#endif
\ 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