summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTom Black <[email protected]>2015-12-25 23:18:53 -0600
committerTom Black <[email protected]>2015-12-25 23:18:53 -0600
commitcbfce01bce4bd082b238a378bb11868e76b4a6d6 (patch)
treeebf8739fa6dd8d72332f1e8a12223627a47840d0
parent4b4ceac1d95773f8c054cd04e287af9f65c29dec (diff)
downloadruby2d-cbfce01bce4bd082b238a378bb11868e76b4a6d6.tar.gz
ruby2d-cbfce01bce4bd082b238a378bb11868e76b4a6d6.zip
Store frame rate
-rw-r--r--ext/ruby2d/ruby2d.c3
-rw-r--r--lib/ruby2d/window.rb3
2 files changed, 6 insertions, 0 deletions
diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c
index 0681e27..965f863 100644
--- a/ext/ruby2d/ruby2d.c
+++ b/ext/ruby2d/ruby2d.c
@@ -112,6 +112,9 @@ void update() {
rb_iv_set(self, "@mouse_x", INT2NUM(window->mouse.x));
rb_iv_set(self, "@mouse_y", INT2NUM(window->mouse.y));
+ // Store frame rate
+ rb_iv_set(self, "@fps", INT2NUM(window->fps));
+
// Call update proc, `window.update`
rb_funcall(self, rb_intern("update_callback"), 0);
}
diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb
index a56e8d5..3f5dd1a 100644
--- a/lib/ruby2d/window.rb
+++ b/lib/ruby2d/window.rb
@@ -8,6 +8,7 @@ module Ruby2D
@width, @height, @title = width, height, title
@mouse_x = @mouse_y = 0
@fps_cap = fps
+ @fps = 0
@vsync = vsync
@objects = []
@@ -27,6 +28,8 @@ module Ruby2D
return @width
when :height
return @height
+ when :fps
+ return @fps
when :mouse_x
return @mouse_x
when :mouse_y