diff --git a/data/AUTH b/data/AUTH index e79bcc5..e98f7a9 100644 --- a/data/AUTH +++ b/data/AUTH @@ -6,4 +6,5 @@ Poul Sander's files are multi licensed under "GPL v2 or later" OR "CC-BY-SA any background_sixteen_nine.png Poul Sander (based of qubodup's background.png) fallback.png Poul Sander mouse.png Poul Sander - +gui_back_white.png Derived from UI pack by Kenney Vleugels (www.kenney.nl) (CC0 license) +gui_back_yellow.png Derived from UI pack by Kenney Vleugels (www.kenney.nl) (CC0 license) diff --git a/data/sprites/gui_rect_white.sprite b/data/sprites/gui_rect_white.sprite new file mode 100644 index 0000000..e551532 --- /dev/null +++ b/data/sprites/gui_rect_white.sprite @@ -0,0 +1,75 @@ +{ + +"ui_rect_white_nw" : { + "texture" : "gui_back_white", + "topx" : 0, + "topy" : 0, + "height" : 32, + "width" : 32 +}, + +"ui_rect_white_n" : { + "texture" : "gui_back_white", + "topx" : 32, + "topy" : 0, + "height" : 32, + "width" : 32 +}, + +"ui_rect_white_ne" : { + "texture" : "gui_back_white", + "topx" : 160, + "topy" : 0, + "height" : 32, + "width" : 32 +}, + +"ui_rect_white_e" : { + "texture" : "gui_back_white", + "topx" : 160, + "topy" : 32, + "height" : 32, + "width" : 32 +}, + +"ui_rect_white_se" : { + "texture" : "gui_back_white", + "topx" : 160, + "topy" : 160, + "height" : 32, + "width" : 32 +}, + +"ui_rect_white_s" : { + "texture" : "gui_back_white", + "topx" : 32, + "topy" : 160, + "height" : 32, + "width" : 32 +}, + +"ui_rect_white_sw" : { + "texture" : "gui_back_white", + "topx" : 0, + "topy" : 160, + "height" : 32, + "width" : 32 +}, + +"ui_rect_white_w" : { + "texture" : "gui_back_white", + "topx" : 0, + "topy" : 32, + "height" : 32, + "width" : 32 +}, + +"ui_rect_white_fill" : { + "texture" : "gui_back_white", + "topx" : 32, + "topy" : 32, + "height" : 32, + "width" : 32 +} + +} diff --git a/data/sprites/gui_rect_yellow.sprite b/data/sprites/gui_rect_yellow.sprite new file mode 100644 index 0000000..22c33bd --- /dev/null +++ b/data/sprites/gui_rect_yellow.sprite @@ -0,0 +1,75 @@ +{ + +"ui_rect_yellow_nw" : { + "texture" : "gui_back_yellow", + "topx" : 0, + "topy" : 0, + "height" : 32, + "width" : 32 +}, + +"ui_rect_yellow_n" : { + "texture" : "gui_back_yellow", + "topx" : 32, + "topy" : 0, + "height" : 32, + "width" : 32 +}, + +"ui_rect_yellow_ne" : { + "texture" : "gui_back_yellow", + "topx" : 160, + "topy" : 0, + "height" : 32, + "width" : 32 +}, + +"ui_rect_yellow_e" : { + "texture" : "gui_back_yellow", + "topx" : 160, + "topy" : 32, + "height" : 32, + "width" : 32 +}, + +"ui_rect_yellow_se" : { + "texture" : "gui_back_yellow", + "topx" : 160, + "topy" : 160, + "height" : 32, + "width" : 32 +}, + +"ui_rect_yellow_s" : { + "texture" : "gui_back_yellow", + "topx" : 32, + "topy" : 160, + "height" : 32, + "width" : 32 +}, + +"ui_rect_yellow_sw" : { + "texture" : "gui_back_yellow", + "topx" : 0, + "topy" : 160, + "height" : 32, + "width" : 32 +}, + +"ui_rect_yellow_w" : { + "texture" : "gui_back_yellow", + "topx" : 0, + "topy" : 32, + "height" : 32, + "width" : 32 +}, + +"ui_rect_yellow_fill" : { + "texture" : "gui_back_yellow", + "topx" : 32, + "topy" : 32, + "height" : 32, + "width" : 32 +} + +} diff --git a/data/textures/gui_back_white.png b/data/textures/gui_back_white.png new file mode 100644 index 0000000..0368709 Binary files /dev/null and b/data/textures/gui_back_white.png differ diff --git a/data/textures/gui_back_yellow.png b/data/textures/gui_back_yellow.png new file mode 100644 index 0000000..538eb7d Binary files /dev/null and b/data/textures/gui_back_yellow.png differ diff --git a/src/MainGameState.cpp b/src/MainGameState.cpp index e226714..d17d12b 100644 --- a/src/MainGameState.cpp +++ b/src/MainGameState.cpp @@ -22,6 +22,8 @@ https://github.com/sago007/saland */ #include "MainGameState.hpp" +#include +#include "globals.hpp" MainGameState::MainGameState() { } @@ -39,10 +41,50 @@ void MainGameState::ProcessInput(const SDL_Event& event, bool &processed) { } void MainGameState::Draw(SDL_Renderer* target) { - + DrawRectYellow(target, 5, 5, 200, 200); } void MainGameState::Update() { +} + + +static void DrawRect(SDL_Renderer* target, int topx, int topy, int height, int width, const std::string& name) { + const int size = 32; + SDL_Rect bounds_ns = {topx, topy+size, width, height-2*size}; //bounds for south + SDL_Rect bounds_e = {topx, topy, width-size, height}; + const sago::SagoSprite& n = globalData.spriteHolder->GetSprite(name+"n"); + const sago::SagoSprite& s = globalData.spriteHolder->GetSprite(name+"s"); + const sago::SagoSprite& e = globalData.spriteHolder->GetSprite(name+"e"); + const sago::SagoSprite& w = globalData.spriteHolder->GetSprite(name+"w"); + const sago::SagoSprite& fill = globalData.spriteHolder->GetSprite(name+"fill"); + for (int i = 1; i < width/size; ++i) { + n.DrawBounded(target, SDL_GetTicks(), topx+i*size, topy, bounds_e); + for (int j = 1; j < height/size; ++j) { + w.DrawBounded(target, SDL_GetTicks(), topx, topy+j*size, bounds_ns); + fill.Draw(target, SDL_GetTicks(),topx+i*size, topy+j*size); + e.DrawBounded(target, SDL_GetTicks(), topx+width-size, topy+j*size, bounds_ns); + } + s.DrawBounded(target, SDL_GetTicks(), topx+i*size, topy+height-size, bounds_e); + } + //Corners + const sago::SagoSprite& nw = globalData.spriteHolder->GetSprite(name+"nw"); + const sago::SagoSprite& ne = globalData.spriteHolder->GetSprite(name+"ne"); + const sago::SagoSprite& se = globalData.spriteHolder->GetSprite(name+"se"); + const sago::SagoSprite& sw = globalData.spriteHolder->GetSprite(name+"sw"); + nw.Draw(target, SDL_GetTicks(), topx, topy); + ne.Draw(target, SDL_GetTicks(), topx+width-size, topy); + se.Draw(target, SDL_GetTicks(), topx+width-size, topy+height-size); + sw.Draw(target, SDL_GetTicks(), topx, topy+height-size); +} + +void DrawRectWhite(SDL_Renderer* target, int topx, int topy, int height, int width) { + std::string name = "ui_rect_white_"; + DrawRect(target, topx, topy, height, width, name); +} + +void DrawRectYellow(SDL_Renderer* target, int topx, int topy, int height, int width) { + std::string name = "ui_rect_yellow_"; + DrawRect(target, topx, topy, height, width, name); } \ No newline at end of file diff --git a/src/MainGameState.hpp b/src/MainGameState.hpp index 19cfe54..132764e 100644 --- a/src/MainGameState.hpp +++ b/src/MainGameState.hpp @@ -41,5 +41,8 @@ private: bool isActive = true; }; +void DrawRectWhite(SDL_Renderer* target, int topx, int topy, int height, int width); +void DrawRectYellow(SDL_Renderer* target, int topx, int topy, int height, int width); + #endif /* MAINGAMESTATE_HPP */