Fix Pterosaur.

This commit is contained in:
革匊习习中 2022-08-06 00:47:11 +08:00
parent 7b1b5feaff
commit da1a8d4a6f
4 changed files with 16 additions and 12 deletions

View File

@ -41,9 +41,9 @@ public:
return return
{ {
Posi.x - Size.x * Anch.x, 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.y + Size.y * (1.f - Anch.y),
Posi.x + Size.x * (1.f - Anch.x),
Posi.y - Size.y * Anch.y,
}; };
} }

View File

@ -65,12 +65,16 @@ void Game::Update()
background.OnUpdate(delta); background.OnUpdate(delta);
score += obs.speed * delta; score += obs.speed * delta;
score.OnUpdate(delta); score.OnUpdate(delta);
if (isIntersection(steve.getRect(), obs.getRect()))
{ {
status = End; auto s_r = steve.getRect();
steve.status = Steve::Dead; auto o_r = obs.getRect();
steve.imge.rect = Steve::DeadRect; if (isIntersection(s_r, o_r))
steve.Size = steve.imge.rect.size(); {
status = End;
steve.status = Steve::Dead;
steve.imge.rect = Steve::DeadRect;
steve.Size = steve.imge.rect.size();
}
} }
break; break;
case Game::End: case Game::End:

View File

@ -29,7 +29,7 @@ export struct Obstacle : GameObject
{ 850,2,952,102 }, { 850,2,952,102 },
//Qradro Giant Cactus //Qradro Giant Cactus
{ 802,2,952,102 }, { 802,2,952,102 },
// // Pterosaur
{ 260,2,352,82 }, { 260,2,352,82 },
{ 352,2,444,82 }, { 352,2,444,82 },
}; };
@ -66,11 +66,11 @@ export struct Obstacle : GameObject
std::mt19937 random{std::random_device()()}; std::mt19937 random{std::random_device()()};
void Reset() void Reset()
{ {
int index = 14;// random() % 15; int index = random() % 15;
if (index == 14) if (index == 14)
{ {
isCactus = false; isCactus = false;
Posi.y = 125; Posi.y = 120;
} }
else else
{ {

View File

@ -21,8 +21,8 @@ export struct Steve : GameObject
static constexpr Rect LeftRect = { 1942, 2, 2030, 96 }; static constexpr Rect LeftRect = { 1942, 2, 2030, 96 };
static constexpr Rect BigEyeRect = { 2030, 2, 2118, 96 }; static constexpr Rect BigEyeRect = { 2030, 2, 2118, 96 };
static constexpr Rect DeadRect = { 2122, 2, 2202, 96 }; static constexpr Rect DeadRect = { 2122, 2, 2202, 96 };
static constexpr Rect CrawlingRightRect = { 2203, 2, 2321, 96 }; static constexpr Rect CrawlingRightRect = { 2203, 36, 2321, 96 };
static constexpr Rect CrawlingLeftRect = { 2321, 2, 2439, 96 }; static constexpr Rect CrawlingLeftRect = { 2321, 36, 2439, 96 };
enum Status { Idle, Running, Jumping, Freefall, Crawling, Dead } status; enum Status { Idle, Running, Jumping, Freefall, Crawling, Dead } status;