From 37101bf5f1ea8d65d13348aec171fadf8850a46e Mon Sep 17 00:00:00 2001 From: arngo <27396817+arngo@users.noreply.github.com> Date: Tue, 18 Jan 2022 18:36:01 -0500 Subject: web and desktop main loop --- mrblib/raylib.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'mrblib') diff --git a/mrblib/raylib.rb b/mrblib/raylib.rb index 5fd1ad7..0f542c9 100644 --- a/mrblib/raylib.rb +++ b/mrblib/raylib.rb @@ -1,12 +1,20 @@ module Raylib - #attr_accessor :main_loop + class << self + attr_accessor :main_loop - #def call_main_loop - # self.main_loop.call - #end + def while_window_open(&block) + self.main_loop = block + if Raylib.platform == 'desktop' + while !Raylib.window_should_close? do + self.main_loop.call + end + elsif Raylib.platform == 'web' + Raylib.emscripten_set_main_loop + end + end - def self.window_open(&block) - self.main_loop = block - self.execute_main_loop + def test + puts 'hello' + end end end -- cgit v1.2.3