Skip to content

Commit 7114370

Browse files
committed
aded persistence module for keeping track of stars for score screen
1 parent bb10301 commit 7114370

File tree

6 files changed

+55
-6
lines changed

6 files changed

+55
-6
lines changed

bin/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"audio" : {
3-
"music-volume" : 100,
4-
"sound-volume" : 100,
5-
"volume" : 100
3+
"music-volume" : 50,
4+
"sound-volume" : 50,
5+
"volume" : 50
66
},
77
"video" : {
88
"resolution" : "1920x1080",

src/Game.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "Qor/Input.h"
77
#include "Qor/Qor.h"
88
#include "Qor/Shader.h"
9+
#include "Persistence.h"
910
#include <glm/glm.hpp>
1011
#include <cstdlib>
1112
#include <chrono>
@@ -316,6 +317,11 @@ void Game :: preload() {
316317
auto mapname = _this->m_pQor->args().value_or("map","1");
317318
auto nextmap = to_string(boost::lexical_cast<int>(mapname) + 1);
318319

320+
// TODO: store star data in persistence module
321+
auto ps = _this->m_pQor->session()->module<Persistence>("persistence");
322+
ps->stars = _this->m_Stars;
323+
ps->max_stars = _this->m_MaxStars;
324+
319325
_this->m_pQor->args().set("map", nextmap);
320326
_this->m_pQor->change_state("pregame");
321327
}

src/Persistence.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "Qor/Session.h"
2+
3+
class Persistence:
4+
public Session::IModule
5+
{
6+
public:
7+
8+
virtual ~Persistence() {}
9+
10+
std::vector<int> stars;
11+
std::vector<int> max_stars;
12+
};
13+

src/Pregame.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "Qor/Input.h"
44
#include "Qor/Material.h"
55
#include "Qor/Qor.h"
6+
#include "Persistence.h"
67
#include <glm/glm.hpp>
78
#include <cstdlib>
89
#include <chrono>
@@ -12,6 +13,8 @@ using namespace std;
1213
using namespace glm;
1314
using namespace Filesystem;
1415

16+
//const std::vector<int> HUD :: STAR_LEVELS = { 7, 6, 2 };
17+
1518
Pregame :: Pregame(Qor* engine):
1619
m_pQor(engine),
1720
m_pInput(engine->input()),
@@ -89,6 +92,22 @@ void Pregame :: preload() {
8992
return;
9093
}
9194
m_pText->set(string("Now entering: ") + map_name);
95+
96+
//auto mat = make_shared<MeshMaterial>("items.png", m_pCache);
97+
98+
//auto mesh = make_shared<Mesh>(
99+
// make_shared<MeshGeometry>(Prefab::quad(vec2(sw / 24, sw / 24))),
100+
// vector<shared_ptr<IMeshModifier>>{
101+
// make_shared<Wrap>(Prefab::tile_wrap(
102+
// // Y Y (height is tile size for both dims)
103+
// uvec2(16,16),
104+
// // X Y
105+
// uvec2(mat->texture()->size().x, mat->texture()->size().y),
106+
// STAR_LEVELS[0]
107+
// ))
108+
// }, mat
109+
//);
110+
//add(mesh);
92111

93112
//// TEMP: just for jam
94113
/*
@@ -133,6 +152,10 @@ void Pregame :: preload() {
133152
}
134153
//m_pRoot->add(m_pCanvas);
135154
*/
155+
156+
auto ps = m_pQor->session()->module<Persistence>("persistence");
157+
m_Stars = ps->stars;
158+
m_MaxStars = ps->max_stars;
136159
}
137160

138161

@@ -148,6 +171,8 @@ void Pregame :: enter() {
148171
m_pPipeline->winding(true);
149172
m_pPipeline->bg_color(Color::black());
150173
m_pInput->relative_mouse(false);
174+
175+
Sound::play(m_pCamera.get(), "starpop.wav", m_pResources);
151176
}
152177

153178

src/Pregame.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ class Pregame: public State {
3131
virtual void render() const override;
3232
virtual bool needs_load() const override { return true; }
3333

34-
3534
private:
35+
36+
//static const std::vector<int> STAR_LEVELS;
37+
3638
// Variables
3739
bool m_Win = false;
3840
Freq::Alarm m_Transition;
3941

40-
4142
// Pointers
4243
Qor* m_pQor = nullptr;
4344
Input* m_pInput = nullptr;
@@ -52,6 +53,10 @@ class Pregame: public State {
5253

5354
std::shared_ptr<Font> m_pFont;
5455
std::shared_ptr<Text> m_pText;
56+
57+
std::vector<int> m_Stars;
58+
std::vector<int> m_MaxStars;
5559
};
5660

5761
#endif
62+

0 commit comments

Comments
 (0)