This commit is contained in:
Squishy Bloob 2024-03-26 17:24:35 +00:00
parent 858e1463a0
commit 8214786a3e
4 changed files with 14 additions and 1 deletions

View File

@ -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;
};

View File

@ -3,7 +3,6 @@
#include <chrono>
#include <format>
#include <iostream>
#define WIN32_LEAN_AND_MEAN
#include <SDL3/SDL.h>
#include <Windows.h>
#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;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -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[]) {