Refactor input handling: replace hardcoded key inputs with configurable key bindings for character movement, inventory navigation, and actions; enhance settings scene with key rebind functionality and add credits scene.
This commit is contained in:
+3
-3
@@ -35,12 +35,12 @@ class HealthBar
|
||||
|
||||
def draw
|
||||
# Draw the background of the health bar (red)
|
||||
Gosu.draw_rect(SCREEN_SIZE[0] - 100 - 10, 180, 100, 10, Gosu::Color::RED)
|
||||
Gosu.draw_rect(SCREEN_SIZE[0] - 100 - 10, 180, 100, 10, Gosu::Color::RED, Float::INFINITY)
|
||||
|
||||
# Draw the foreground of the health bar (green) based on current health
|
||||
health_width = (health.to_f / max_health) * 100
|
||||
Gosu.draw_rect(SCREEN_SIZE[0] - 100 - 10, 180, health_width, 10, Gosu::Color::GREEN)
|
||||
Gosu.draw_rect(SCREEN_SIZE[0] - 100 - 10, 180, health_width, 10, Gosu::Color::GREEN, Float::INFINITY)
|
||||
|
||||
@heart_image.draw(SCREEN_SIZE[0] - 100 - 20, 173, 1, 1.5, 1.5)
|
||||
@heart_image.draw(SCREEN_SIZE[0] - 100 - 20, 173, Float::INFINITY, 1.5, 1.5)
|
||||
end
|
||||
end
|
||||
@@ -94,19 +94,19 @@ class Inventory
|
||||
when Gosu::KB_1 then @inventory_selected = :occams_razor
|
||||
when Gosu::KB_2 then @inventory_selected = :quantum_bow
|
||||
when Gosu::KB_3 then @inventory_selected = :blade_of_recursion
|
||||
when Gosu::KB_DOWN
|
||||
when $bus.get(:settings, :"inventory down")
|
||||
row, col = find_slot(@inventory_selected)
|
||||
@inventory_selected = @grid[(row + 1) % @grid.size][col][0]
|
||||
when Gosu::KB_UP
|
||||
when $bus.get(:settings, :"inventory up")
|
||||
row, col = find_slot(@inventory_selected)
|
||||
@inventory_selected = @grid[(row - 1) % @grid.size][col][0]
|
||||
when Gosu::KB_LEFT
|
||||
when $bus.get(:settings, :"inventory left")
|
||||
row, col = find_slot(@inventory_selected)
|
||||
@inventory_selected = @grid[row][(col - 1) % @grid[row].size][0]
|
||||
when Gosu::KB_RIGHT
|
||||
when $bus.get(:settings, :"inventory right")
|
||||
row, col = find_slot(@inventory_selected)
|
||||
@inventory_selected = @grid[row][(col + 1) % @grid[row].size][0]
|
||||
when Gosu::KB_RETURN
|
||||
when $bus.get(:settings, :craft)
|
||||
craft(@inventory_selected, ctrl: Gosu.button_down?(Gosu::KB_RIGHT_CONTROL) || Gosu.button_down?(Gosu::KB_LEFT_CONTROL))
|
||||
else
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user