git repos / blockattack-game

commit d4f28be2

sago007 · 2018-04-24 09:33
d4f28be28d36f12a6b1787f5883354f7fe2bb659 patch · browse files
parent fd7693a1a501abe2d36417f476c7d2a7f5366eec

Add exit button to HowTo screen

Changed files

M source/code/HelpGamepadState.cpp before
M source/code/HelpHowtoState.cpp before
M source/code/HelpHowtoState.hpp before
diff --git a/source/code/HelpGamepadState.cpp b/source/code/HelpGamepadState.cpp index a164199..7810613 100644 --- a/source/code/HelpGamepadState.cpp +++ b/source/code/HelpGamepadState.cpp
@@ -120,7 +120,7 @@ void HelpGamepadState::Draw(SDL_Renderer* target) {
}
void HelpGamepadState::Update() {
- // If the mouse button is released, make bMouseUp equal true
+ // If the mouse button is released, make bMouseUp equal true
if ( !(SDL_GetMouseState(nullptr, nullptr)&SDL_BUTTON(1)) ) {
bMouseUp=true;
}
diff --git a/source/code/HelpHowtoState.cpp b/source/code/HelpHowtoState.cpp index e2f13d6..d455b52 100644 --- a/source/code/HelpHowtoState.cpp +++ b/source/code/HelpHowtoState.cpp
@@ -26,6 +26,11 @@ https://blockattack.net
#include "common.h"
#include "MenuSystem.h"
+const int xsize = 1024;
+const int ysize = 768;
+const int buttonOffset = 160;
+extern sago::SagoSprite bExit;
+
HelpHowtoState::HelpHowtoState() {
box.SetHolder(&globalData.spriteHolder->GetDataHolder());
box.SetFontSize(30);
@@ -57,8 +62,23 @@ void HelpHowtoState::Draw(SDL_Renderer* target) {
DrawBackground(target);
box.SetMaxWidth(1000);
box.Draw(target, 10,10);
+ bExit.Draw(globalData.screen, SDL_GetTicks(), xsize-buttonOffset, ysize-buttonOffset);
}
void HelpHowtoState::Update() {
-
+ // If the mouse button is released, make bMouseUp equal true
+ if ( !(SDL_GetMouseState(nullptr, nullptr)&SDL_BUTTON(1)) ) {
+ bMouseUp=true;
+ }
+
+ if (SDL_GetMouseState(nullptr,nullptr)&SDL_BUTTON(1) && bMouseUp) {
+ bMouseUp = false;
+
+ //The Score button:
+ if ((globalData.mousex>xsize-buttonOffset) && (globalData.mousex<xsize-buttonOffset+bExit.GetWidth())
+ && (globalData.mousey>ysize-buttonOffset) && (globalData.mousey<ysize-buttonOffset+bExit.GetHeight())) {
+ isActive = false;
+ }
+
+ }
}
\ No newline at end of file
diff --git a/source/code/HelpHowtoState.hpp b/source/code/HelpHowtoState.hpp index e0954d6..6f09546 100644 --- a/source/code/HelpHowtoState.hpp +++ b/source/code/HelpHowtoState.hpp
@@ -41,6 +41,7 @@ public:
private:
bool isActive = true;
+ bool bMouseUp = true;
sago::SagoTextBox box;
};