module; #include export module Steve; import GameObject; import Input; export struct Steve : GameObject { float a, v, h; bool jumping = false; enum Status { Idle, Running, Jumping, Freefall, Crawling, Dead } status; virtual void OnStartUp() override { imge = Texture::LoadFromFile(L"steve.png"); imge.rect = { 1678, 2, 1766, 96 }; Posi = { 94, 100 }; Anch = { 0.5f,0 }; Size = { 88, 94 }; a = v = h = 0.0f; } virtual void OnCleanUp() override { imge.bitmap = nullptr; } virtual void OnUpdate(float delta) override { switch (status) { case Steve::Idle: if (KeyBoard::GetKey(VK_SPACE)) status = Running; break; case Steve::Running: if (KeyBoard::GetKey(VK_SPACE)) { status = Jumping; goto _jump_; } break; case Steve::Jumping: _jump_: if ((h < 60 || KeyBoard::GetKey(VK_SPACE)) && h < 120.f) { v = 1000.f; h += v * delta; Posi.y = 100 + h; } else { status = Freefall; } break; case Steve::Freefall: a = -8000.f; v += a * delta; if (v < -1000) v = -1200; h += v * delta; Posi.y = 100 + h; if (Posi.y <= 100) { status = Running; Posi.y = 100; } break; case Steve::Crawling: break; case Steve::Dead: break; default: break; } } virtual void OnLaterUpdate(float delta) override { } };