hud cursor coordinates

This commit is contained in:
2025-08-04 21:29:33 -05:00
parent 07595aad63
commit faf19db27e
3 changed files with 9 additions and 3 deletions

View File

@@ -53,7 +53,7 @@ clay.contain = layout.contain;
clay.draw = function draw(fn)
{
var size = [prosperon.logical.x, prosperon.logical.y]
var size = [prosperon.logical.width, prosperon.logical.height]
lay_ctx.reset();
boxes = [];
var root = lay_ctx.item();

View File

@@ -10,7 +10,10 @@ var clay_input = {}
// boxes: array of box objects from clay.draw()
// mousepos: {x, y} position to test
// prev_state: previous input state for tracking changes
clay_input.hit = function hit(boxes, mousepos, prev_state = {}) {
clay_input.hit = function hit(boxes, mouse, prev_state = {}) {
var mousepos = {...mouse}
mousepos.x *= 640
mousepos.y *= 360
var hovered = null
var clicked = null

View File

@@ -529,8 +529,11 @@ function poll_input() {
event.key = input.keyname(event.key)
}
if (event.type.startsWith('mouse_') && event.pos && event.pos.y)
if (event.type.startsWith('mouse_') && event.pos && event.pos.y) {
event.pos.y = -event.pos.y + win_size.height
event.pos.y /= win_size.height
event.pos.x /= win_size.width
}
filteredEvents.push(event)
}