Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
1
142GameCenter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nelson Phillips
142GameCenter
Commits
bd4d4e41
Commit
bd4d4e41
authored
Mar 11, 2019
by
Konrad McClure
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 2048GameOverState
parent
523a5e90
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
0 deletions
+122
-0
GameEngine/2048GameOverState.cpp
GameEngine/2048GameOverState.cpp
+86
-0
GameEngine/2048GameOverState.h
GameEngine/2048GameOverState.h
+36
-0
No files found.
GameEngine/2048GameOverState.cpp
0 → 100644
View file @
bd4d4e41
#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"
);
}
GameEngine/2048GameOverState.h
0 → 100644
View file @
bd4d4e41
#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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment