module; #include #include export module GameObject; import Graphics; import Math; export struct Texture { using BitMap = ::Microsoft::WRL::ComPtr; BitMap bitmap; Vector2 size; Rect rect; static Texture LoadFromFile(LPCWSTR uri) { Texture tex; tex.bitmap = Graphics::LoadImageFromFile(uri); auto s = tex.bitmap->GetPixelSize(); tex.size = { (FLOAT)s.width, (FLOAT)s.height }; tex.rect = { 0.f, 0.f, tex.size.x, tex.size.y }; return tex; } }; export class GameObject { public: Texture imge; Vector2 Posi; Vector2 Anch; Vector2 Size; Rect getRect() const { 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), }; } bool isPaused = false; void Pause() { isPaused = true; } void Resume() { isPaused = false; } GameObject() {} virtual void OnStartUp() = 0; virtual void OnCleanUp() = 0; virtual void OnUpdate(float delta) = 0; virtual void OnLaterUpdate(float delta) = 0; virtual void OnReset() {} virtual void OnRender() { 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); } };