-
Notifications
You must be signed in to change notification settings - Fork 2
/
GameSystemExtended.cpp
79 lines (68 loc) · 1.95 KB
/
GameSystemExtended.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "GameSystemExtended.h"
namespace is
{
GameSystemExtended::GameSystemExtended() :
GameSystem()
{
initProgress();
// Default position of the Virtual Pad Game on the screen
m_defaultPadDirXPos = -250.f;
m_defaultPadDirYPos = 170.f;
m_defaultPadActionXPos = 245.f;
m_defaultPadActionYPos = 200.f;
// Configurable position of the Virtual Pad Game on the screen
m_padDirXPos = m_defaultPadDirXPos;
m_padDirYPos = m_defaultPadDirYPos;
m_padActionXPos = m_defaultPadActionXPos;
m_padActionYPos = m_defaultPadActionYPos;
m_permutePadAB = false;
m_padAlpha = 255;
}
void GameSystemExtended::initProgress()
{
m_gameProgression = 0; // LEVEL 1
m_currentLives = 3;
m_currentBonus = 0;
m_currentLevel = 0;
m_currentScore = 0;
}
void GameSystemExtended::initSystemData()
{
// global variable
m_gameLanguage = 0;
m_firstLaunch = true;
// Determine the number of levels
// LEVEL_MAX - 1 because we count the number of levels from zero (0) as for the array)
m_levelNumber = is::level::LevelId::LEVEL_MAX - 1;
}
void GameSystemExtended::initData(bool clearCurrentLevel)
{
if (clearCurrentLevel) m_currentLevel = 0; // LEVEL 1
m_currentBonus = 0;
m_currentScore = 0;
}
void GameSystemExtended::saveData(std::string const &fileName)
{
FILE *file = NULL;
file = fopen(fileName.c_str(), "wb");
if (file != NULL)
{
fwrite(&m_gameProgression, sizeof(int), 1, file);
fwrite(&m_currentLives, sizeof(int), 1, file);
fwrite(&m_currentBonus, sizeof(int), 1, file);
fclose(file);
}
}
void GameSystemExtended::loadData(std::string const &fileName)
{
FILE *file = NULL;
file = fopen(fileName.c_str(), "rb");
if (file != NULL)
{
fread(&m_gameProgression, sizeof(int), 1, file);
fread(&m_currentLives, sizeof(int), 1, file);
fread(&m_currentBonus, sizeof(int), 1, file);
fclose(file);
}
}
}