diff --git a/build/BeagleRescue b/build/BeagleRescue index 50a8bf7..de25c6a 100755 Binary files a/build/BeagleRescue and b/build/BeagleRescue differ diff --git a/src/config/config.json b/src/config/config.json index 7185755..c8a053d 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -1,7 +1,7 @@ { "GameName":"Beagle Rescue", "WindowName":"Beagle Rescue", -"WindowSize":{"w":320,"h":240}, +"WindowSize":{"w":640,"h":360}, "WindowFullScreen": 0, -"GlobalScale": 1 +"GlobalScale": 3 } diff --git a/src/ecs/KeyboardController.h b/src/ecs/KeyboardController.h index 9cd314e..eae4f2d 100644 --- a/src/ecs/KeyboardController.h +++ b/src/ecs/KeyboardController.h @@ -78,6 +78,24 @@ public: sprite->spriteFlip = SDL_FLIP_HORIZONTAL; } break; + case SDLK_a: + if(Game::gsm->currentState == GameStateManager::ST_COREGAME){ + transform->velocity.x = -1; + if(Game::playerIsGrounded){ + sprite->Play("Walk"); + } + sprite->spriteFlip = SDL_FLIP_NONE; + } + break; + case SDLK_d: + if(Game::gsm->currentState == GameStateManager::ST_COREGAME){ + transform->velocity.x = 1; + if(Game::playerIsGrounded){ + sprite->Play("Walk"); + } + sprite->spriteFlip = SDL_FLIP_HORIZONTAL; + } + break; case SDLK_k: if (!Game::debugCollisionBoxes) { Game::debugCollisionBoxes = true; } @@ -129,7 +147,7 @@ public: } } break; - case SDLK_RIGHT: + case SDLK_RIGHT: if(Game::gsm->currentState == GameStateManager::ST_COREGAME){ transform->velocity.x = 0; sprite->Play("Idle"); @@ -138,6 +156,25 @@ public: } } break; + case SDLK_a: + if(Game::gsm->currentState == GameStateManager::ST_COREGAME){ + transform->velocity.x = 0; + sprite->Play("Idle"); + if (!Game::gravityOnPlayer){ + Game::gravityOnPlayer = true; + // sprite->Play("Fall"); + } + } + break; + case SDLK_d: + if(Game::gsm->currentState == GameStateManager::ST_COREGAME){ + transform->velocity.x = 0; + sprite->Play("Idle"); + if (!Game::gravityOnPlayer){ + Game::gravityOnPlayer = true; + } + } + break; case SDLK_k: break; case SDLK_j: @@ -151,13 +188,13 @@ public: break; case SDLK_i: break; - case SDLK_d: - if (Game::debugMenu == false){ - Game::debugMenu = true;} - else { - Game::debugMenu = false; - } - break; +// case SDLK_d: +// if (Game::debugMenu == false){ +// Game::debugMenu = true;} +// else { +// Game::debugMenu = false; +// } +// break; case SDLK_ESCAPE: // exit the game when Escape pressed Game::isRunning = false; break; diff --git a/src/game/Game.cpp b/src/game/Game.cpp index 07d15a3..9c915f6 100644 --- a/src/game/Game.cpp +++ b/src/game/Game.cpp @@ -31,6 +31,7 @@ UINineSlice* scoreboard9Slice; UINineSlice* debugBox; UIText* debugStaticText; UIText* debugdynamicText; +UIText* debugJumpText; GameStateManager* Game::gsm = new GameStateManager(); @@ -64,6 +65,16 @@ int last_time; int current_time; int diff_time; +std::string Game::BoolToString(bool b) { + std::string myString; + if (b) { + myString = "true"; + } else { + myString = "false"; + } + return myString; +} + Game::Game() { // TODO Auto-generated constructor stub @@ -146,7 +157,9 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g UIText* debugStaticText4; UIText* debugStaticText5; UIText* debugStaticText6; - UIText* debugStaticText7; + UIText* debugStaticText7; + + std::string debugStaticString = "Collision"; debugStaticText = new UIText(debugStaticString, "font", 0,0,8,12,1); debugStaticText->ParseString(debugStaticString,220*globalScale,14*gScale,1,"debug",Game::groupUI_Layer3); @@ -169,6 +182,9 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g debugStaticText7 = new UIText(debugStaticString7, "font", 0,0,8,12,1); debugStaticText7->ParseString(debugStaticString7,220*globalScale,74*gScale,1,"debug",Game::groupUI_Layer3); + debugJumpText = new UIText(Game::BoolToString(playerIsJumping), "font", 0,0,8,12,1); + debugJumpText->ParseString(Game::BoolToString(playerIsJumping),260*globalScale,44*gScale,1,"debugJumpText",Game::groupUI_Layer3); + // debug UI box SDL_Rect debugBoxRect = SDL_Rect(); debugBoxRect.x = 220*globalScale; @@ -259,6 +275,15 @@ void Game::update() // Mix_PlayChannel(-1, Game::assets->GetSoundClip("bark1"),0); // } + +// for (auto& letter : debugText) +// { +// if(letter->tag=="debugJumpText"){ +// std::cout<tag<ParseString(Game::BoolToString(playerIsJumping),260*gScale,44*gScale,1,"debugJumpText",Game::groupUI_Layer3); + manager.refresh(); manager.update(); @@ -407,3 +432,4 @@ void Game::drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blu SDL_SetRenderDrawColor(renderer, red, green, blue, 255); SDL_RenderDrawLine(renderer, srcpt.x, srcpt.y, destpt.x, destpt.y); } + diff --git a/src/game/Game.hpp b/src/game/Game.hpp index c49b69b..2d775b4 100644 --- a/src/game/Game.hpp +++ b/src/game/Game.hpp @@ -45,6 +45,7 @@ public: static SDL_Rect camera; static AssetManager* assets; static GameStateManager* gsm; + std::string BoolToString(bool b); enum groupLabels : std::size_t { groupMap, diff --git a/src/ui/UIText.cpp b/src/ui/UIText.cpp index 3bff468..b5d34f3 100644 --- a/src/ui/UIText.cpp +++ b/src/ui/UIText.cpp @@ -65,3 +65,9 @@ void UIText::AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrS letter.setTag(tag); letter.addGroup(groupLabel); } + +void UIText::RemoveAllLetters() +{ + manager.getEntitiesByTag(""); +} + diff --git a/src/ui/UIText.h b/src/ui/UIText.h index daa4481..4577734 100644 --- a/src/ui/UIText.h +++ b/src/ui/UIText.h @@ -26,6 +26,8 @@ public: void AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrScale, Game::groupLabels groupLabel); void ParseString(std::string inputText, int x, int y, int letterScale, std::string tag, Game::groupLabels group); + void RemoveAllLetters(); + void UpdateString(std::string newInputText); int scale; };