diff --git a/blooblib/include/game.h b/blooblib/include/game.h index e671b8c..a0dd47b 100644 --- a/blooblib/include/game.h +++ b/blooblib/include/game.h @@ -4,12 +4,17 @@ #include "settings.h" struct game { + game(); + void run(); virtual void init(settings& settings); virtual void render(image& target); virtual void update(); protected: vec2i const& mouse_pos() const; + void cursor(image const* cursor); private: vec2i _mouse_pos; + image const* _cursor; + }; diff --git a/blooblib/src/game.cpp b/blooblib/src/game.cpp index 1a883be..93bb5db 100644 --- a/blooblib/src/game.cpp +++ b/blooblib/src/game.cpp @@ -18,6 +18,9 @@ LRESULT WINAPI wnd_proc(HWND window, UINT msg, WPARAM w, LPARAM l) { return ::DefWindowProc(window, msg, w, l); } +game::game() : _cursor(0) { +} + void game::run() { settings settings; init(settings); @@ -87,6 +90,8 @@ void game::run() { if(now - last_frame >= frame_duration) { update(); render(screen); + if(_cursor) + screen.draw(*_cursor, _mouse_pos); window_image.draw_upscaled(screen); BITMAPINFOHEADER bi{ sizeof(bi) }; @@ -192,3 +197,7 @@ void game::update() { vec2i const& game::mouse_pos() const { return _mouse_pos; } + +void game::cursor(image const* cursor) { + _cursor = cursor; +} diff --git a/test/test.cpp b/test/test.cpp index 0a64fb3..b0660c4 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -22,6 +22,7 @@ my_game::my_game() : void my_game::init(settings& settings) { settings.target_fps = 60; + cursor(&font['\\']); } void my_game::update() { @@ -35,7 +36,7 @@ void my_game::render(image& target) { //target.draw(img, vec2i(320, 180) + pos); //target.draw(tileset[0xda], vec2i(320, 180) + pos, 0xff00ff); target.draw("hello world!", vec2i(320, 180) + pos, font, 0xffffff, 0); - target.draw("\\", mouse_pos(), font, 0xffffff, 0); + //target.draw("\\", mouse_pos(), font, 0xffffff, 0); } int main(int argc, char* argv[]) {