diff --git a/GameObject.ixx b/GameObject.ixx index 680a0e9..5517880 100644 --- a/GameObject.ixx +++ b/GameObject.ixx @@ -41,9 +41,9 @@ public: return { Posi.x - Size.x * Anch.x, - Posi.y - Size.y * Anch.y, - Posi.x + Size.x * (1.f - Anch.x), Posi.y + Size.y * (1.f - Anch.y), + Posi.x + Size.x * (1.f - Anch.x), + Posi.y - Size.y * Anch.y, }; } diff --git a/MegaEngine.cpp b/MegaEngine.cpp index f99f70a..80241f2 100644 --- a/MegaEngine.cpp +++ b/MegaEngine.cpp @@ -65,12 +65,16 @@ void Game::Update() background.OnUpdate(delta); score += obs.speed * delta; score.OnUpdate(delta); - if (isIntersection(steve.getRect(), obs.getRect())) { - status = End; - steve.status = Steve::Dead; - steve.imge.rect = Steve::DeadRect; - steve.Size = steve.imge.rect.size(); + auto s_r = steve.getRect(); + auto o_r = obs.getRect(); + if (isIntersection(s_r, o_r)) + { + status = End; + steve.status = Steve::Dead; + steve.imge.rect = Steve::DeadRect; + steve.Size = steve.imge.rect.size(); + } } break; case Game::End: diff --git a/Obstacle.ixx b/Obstacle.ixx index d658c8d..948a6a7 100644 --- a/Obstacle.ixx +++ b/Obstacle.ixx @@ -29,7 +29,7 @@ export struct Obstacle : GameObject { 850,2,952,102 }, //Qradro Giant Cactus { 802,2,952,102 }, - // + // Pterosaur { 260,2,352,82 }, { 352,2,444,82 }, }; @@ -66,11 +66,11 @@ export struct Obstacle : GameObject std::mt19937 random{std::random_device()()}; void Reset() { - int index = 14;// random() % 15; + int index = random() % 15; if (index == 14) { isCactus = false; - Posi.y = 125; + Posi.y = 120; } else { diff --git a/Steve.ixx b/Steve.ixx index 3314db6..7f5f342 100644 --- a/Steve.ixx +++ b/Steve.ixx @@ -21,8 +21,8 @@ export struct Steve : GameObject static constexpr Rect LeftRect = { 1942, 2, 2030, 96 }; static constexpr Rect BigEyeRect = { 2030, 2, 2118, 96 }; static constexpr Rect DeadRect = { 2122, 2, 2202, 96 }; - static constexpr Rect CrawlingRightRect = { 2203, 2, 2321, 96 }; - static constexpr Rect CrawlingLeftRect = { 2321, 2, 2439, 96 }; + static constexpr Rect CrawlingRightRect = { 2203, 36, 2321, 96 }; + static constexpr Rect CrawlingLeftRect = { 2321, 36, 2439, 96 }; enum Status { Idle, Running, Jumping, Freefall, Crawling, Dead } status;