mouse cursor
This commit is contained in:
parent
8214786a3e
commit
df5a5979da
|
@ -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;
|
||||
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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[]) {
|
||||
|
|
Loading…
Reference in New Issue