Finish basic ui binding to ruby

This commit is contained in:
2026-05-05 11:53:27 +01:00
parent a51eb903c4
commit 1b15f51e1e
10 changed files with 536 additions and 23 deletions
+13 -7
View File
@@ -1,25 +1,31 @@
App.run 400, 400, title: "Button Test"
App.run 400, 400, "Button Test"
main_scene = Scene.new
default_font = Font.new "assets/fonts/charybdis.ttf", 24, pixel_art: true
default_font = Font.new "assets/DejaVuSans.ttf", 24, italic: true
App.language = :en
App.localize(:en, :btn_text, "Click me!")
text = ElementText.new "Click me!", font: default_font, position: {x: 50, y: 50}, z: 1, click_through: true
text = ElementText.new :btn_text, default_font, position: {x: 50, y: 50}, z: 1, click_through: true
rect = ElementRect.new {x: 50, y: 50, w: 100, h: 25}, color: 0xFF0000, z: 0
rect = ElementRect.new({x: 50, y: 50, w: 100, h: 25}, 0xFF0000FF, z: 0)
rect.on_click do
rect.color = rect.color == 0xFF0000 ?
0x00FF00
rect.color = rect.color == 0xFF0000FF ?
0x00FF00FF
:
0xFF0000
0xFF0000FF
end
=begin
main_scene.update do |dt|
puts "Delta time: #{dt}ms"
end
=end
main_scene << text
main_scene << rect
# main_scene.delete(text) # Uncomment to test element deletion
App.start main_scene
+1 -1
View File
@@ -24,7 +24,7 @@ start_button = ElementText.new "Start Game", font: default_font, position: {x: 1
game_scene = Scene.new
start_button.on_click do
App.start game_scene
App.switch_to game_scene
end
menu_scene << start_button