-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
121 lines (105 loc) · 3.79 KB
/
main.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// xg_main.hpp
// life
//
// Created by Daher Alfawares on 1/1/2019.
// Copyright © 2019 Daher Alfawares. All rights reserved.
//
#include "xg.hpp"
#include <cmath>
using xg::v;
namespace cfg
{
const auto screen_size = xg::vec2(1200, 800);
const auto big_font_size = 24;
const auto big_font_spacing = 28.0f;
const auto big_font_name = "resources/Sansation-Regular.ttf";
const auto small_font_size = 14;
const auto small_font_name = "resources/Sansation-Light.ttf";
const auto small_font_spacing = 24.0f;
const auto tick_size = xg::vec2(0, 10);
const auto block_size = xg::vec2(80.0f, 80.0f)*2.80f;
const auto block_offset = xg::vec2(0, 0);
const auto block_disabled_color = xg::color::black();
const auto hud_block_size = xg::vec2(20.0f, 20.0f);
const auto pitch_grid_block_size = xg::vec2(40.0f, 40.0f);
const auto pitch_grid_origin = xg::vec2{ 250,screen_size.y - 250 } -cfg::pitch_grid_block_size*2.5f;
const auto icon_size = xg::vec2(100.0f, 100.0f)*1.0f;
const auto icon_offset = xg::vec2(0, -150.0f);
const auto legend_origin = screen_size * xg::vec2(1, 0) + xg::vec2(-300.0f, 240.0f);
const auto color_legend_origin = screen_size - xg::v{ -10.0f,60.0f };
const auto background_color = xg::color(30, 30, 30, 255);
const auto grid_color = xg::color::dark_gray();
const auto note_line_shade_factor = 0.40f;
}
class stats
{
xg::line line;
public:
void render(xg::renderer& renderer, const xg::time& time)
{
xg::text text(renderer, cfg::big_font_name, cfg::big_font_size);
xg::grid text_grid = xg::grid().start_at(cfg::screen_size * v{ 1, 1 }).space_by(v{ 0, 80 });
text.align = xg::bottom | xg::center_h;
text.origin = text_grid--;
text.color = xg::color::white();
renderer.set_color(text.color);
text.render(renderer, time_string(time));
line.p0 = text_grid--;
line.p1 = text_grid--;
line.render(renderer);
}
std::string time_string(const xg::time& time)
{
int T = int(time.seconds());
int hours = (T) / (60 * 60);
int minutes = (T - (hours * 60 * 60)) / 60;
int seconds = (T - (hours * 60 * 60) - (minutes * 60));
std::stringstream time_string;
time_string << std::setfill('0') << std::setw(2) << hours << ":";
time_string << std::setfill('0') << std::setw(2) << minutes << ":";
time_string << std::setfill('0') << std::setw(2) << seconds;
return time_string.str();
}
};
namespace xg
{
int main() {
xg::sdl sdl;
xg::window window(cfg::screen_size);
xg::renderer renderer(window);
renderer.background_color = xg::color::orange();
stats stats;
//window.hide_cursor();
try
{
{
xg::music music("resources/example.mp3");
xg::time time;
xg::text text(renderer, cfg::big_font_name, cfg::big_font_size);
xg::texture texture("resources/star.png", renderer);
texture.dimensions = v{100, 100};
texture.blend = xg::blend;
while (window.new_frame() && music.new_frame())
{
renderer.new_frame();
renderer.set_color(xg::color::blue());
time.new_frame();
stats.render(renderer, time);
texture.origin = cfg::screen_size + v{100 * cosf(time.seconds()), 100 * sinf(time.seconds())};
texture.render();
text.render(renderer, "X Graphics");
renderer.present();
}
}
}
catch (quit&)
{
}
return 0;
}
}
extern "C" int main(int argc, char *argv[])
{
return xg::main();
}