diff options
-rw-r--r-- | include/components.hpp | 22 | ||||
-rw-r--r-- | src/ui_menu.cpp | 11 | ||||
-rw-r--r-- | xml/entities.xml | 4 |
3 files changed, 29 insertions, 8 deletions
diff --git a/include/components.hpp b/include/components.hpp index be967c8..551df53 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -136,6 +136,8 @@ struct SpriteData { vec2 size; }; +using Frame = std::vector<std::pair<SpriteData, vec2>>; + //TODO /** * @struct Sprite @@ -202,14 +204,25 @@ struct Sprite { return dim; } - std::vector<std::pair<SpriteData, vec2>> sprite; + Frame sprite; bool faceLeft; }; //TODO struct Animate { - std::vector<std::pair<SpriteData, vec2>> sprite_e; - std::vector<std::pair<SpriteData, vec2>> sprite_c; + // COMMENT + std::vector<Frame> frame; + // COMMENT + std::vector<Frame>::iterator currentFrame; + + // COMMENT + Frame nextFrame() { + if (currentFrame != std::end(frame)) + currentFrame++; + else + currentFrame = std::begin(frame); + return *currentFrame; + } }; //TODO @@ -241,8 +254,6 @@ struct Dialog { bool talking; }; - - // movement styles /** @@ -262,7 +273,6 @@ struct Wander { int countdown; }; - /** * SYSTEMS */ diff --git a/src/ui_menu.cpp b/src/ui_menu.cpp index e7845c2..f6f962d 100644 --- a/src/ui_menu.cpp +++ b/src/ui_menu.cpp @@ -198,12 +198,14 @@ namespace ui { SDL_Event e; + bool clicked = false; + Render::useShader(&Render::textShader); setFontSize(24); game::config::update(); setFontZ(-9.0); - + mouse.x = ui::premouse.x+offset.x-(SCREEN_WIDTH/2); mouse.y = (offset.y+SCREEN_HEIGHT/2)-ui::premouse.y; @@ -218,6 +220,11 @@ namespace ui { premouse.x=e.motion.x; premouse.y=e.motion.y; break; + case SDL_MOUSEBUTTONUP: + if (e.button.button & SDL_BUTTON_LEFT) { + clicked = true; + } + break; case SDL_KEYUP: if (SDL_KEY == SDLK_ESCAPE) { currentMenu->gotoParent(); @@ -257,7 +264,7 @@ namespace ui { cMult = 0.6f; //if the mouse is over the button and clicks - if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) { + if (clicked) { switch(m.member) { case 0: //normal button m.button.func(); diff --git a/xml/entities.xml b/xml/entities.xml index 60b4424..d95cdc7 100644 --- a/xml/entities.xml +++ b/xml/entities.xml @@ -4,6 +4,10 @@ <Position value="0.0,100.0" /> <Visible value="0.2" /> <Sprite image="assets/NPC.png" /> + <Animation> + <frame>assets/NPC.png</frame> + <frame>assets/NPC_Walk.png</frame> + </Animation> <Direction /> <Solid /> <Physics /> |