diff options
-rw-r--r-- | application.cpp | 40 | ||||
-rw-r--r-- | config.h | 16 | ||||
-rw-r--r-- | player.cpp | 4 | ||||
-rw-r--r-- | textures/background.png | bin | 13359 -> 18092 bytes |
4 files changed, 33 insertions, 27 deletions
diff --git a/application.cpp b/application.cpp index ebf412d..2ef8e79 100644 --- a/application.cpp +++ b/application.cpp @@ -203,25 +203,26 @@ void Application::main_loop(unsigned int tick, unsigned int step) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0, Config::window_w, 0, Config::window_h, 0, 10); + float xo = float(Config::window_w)/float(Config::window_h)/2.5 - 0.5; + glOrtho(-xo, 1 + xo, 0, 0.8, 0, 10); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, background->tex()); glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2i(0, 0); glTexCoord2f(0, 1); - glVertex2i(0, Config::window_h); - glTexCoord2f(1, 1); - glVertex2i(Config::window_w, Config::window_h); + glVertex2f(-1.9/9.0, 0); + glTexCoord2f(0, 0); + glVertex2f(-1.9/9.0, 0.8); glTexCoord2f(1, 0); - glVertex2i(Config::window_w, 0); + glVertex2f(10.9/9.0, 0.8); + glTexCoord2f(1, 1); + glVertex2f(10.9/9.0, 0); glEnd(); glDisable(GL_TEXTURE_2D); - glColor4f(0, 0, 0, 1); + glColor4f(1, 1, 0, 1); char s[0xff]; @@ -236,12 +237,17 @@ void Application::main_loop(unsigned int tick, unsigned int step) { glRasterPos2f(Config::fps_x, Config::fps_y); font->Render(s); + float v_x = Config::window_w * (Config::viewport_x + xo) / (1 + 2 * xo); + float v_y = Config::window_h * Config::viewport_y; + float v_w = Config::window_h * Config::viewport_w; + float v_h = Config::window_h * Config::viewport_h; + glViewport( - Config::viewport_x - Config::viewport_overscan, - Config::viewport_y - Config::viewport_overscan, - Config::viewport_w + Config::viewport_overscan * 2, - Config::viewport_h + Config::viewport_overscan * 2); - glScissor(Config::viewport_x, Config::viewport_y, Config::viewport_w, Config::viewport_h); + v_x - Config::viewport_overscan, + v_y - Config::viewport_overscan, + v_w + Config::viewport_overscan * 2, + v_h + Config::viewport_overscan * 2); + glScissor(v_x, v_y, v_w, v_h); glEnable(GL_SCISSOR_TEST); glClearColor(0.2, 0.2, 0.2, 0); @@ -277,10 +283,10 @@ void Application::main_loop(unsigned int tick, unsigned int step) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho( - -float(Config::viewport_overscan) / float(Config::viewport_w), - 1.0 + float(Config::viewport_overscan) / float(Config::viewport_w), - -float(Config::viewport_overscan) / float(Config::viewport_w), - Config::viewport_aspect + float(Config::viewport_overscan) / float(Config::viewport_w), + -float(Config::viewport_overscan) / float(v_w), + 1.0 + float(Config::viewport_overscan) / float(v_w), + -float(Config::viewport_overscan) / float(v_w), + Config::viewport_aspect + float(Config::viewport_overscan) / float(v_w), 0, 10); glMatrixMode(GL_MODELVIEW); @@ -2,20 +2,20 @@ #define CONFIG_H namespace Config { - const unsigned int window_w = 1920; - const unsigned int window_h = 1080; + const unsigned int window_w = 1280; + const unsigned int window_h = 800; - const unsigned int viewport_x = 300; - const unsigned int viewport_y = 15; - const unsigned int viewport_w = 900; - const unsigned int viewport_h = 1050; + const float viewport_x = 15.0 / 1080.0; + const float viewport_y = 15.0 / 1080.0; + const float viewport_w = 900.0 / 1080.0; + const float viewport_h = 1050.0 / 1080.0; const unsigned int viewport_overscan = 10; const float viewport_aspect = float(viewport_h) / float(viewport_w); - const unsigned int fps_x = 1; - const unsigned int fps_y = 1; + const float fps_x = 0.0; + const float fps_y = 0.0; }; #endif @@ -44,6 +44,6 @@ void Player::update() { y_speed /= sqrtf(2); } - x = fmaxf(fminf(x + x_speed, 1.0 - 16.0 / Config::viewport_w), 16.0 / Config::viewport_w); - y = fmaxf(fminf(y + y_speed, Config::viewport_aspect - 16.0 / Config::viewport_h), 16.0 / Config::viewport_h); + x = fmaxf(fminf(x + x_speed, 1.0 - 0.018), 0.018); + y = fmaxf(fminf(y + y_speed, Config::viewport_aspect - 0.018), 0.018); } diff --git a/textures/background.png b/textures/background.png Binary files differindex a97cc05..c7c0f8d 100644 --- a/textures/background.png +++ b/textures/background.png |