mouse handling refact
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -355,14 +355,9 @@ function MinigameDDRWindow.update()
|
||||
right = Input.right()
|
||||
}
|
||||
|
||||
if Mouse.clicked() then
|
||||
local mx = Mouse.x()
|
||||
local my = Mouse.y()
|
||||
for _, target in ipairs(mg.target_arrows) do
|
||||
if mx >= target.x and mx < target.x + mg.arrow_size and
|
||||
my >= mg.target_y and my < mg.target_y + mg.arrow_size then
|
||||
input_map[target.dir] = true
|
||||
end
|
||||
for _, target in ipairs(mg.target_arrows) do
|
||||
if Mouse.zone({ x = target.x, y = mg.target_y, w = mg.arrow_size, h = mg.arrow_size }) then
|
||||
input_map[target.dir] = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -83,12 +83,7 @@ function MinigameButtonMashWindow.update()
|
||||
return
|
||||
end
|
||||
|
||||
local mouse_on_button = false
|
||||
if Mouse.clicked() then
|
||||
local dx = Mouse.x() - mg.button_x
|
||||
local dy = Mouse.y() - mg.button_y
|
||||
mouse_on_button = (dx * dx + dy * dy) <= (mg.button_size * mg.button_size)
|
||||
end
|
||||
local mouse_on_button = Mouse.zone_circle({ x = mg.button_x, y = mg.button_y, r = mg.button_size })
|
||||
|
||||
if Input.select() or mouse_on_button then
|
||||
Audio.sfx_drum_high()
|
||||
|
||||
@@ -95,12 +95,7 @@ function MinigameRhythmWindow.update()
|
||||
if mg.press_cooldown > 0 then
|
||||
mg.press_cooldown = mg.press_cooldown - 1
|
||||
end
|
||||
local mouse_on_button = false
|
||||
if Mouse.clicked() then
|
||||
local dx = Mouse.x() - mg.button_x
|
||||
local dy = Mouse.y() - mg.button_y
|
||||
mouse_on_button = (dx * dx + dy * dy) <= (mg.button_size * mg.button_size)
|
||||
end
|
||||
local mouse_on_button = Mouse.zone_circle({ x = mg.button_x, y = mg.button_y, r = mg.button_size })
|
||||
|
||||
if (Input.select() or mouse_on_button) and mg.press_cooldown == 0 then
|
||||
mg.button_pressed_timer = mg.button_press_duration
|
||||
|
||||
Reference in New Issue
Block a user