mouse
This commit is contained in:
parent
858e1463a0
commit
8214786a3e
|
@ -8,4 +8,8 @@ struct game {
|
||||||
virtual void init(settings& settings);
|
virtual void init(settings& settings);
|
||||||
virtual void render(image& target);
|
virtual void render(image& target);
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
protected:
|
||||||
|
vec2i const& mouse_pos() const;
|
||||||
|
private:
|
||||||
|
vec2i _mouse_pos;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
@ -47,6 +46,7 @@ void game::run() {
|
||||||
);
|
);
|
||||||
|
|
||||||
ShowWindow(window, SW_SHOWNORMAL);
|
ShowWindow(window, SW_SHOWNORMAL);
|
||||||
|
ShowCursor(FALSE);
|
||||||
|
|
||||||
auto window_image = image(settings.size * settings.scale);
|
auto window_image = image(settings.size * settings.scale);
|
||||||
auto screen = image(settings.size);
|
auto screen = image(settings.size);
|
||||||
|
@ -70,6 +70,10 @@ void game::run() {
|
||||||
case WM_QUIT:
|
case WM_QUIT:
|
||||||
running = false;
|
running = false;
|
||||||
break;
|
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() {
|
void game::update() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec2i const& game::mouse_pos() const {
|
||||||
|
return _mouse_pos;
|
||||||
|
}
|
||||||
|
|
BIN
test/habbo.png
BIN
test/habbo.png
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
@ -35,6 +35,7 @@ void my_game::render(image& target) {
|
||||||
//target.draw(img, vec2i(320, 180) + pos);
|
//target.draw(img, vec2i(320, 180) + pos);
|
||||||
//target.draw(tileset[0xda], vec2i(320, 180) + pos, 0xff00ff);
|
//target.draw(tileset[0xda], vec2i(320, 180) + pos, 0xff00ff);
|
||||||
target.draw("hello world!", vec2i(320, 180) + pos, font, 0xffffff, 0);
|
target.draw("hello world!", vec2i(320, 180) + pos, font, 0xffffff, 0);
|
||||||
|
target.draw("\\", mouse_pos(), font, 0xffffff, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|
Loading…
Reference in New Issue