2024-11-10 19:03:01 -06:00
|
|
|
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
2024-11-13 11:03:31 -06:00
|
|
|
render := @use("../../../libraries/render/src/lib.hb")
|
2024-11-14 18:09:54 -06:00
|
|
|
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
2024-11-10 12:57:48 -06:00
|
|
|
|
|
|
|
main := fn(): void {
|
2024-11-13 11:03:31 -06:00
|
|
|
screen := render.init(true)
|
2024-11-11 15:48:43 -06:00
|
|
|
sunset.server.start()
|
2024-11-14 18:09:54 -06:00
|
|
|
render.clear(screen, render.black)
|
|
|
|
|
|
|
|
mouse_x := 0
|
|
|
|
mouse_y := 0
|
|
|
|
|
|
|
|
loop {
|
|
|
|
mouse_event := intouch.recieve_mouse_event()
|
|
|
|
if mouse_event != null {
|
|
|
|
change_x := @as(i16, mouse_event.x_change)
|
|
|
|
change_x = change_x << 8
|
|
|
|
change_x = change_x >> 8
|
|
|
|
|
|
|
|
mouse_x += change_x
|
|
|
|
if mouse_x < 0 {
|
|
|
|
mouse_x = 0
|
|
|
|
}
|
|
|
|
if mouse_x >= screen.width - 20 {
|
|
|
|
mouse_x = @intcast(screen.width - 21)
|
|
|
|
}
|
|
|
|
|
|
|
|
change_y := @as(i16, mouse_event.y_change)
|
|
|
|
change_y = change_y << 8
|
|
|
|
change_y = change_y >> 8
|
|
|
|
|
|
|
|
if mouse_y < 0 {
|
|
|
|
mouse_y = 0
|
|
|
|
}
|
|
|
|
if mouse_y >= screen.height - 20 {
|
|
|
|
mouse_y = @intcast(screen.height - 21)
|
|
|
|
}
|
|
|
|
mouse_y -= change_y
|
|
|
|
|
|
|
|
if mouse_event.left {
|
|
|
|
// set_label_text(text_label, "LEFT CLICK\0")
|
|
|
|
}
|
|
|
|
if mouse_event.middle {
|
|
|
|
// set_label_text(text_label, "MIDDLE CLICK\0")
|
|
|
|
}
|
|
|
|
if mouse_event.right {
|
|
|
|
// set_label_text(text_label, "RIGHT CLICK\0")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// render.clear(screen, render.black)
|
|
|
|
}
|
|
|
|
|
|
|
|
if sunset.server.incoming() {
|
|
|
|
// render.clear(screen, render.black)
|
|
|
|
//
|
|
|
|
sunset.server.collect_frames()
|
|
|
|
sunset.server.render_clients(screen)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mouse cursor
|
|
|
|
{
|
|
|
|
render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black)
|
|
|
|
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
|
|
|
}
|
|
|
|
|
|
|
|
render.sync(screen)
|
2024-11-10 12:57:48 -06:00
|
|
|
}
|
|
|
|
}
|