diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-10-20 08:00:57 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-10-20 08:00:57 -0400 |
commit | 563d978b4ba721370441eaaca3f8471ec383deff (patch) | |
tree | 268b04a1fdfec2ce92512722ef2d0a8b74e3659a | |
parent | d79f4a7f4b5aff5931ef86edd2537ef5e3620fd4 (diff) |
arrow rotation and actual pausing
-rw-r--r-- | assets/items/arrow_crude.png | bin | 222 -> 217 bytes | |||
-rw-r--r-- | include/gametime.hpp | 3 | ||||
-rw-r--r-- | src/gametime.cpp | 11 | ||||
-rw-r--r-- | src/systems/render.cpp | 4 | ||||
-rw-r--r-- | src/ui.cpp | 177 | ||||
-rw-r--r-- | src/ui_menu.cpp | 4 |
6 files changed, 21 insertions, 178 deletions
diff --git a/assets/items/arrow_crude.png b/assets/items/arrow_crude.png Binary files differindex 5fba709..6b9a636 100644 --- a/assets/items/arrow_crude.png +++ b/assets/items/arrow_crude.png diff --git a/include/gametime.hpp b/include/gametime.hpp index e06a0d3..7999f1c 100644 --- a/include/gametime.hpp +++ b/include/gametime.hpp @@ -7,6 +7,9 @@ namespace game { namespace time { + void togglePause(void); + void togglePause(bool state); + /** * Sets the game's tick count to the desired amount. * @param t desired tick count diff --git a/src/gametime.cpp b/src/gametime.cpp index a5272e5..6f6ac0e 100644 --- a/src/gametime.cpp +++ b/src/gametime.cpp @@ -5,9 +5,18 @@ static unsigned int tickCount = 0; static unsigned int deltaTime = 1; +static bool paused = false; namespace game { namespace time { + void togglePause(void) { + paused ^= true; + } + + void togglePause(bool state) { + paused = state; + } + void setTickCount(unsigned int t) { tickCount = t; } @@ -17,7 +26,7 @@ namespace game { } unsigned int getDeltaTime(void) { - return (deltaTime > 0) ? deltaTime : 1; + return paused ? 0 : ((deltaTime > 0) ? deltaTime : 1); } void tick(void) { diff --git a/src/systems/render.cpp b/src/systems/render.cpp index a25b152..f72832b 100644 --- a/src/systems/render.cpp +++ b/src/systems/render.cpp @@ -78,7 +78,9 @@ void RenderSystem::render(void) if (S.first.veltate) { auto vel = entity.component<Direction>(); - float angle = static_cast<float>(std::atan(vel->y / vel->x)) * 180 / 3.14f; + float angle = std::atan(vel->y / vel->x); + if (vel->x < 0) + angle += 3.14f; auto toOrigin = glm::translate(glm::mat4(1.0f), glm::vec3(-pos.x, -pos.y, 0.0f)); auto rotation = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 0.0f, 1.0f)); auto toBack = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, pos.y, 0.0f)); @@ -169,41 +169,6 @@ namespace ui { return ret; } - /*void importantText(const char *text, ...) { - va_list args; - - dialogBoxText.clear(); - - va_start(args, text); - auto s = uisprintf(text, args); - va_end(args); - - dialogBoxText = s; - - dialogBoxExists = true; - dialogImportant = true; - dialogPassive = false; - dialogPassiveTime = 0; - } - - void passiveImportantText(int duration, const char *text, ...) { - va_list args; - - dialogBoxText.clear(); - - va_start(args, text); - auto s = uisprintf(text, args); - va_end(args); - - dialogBoxText = s; - - dialogBoxExists = true; - dialogImportant = true; - dialogPassive = true; - dialogPassiveTime = duration; - }*/ - - void drawPage(const GLuint& tex) { pageTex = tex; pageTexReady = true; @@ -401,147 +366,7 @@ namespace ui { Render::textShader.disable(); Render::textShader.unuse(); - } /* else if (dialogBoxExists) { - rtext = typeOut(dialogBoxText); - - if (dialogImportant) { - setFontColor(255, 255, 255); - if (dialogPassive) { - dialogPassiveTime -= game::time::getDeltaTime() * 12; - if (dialogPassiveTime < 0) { - dialogPassive = false; - dialogImportant = false; - dialogBoxExists = false; - } - } - - *if (fadeIntensity == 255 || dialogPassive) { - setFontSize(24); - putStringCentered(offset.x,offset.y,rtext); - setFontSize(16); - }* - } else { //normal dialog box - - float y = offset.y + SCREEN_HEIGHT / 2 - HLINES(8); - float x = offset.x - 300; - - drawNiceBox(vec2 {x, y}, vec2 {x + 600, y - SCREEN_HEIGHT / 4}, -7.0); - - setFontZ(-7.2f); - rtext = typeOut(dialogBoxText); - UISystem::putString(vec2(x + HLINES(2), y - fontSize - game::HLINE), rtext); - - for (i = 0; i < dialogOptText.size(); i++) { - auto& sec = dialogOptText[i].second; - - setFontColor(255, 255, 255); - auto tmp = putStringCentered(offset.x, sec.y,dialogOptText[i].first); - sec.z = offset.x + tmp; - sec.x = offset.x - tmp; - sec.y = y - SCREEN_HEIGHT / 4 + (fontSize + game::HLINE) * (i + 1); - if (mouse.x > sec.x && mouse.x < sec.z && - mouse.y > sec.y && mouse.y < sec.y + 16) { // fontSize - setFontColor(255, 255, 0); - putStringCentered(offset.x, sec.y, dialogOptText[i].first); - } - } - - setFontColor(255, 255, 255); - } - - static unsigned int rtext_oldsize = 0; - if (rtext_oldsize != rtext.size()) { - if (!isspace(rtext[(rtext_oldsize = rtext.size()) - 1])) - Mix_PlayChannel(0, dialogClick, 0); - - } - - } else { - for (const auto &s : textToDraw) - putString(s.first.x, s.first.y, s.second); - }*/ - - //if (!fadeIntensity) { - /*vec2 hub = { - (SCREEN_WIDTH/2+offset.x)-fontSize*10, - (offset.y+SCREEN_HEIGHT/2)-fontSize - };*/ - - /*putText(hub.x,hub.y,"Health: %u/%u",player->health>0?(unsigned)player->health:0, - (unsigned)player->maxHealth - );*/ - /*static GLuint frontHealth = Texture::genColor(Color(255,0,0)); - static GLuint backHealth = Texture::genColor(Color(150,0,0)); - - if (player->isAlive()) { - hub.y-=fontSize*1.15; - - GLfloat tex[] = {0.0, 0.0, - 1.0, 0.0, - 0.0, 1.0, - 1.0, 1.0}; - - GLfloat back[] = {hub.x, hub.y, -7.0, - hub.x + 150, hub.y, -7.0, - hub.x, hub.y + 12, -7.0, - hub.x + 150, hub.y + 12, -7.0}; - - GLfloat front[] = {hub.x, hub.y, -7.1, - hub.x + 150, hub.y, -7.1, - hub.x, hub.y + 12, -7.1, - hub.x + 150, hub.y + 12, -7.1}; - - - glUniform1i(Render::textShader.uniform[WU_texture], 0); - - Render::textShader.use(); - Render::textShader.enable(); - - glBindTexture(GL_TEXTURE_2D, frontHealth); - - glVertexAttribPointer(Render::textShader.coord, 3, GL_FLOAT, GL_FALSE, 0, front); - glVertexAttribPointer(Render::textShader.tex, 2, GL_FLOAT, GL_FALSE, 0, tex); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - glBindTexture(GL_TEXTURE_2D, backHealth); - - glVertexAttribPointer(Render::textShader.coord, 3, GL_FLOAT, GL_FALSE, 0, back); - glVertexAttribPointer(Render::textShader.tex, 2, GL_FLOAT, GL_FALSE, 0, tex); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - Render::textShader.disable(); - Render::textShader.unuse(); - }*/ - - /* - * Lists all of the quests the player is currently taking. - */ - - /*setFontColor(255,255,255,fontTransInv); - if (player->inv->invOpen) { - hub.y = player->loc.y + fontSize * 8; - hub.x = player->loc.x;// + player->width / 2; - - putStringCentered(hub.x,hub.y,"Current Quests:"); - - for(auto &c : player->qh.current) { - hub.y -= fontSize * 1.15; - putStringCentered(hub.x,hub.y,c.title); - } - - hub.y = offset.y + 40*1.2; - hub.x = offset.x + SCREEN_WIDTH/2 - 40*1.5; - - putStringCentered(hub.x,hub.y,"Equipment:"); - - hub.y = offset.y + SCREEN_HEIGHT/2 - 20; - hub.x = offset.x - SCREEN_WIDTH/2 + 45*4*1.5; - - putStringCentered(hub.x,hub.y,"Inventory:"); - }*/ - // setFontColor(255,255,255,255); - //} - + } menu::draw(); // draw the mouse diff --git a/src/ui_menu.cpp b/src/ui_menu.cpp index 3afe0dc..052030a 100644 --- a/src/ui_menu.cpp +++ b/src/ui_menu.cpp @@ -3,6 +3,7 @@ #include <common.hpp> #include <engine.hpp> #include <fileio.hpp> +#include <gametime.hpp> #include <render.hpp> #include <texture.hpp> #include <font.hpp> @@ -56,6 +57,7 @@ void Menu::gotoParent(void) if (parent == nullptr) { game::config::update(); FontSystem::setFontSize(FontSystem::SizeSmall); + game::time::togglePause(false); } currentMenu = parent; @@ -241,6 +243,8 @@ namespace ui { void toggle(void) { currentMenu = &pauseMenu; + if (currentMenu != nullptr) + game::time::togglePause(true); } void draw(void) { |