Fix main loop, add example and cleanup

This commit is contained in:
2026-05-04 21:28:22 +01:00
parent 55f4b4d933
commit a51eb903c4
8 changed files with 127 additions and 128 deletions
+6 -2
View File
@@ -1,4 +1,4 @@
app = App.new 400, 400, title: "Button Test"
App.run 400, 400, title: "Button Test"
main_scene = Scene.new
@@ -15,7 +15,11 @@ rect.on_click do
0xFF0000
end
main_scene.update do |dt|
puts "Delta time: #{dt}ms"
end
main_scene << text
main_scene << rect
app.start main_scene
App.start main_scene
+9 -9
View File
@@ -5,15 +5,15 @@ width, height = 720, 480
image = Tiles.from("assets/loading.png").first
app = App.new width, height, title: "My Game", loading_bg: image # can be image or animation
App.run width, height, title: "My Game", loading_bg: image # can be image or animation
app.map_key ?w, :forward
app.map_key ?s, :backward
app.map_key ?a, :left
app.map_key ?d, :right
App.map_key ?w, :forward
App.map_key ?s, :backward
App.map_key ?a, :left
App.map_key ?d, :right
app.map_key ?h, :heal
app.map_key ?t, :place
App.map_key ?h, :heal
App.map_key ?t, :place
menu_scene = Scene.new
@@ -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.start game_scene
end
menu_scene << start_button
@@ -184,4 +184,4 @@ world.shader :fog do |shader|
z = 100 # shaders always appear above normal sprites but z is used to sort them relative to each other, so a shader with z 100 will appear above a shader with z 50, but both will appear above normal sprites
end
app.start menu_scene # first scene to show when the game starts, stops the loading bg
App.start menu_scene # first scene to show when the game starts, stops the loading bg