Improve loop with fps control
This commit is contained in:
+8
-4
@@ -1,4 +1,4 @@
|
||||
App.run 720, 480, "Button Test"
|
||||
App.run 720, 480, "Button Test", fps: 24
|
||||
|
||||
main_scene = Scene.new
|
||||
|
||||
@@ -14,7 +14,7 @@ App.localize(:en, :btn_text, "Click %{name}!")
|
||||
|
||||
text = ElementText.new :btn_text, default_font, 0xFFFF00, {name: "Me"}, position: {x: 50, y: 50}, z: 1, click_through: true, alpha: 1
|
||||
|
||||
rect = ElementRect.new 100, 25, 0xFF0000, position: {x: 50, y: 50}, z: 0, rotation: 60, pivot: {x: 0.5, y: 0.5}, scale: { x: 1, y: 1 }, alpha: 0.4
|
||||
rect = ElementRect.new 100, 25, 0xFF0000, position: {x: 50, y: 50}, z: 0, rotation: 60, scale: { x: 1, y: 1 }, alpha: 0.4
|
||||
|
||||
image_element = ElementImage.new bg_animation, position: {x: 0, y: 0}, z: -1, click_through: true, alpha: 1
|
||||
|
||||
@@ -49,7 +49,7 @@ main_scene.on_update do |delta_time|
|
||||
|
||||
pp App.text_input if App.text_input != ""
|
||||
|
||||
next unless App.down?(:press)
|
||||
next unless App.pressed?(:press)
|
||||
|
||||
pp "#{App.pressed?(:press)}, #{App.down?(:press)}, #{App.released?(:press)}"
|
||||
|
||||
@@ -72,6 +72,10 @@ main_scene.delete(text)
|
||||
|
||||
App.start main_scene
|
||||
|
||||
time = Time.now - start
|
||||
|
||||
p "Average delta time: #{c_ / c_c}s"
|
||||
p "Time since start (real): #{Time.now - start}s"
|
||||
p "Average FPS (real): #{c_c / time}s"
|
||||
p "Average FPS (from dt): #{c_c / c_}"
|
||||
p "Time since start (real): #{time}s"
|
||||
p "Time since start (from dt): #{c_}s"
|
||||
Reference in New Issue
Block a user