22 lines
494 B
C++
22 lines
494 B
C++
|
#include "Mouse.h"
|
||
|
|
||
|
Mouse::Mouse(ui::Canvas& screen)
|
||
|
{
|
||
|
m_position.x = screen.width / 2;
|
||
|
m_position.y = screen.height / 2;
|
||
|
m_screen_rect = screen.rect();
|
||
|
}
|
||
|
|
||
|
void Mouse::draw(ui::Canvas& screen)
|
||
|
{
|
||
|
auto canvas = screen.subcanvas(m_position, 10, 10, true).release_value();
|
||
|
canvas.fill(ui::WHITE);
|
||
|
}
|
||
|
|
||
|
void Mouse::move(const moon::MousePacket& packet)
|
||
|
{
|
||
|
m_position.x += packet.xdelta;
|
||
|
m_position.y -= packet.ydelta;
|
||
|
m_position = m_screen_rect.normalize(m_position);
|
||
|
}
|