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
c9918a08
Commit
c9918a08
authored
Mar 11, 2019
by
Nelson Phillips
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.cs.wallawalla.edu:philne/142GameCenter
parents
1e61c7ef
bd4d4e41
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
130 additions
and
6 deletions
+130
-6
GameEngine/2048GameOverState.cpp
GameEngine/2048GameOverState.cpp
+86
-0
GameEngine/2048GameOverState.h
GameEngine/2048GameOverState.h
+36
-0
Testings/SaveLoad/SaveLoad.cpp
Testings/SaveLoad/SaveLoad.cpp
+2
-5
Testings/SaveLoad/main.cpp
Testings/SaveLoad/main.cpp
+1
-1
Testings/SaveLoad/snakedata.txt
Testings/SaveLoad/snakedata.txt
+5
-0
No files found.
GameEngine/2048GameOverState.cpp
0 → 100644
View file @
c9918a08
#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 @
c9918a08
#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
Testings/SaveLoad/SaveLoad.cpp
View file @
c9918a08
...
...
@@ -25,8 +25,8 @@ void SaveLoad::displayScores(){
void
SaveLoad
::
userInputNameMakeScore
(
int
intScore
){
char
userNameInput
[
3
];
cout
<<
"Please enter a 3 character user name
\n
"
;
do
{
cout
<<
"Please enter a 3 character user name
\n
"
;
try
{
cin
>>
userNameInput
;
if
(
strlen
(
userNameInput
)
!=
3
){
...
...
@@ -41,10 +41,7 @@ void SaveLoad::userInputNameMakeScore(int intScore){
}
while
(
true
);
Scores
*
scorePtr
=
nullptr
;
scorePtr
=
new
Scores
(
userNameInput
,
intScore
);
pushBackNewScoreAndSort
(
*
scorePtr
);
delete
scorePtr
;
pushBackNewScoreAndSort
(
Scores
(
userNameInput
,
intScore
));
}
\ No newline at end of file
Testings/SaveLoad/main.cpp
View file @
c9918a08
...
...
@@ -29,7 +29,7 @@ int main(){
// second.displayScores();
second
.
userInputNameMakeScore
(
1000
);
second
.
userInputNameMakeScore
(
9999
);
second
.
updateFile
();
second
.
displayScores
();
...
...
Testings/SaveLoad/snakedata.txt
View file @
c9918a08
...
...
@@ -2,10 +2,15 @@ NAME SCORE
nge 654346
vfd 45365
cdn 21474
bbb 9999
vfr 9999
ddd 9999
Kyl 9999
vfd 4636
vev 4536
DVS 3423
goo 1000
vfd 1000
efd 1000
dew 343
bth 34
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