From 8214786a3efdb1101799f47c7f9a0cef6f7c879d Mon Sep 17 00:00:00 2001 From: squishy Date: Tue, 26 Mar 2024 17:24:35 +0000 Subject: [PATCH] mouse --- blooblib/include/game.h | 4 ++++ blooblib/src/game.cpp | 10 +++++++++- test/habbo.png | Bin 1191 -> 1201 bytes test/test.cpp | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/blooblib/include/game.h b/blooblib/include/game.h index 7156e38..e671b8c 100644 --- a/blooblib/include/game.h +++ b/blooblib/include/game.h @@ -8,4 +8,8 @@ struct game { virtual void init(settings& settings); virtual void render(image& target); virtual void update(); +protected: + vec2i const& mouse_pos() const; +private: + vec2i _mouse_pos; }; diff --git a/blooblib/src/game.cpp b/blooblib/src/game.cpp index c75a1c6..1a883be 100644 --- a/blooblib/src/game.cpp +++ b/blooblib/src/game.cpp @@ -3,7 +3,6 @@ #include #include #include -#define WIN32_LEAN_AND_MEAN #include #include #include "image.h" @@ -47,6 +46,7 @@ void game::run() { ); ShowWindow(window, SW_SHOWNORMAL); + ShowCursor(FALSE); auto window_image = image(settings.size * settings.scale); auto screen = image(settings.size); @@ -70,6 +70,10 @@ void game::run() { case WM_QUIT: running = false; break; + case WM_MOUSEMOVE: + _mouse_pos.x = LOWORD(msg.lParam) / settings.scale; + _mouse_pos.y = HIWORD(msg.lParam) / settings.scale; + break; } } @@ -184,3 +188,7 @@ void game::render(image& target) { void game::update() { } + +vec2i const& game::mouse_pos() const { + return _mouse_pos; +} diff --git a/test/habbo.png b/test/habbo.png index ee3d8f36d3f0b218798cd79cac187d3c6514e667..aef1f6d873c88ff48435260acdcd548dc0cab226 100644 GIT binary patch delta 1168 zcmV;B1aJGN39$)~F@I}GL_t(|ob6j}a^oNjB|Ce(+^1*geR4nVk6rJmFYoCCaO||a znU1j#LVyrLPTRI^TQk_-6`jGW8?Co>kxoiZhR%4R`Wbz^E4?yz5xuHMZ@a70kM8fg z^l>$NsrFl4_bbh3uZ*m}xZ<9#*!sKJtff`Pd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GbFb|(u9;@vmc#&~Rh_!(&ZP0RL=vFQC>#m2_Q#>U3R#uWSk X(|H;c0JS{600000NkvXXu0mjfkn>bW diff --git a/test/test.cpp b/test/test.cpp index 584374e..0a64fb3 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -35,6 +35,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); } int main(int argc, char* argv[]) {