forked from 15-466/15-466-f22-base4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayMode.hpp
78 lines (56 loc) · 2.17 KB
/
PlayMode.hpp
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
#include "Mode.hpp"
#include "Scene.hpp"
#include "Sound.hpp"
#include <glm/glm.hpp>
#include <vector>
#include <deque>
#include "TextRendering.hpp"
#include "data_path.hpp"
#include "RoomParser.hpp"
#define MARGIN 5.
struct PlayMode : Mode {
PlayMode();
virtual ~PlayMode();
RoomParser room_parser;
//functions called by main loop:
virtual bool handle_event(SDL_Event const &, glm::uvec2 const &window_size) override;
virtual void update(float elapsed) override;
virtual void draw(glm::uvec2 const &drawable_size, glm::uvec2 const &window_size) override;
//----- game state -----
Room current_room;
//input tracking:
struct Button {
uint8_t downs = 0;
uint8_t pressed = 0;
} left, right, down, up;
//local copy of the game scene (so code can change it during gameplay):
Scene scene;
// font renderers
// TextRenderer *roboto_renderer = new TextRenderer(data_path("fonts/Roboto-Medium.ttf"), 54);
TextRenderer *rubik_renderer = new TextRenderer(data_path("fonts/RubikDirt-Regular.ttf"), 72);
TextRenderer *patua_renderer = new TextRenderer(data_path("fonts/PatuaOne-Regular.ttf"), 54);
// configuration for main text, choices and inputs
TextRenderer *main_text_renderer = patua_renderer;
TextRenderer *choice_renderer = patua_renderer;
TextRenderer *input_renderer = rubik_renderer;
float main_text_size = 0.5f;
glm::vec3 main_text_color = glm::vec3(1.0f, 1.0f, 1.0f);
//user input:
std::string user_input;
glm::vec3 input = glm::vec3(MARGIN,MARGIN,1.0f); //x pos, y pos, scale
glm::vec3 input_color = glm::vec3(1.0f, 0.25f, 0.25f); //input text color
//choices text:
float choices_text_size = 0.5f;
glm::vec3 choices_color = glm::vec3(1.0f, 1.0f, 0.2f);
//checking if there's a match in room map
std::string check_map(std::string inputString); //if no match, return empty string
std::string new_room; //store map value of check_map here
// background color:
glm::vec3 bg_color = glm::vec3(0.0f, 0.0f, 0.0f);
float time_elapsed;
float fade_time;
//lerp copied from https://graphicscompendium.com/opengl/22-interpolation
static glm::vec3 lerp(glm::vec3 x, glm::vec3 y, float t) {
return x * (1.f - t) + y * t;
}
};