module; export module BackGround; import GameObject; import Graphics; export struct BackGround : GameObject { static constexpr Rect GroundRect{ 2,104,2402,130 }; static constexpr Rect CloudRect{ 166,2,258,29 }; float speed = -500.f; Vector2 CloudPosi; virtual void OnStartUp() { imge.rect = GroundRect; Posi = { 0,50 }; CloudPosi = { 1050,200 }; Size = imge.rect.size(); } virtual void OnCleanUp() { } virtual void OnUpdate(float delta) { Posi.x += speed * delta; CloudPosi.x += speed * delta * 0.5f; } virtual void OnLaterUpdate(float delta) { if (Posi.x <= -Size.x) { Posi.x += Size.x; } if (CloudPosi.x <= 0 - CloudRect.size().x) { CloudPosi.x = 1050; } } virtual void OnReset() override { Posi.x = 0; } virtual void OnRender() override { Rect dst = { Posi.x - Size.x * Anch.x, Posi.y + Size.y * (1.f - Anch.y), Posi.x + Size.x * (1.f - Anch.x), Posi.y - Size.y * Anch.y, }; Graphics::DrawBitMap(imge.bitmap, dst, imge.rect); dst.left += Size.x; dst.right += Size.x; Graphics::DrawBitMap(imge.bitmap, dst, imge.rect); auto cloud_size = CloudRect.size(); Rect cloud_dst = { CloudPosi.x, CloudPosi.y + cloud_size.y, CloudPosi.x + cloud_size.x, CloudPosi.y, }; Graphics::DrawBitMap(imge.bitmap, dst, CloudRect); } };