diff --git a/build/BeagleRescue b/build/BeagleRescue index fbaf288..bbd7827 100755 Binary files a/build/BeagleRescue and b/build/BeagleRescue differ diff --git a/src/ecs/SpriteComponent.h b/src/ecs/SpriteComponent.h index 6aa4b25..7be28af 100644 --- a/src/ecs/SpriteComponent.h +++ b/src/ecs/SpriteComponent.h @@ -70,19 +70,21 @@ public: spriteType = sType; if(sType == spriteAnimation) { - std::string bogusPath = "src/config/credits.json"; - std::ifstream fin(bogusPath); +// std::string bogusPath = "src/config/credits.json"; +// std::ifstream fin(bogusPath); + + std::ifstream fin(json); if(fin.is_open()){ - std::cout<<"file is open"<valueint; Animation anim = Animation(fromFrame,toFrame,100); animations.emplace(name, anim); -// printf("Playing animation named: %s fromFrame:%d toFrame:%d \n",name,fromFrame,toFrame); +// printf("Adding animation named: %s fromFrame:%d toFrame:%d \n",name,fromFrame,toFrame); Play(name); } diff --git a/src/game/Collision.cpp b/src/game/Collision.cpp index b5109e6..600f8f5 100644 --- a/src/game/Collision.cpp +++ b/src/game/Collision.cpp @@ -11,15 +11,14 @@ bool Collision::AABB(const SDL_Rect& recA, const SDL_Rect& recB) { if( - recA.x + recA.w >= recB.x && - recB.x + recB.w >= recA.x && - recA.y + recA.h >= recB.y && - recB.y + recB.h >= recA.y + recA.x + recA.w > recB.x && + recB.x + recB.w > recA.x && + recA.y + recA.h > recB.y && + recB.y + recB.h > recA.y ) - { + { return true; } - return false; } @@ -28,6 +27,10 @@ bool Collision::AABB(const ColliderComponent& colA, const ColliderComponent& col if(AABB(colA.collider, colB.collider)) { // std::cout << colA.tag << " hit: " << colB.tag << std::endl; +// if(recA.x + recA.w >= recB.x) { printf("LeftCollision"); } +// if(recB.x + recB.w >= recA.x) { printf("RightCollision"); } +// if(recA.y + recA.h >= recB.y) { printf("TopCollision"); } +// if(recB.y + recB.h >= recA.y) { printf("BottomCollision"); } return true; } else diff --git a/src/game/Collision.h b/src/game/Collision.h index 0fe14d0..b64aef7 100644 --- a/src/game/Collision.h +++ b/src/game/Collision.h @@ -9,6 +9,7 @@ #define SRC_COLLISION_H_ #include +// #include "Vector2D.h" class ColliderComponent; @@ -17,6 +18,7 @@ class Collision public: static bool AABB(const SDL_Rect& recA, const SDL_Rect& recB); static bool AABB(const ColliderComponent& colA, const ColliderComponent& colB); +// void showColType(); }; diff --git a/src/game/Game.cpp b/src/game/Game.cpp index 75def6d..529281d 100644 --- a/src/game/Game.cpp +++ b/src/game/Game.cpp @@ -121,7 +121,8 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g map = new Map("terrain",globalScale,16); - std::string myText = "Find lost puppies!\nThey need your help!"; +// std::string myText = "Find lost puppies!\nThey need your help!"; + std::string myText = "Press U to Start"; text = new UIText(myText, "font", 0, 0, 8, 12, globalScale); text->ParseString(myText, 12, 22, globalScale, "text"); @@ -230,7 +231,9 @@ void Game::update() SDL_Rect cCol = c->getComponent().collider; if(Collision::AABB(cCol, playerCol)) { -// printf("Collision detected!\nplayerIsGrounded:%d if 0: idle plays\n",playerIsGrounded); +// printDebug("Collision Detected"); +// printf("Collision Stats:\nPlayer Center\nx: %d\ny: %d\nObjectCollider Center\nx: %d\ny: %d\n",(playerCol.x+playerCol.w/2)/gScale,(playerCol.y+playerCol.h/2)/gScale,(cCol.x+cCol.w/2)/gScale,(cCol.y+cCol.h/2)/gScale); +// printDebug(""); if(!playerIsGrounded){ player.getComponent().Play("Idle"); } @@ -324,10 +327,16 @@ void Game::clean() printf("Game Cleaned\n"); } -void Game::printDebug(char* debugInfo) +std::string previousMessage = ""; + +void Game::printDebug(std::string debugInfo) { - printf("%s",debugInfo); - printf("\n"); + if (previousMessage != debugInfo) + { + std::cout << debugInfo; + printf("\n"); + } + previousMessage = debugInfo; } void Game::drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blue) diff --git a/src/game/Game.hpp b/src/game/Game.hpp index b463bb4..5176e0c 100644 --- a/src/game/Game.hpp +++ b/src/game/Game.hpp @@ -29,7 +29,7 @@ public: void update(); void render(); void clean(); - void printDebug(char* debugInfo); + void printDebug(std::string debugInfo); static void drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blue); bool running() { return isRunning; } // static void AddTile(int srcX, int srcY, int xpos, int ypos);