From 8d5c566d17fa719b8b940b5cbb468eb16a176c86 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Sat, 29 Sep 2018 17:45:36 -0700 Subject: Build for WebAssembly, first pass --- lib/ruby2d/image.rb | 6 ++---- lib/ruby2d/music.rb | 6 ++---- lib/ruby2d/sound.rb | 6 ++---- lib/ruby2d/sprite.rb | 8 +++----- lib/ruby2d/text.rb | 6 ++---- lib/ruby2d/window.rb | 6 ++---- 6 files changed, 13 insertions(+), 25 deletions(-) (limited to 'lib') diff --git a/lib/ruby2d/image.rb b/lib/ruby2d/image.rb index 9386f6b..2ee9ef3 100644 --- a/lib/ruby2d/image.rb +++ b/lib/ruby2d/image.rb @@ -10,10 +10,8 @@ module Ruby2D def initialize(opts = {}) @path = opts[:path] - unless RUBY_ENGINE == 'opal' - unless File.exists? @path - raise Error, "Cannot find image file `#{@path}`" - end + unless File.exists? @path + raise Error, "Cannot find image file `#{@path}`" end @x = opts[:x] || 0 diff --git a/lib/ruby2d/music.rb b/lib/ruby2d/music.rb index 41b8901..b9fa8ad 100644 --- a/lib/ruby2d/music.rb +++ b/lib/ruby2d/music.rb @@ -8,10 +8,8 @@ module Ruby2D def initialize(path) - unless RUBY_ENGINE == 'opal' - unless File.exists? path - raise Error, "Cannot find audio file `#{path}`" - end + unless File.exists? path + raise Error, "Cannot find audio file `#{path}`" end @path = path diff --git a/lib/ruby2d/sound.rb b/lib/ruby2d/sound.rb index c1d4060..07043a9 100644 --- a/lib/ruby2d/sound.rb +++ b/lib/ruby2d/sound.rb @@ -8,10 +8,8 @@ module Ruby2D def initialize(path) - unless RUBY_ENGINE == 'opal' - unless File.exists? path - raise Error, "Cannot find audio file `#{path}`" - end + unless File.exists? path + raise Error, "Cannot find audio file `#{path}`" end @path = path diff --git a/lib/ruby2d/sprite.rb b/lib/ruby2d/sprite.rb index a00617f..934fac7 100644 --- a/lib/ruby2d/sprite.rb +++ b/lib/ruby2d/sprite.rb @@ -9,11 +9,9 @@ module Ruby2D def initialize(path, opts = {}) - # Check if sprite file exists, unless running on the web - unless RUBY_ENGINE == 'opal' - unless File.exists? path - raise Error, "Cannot find sprite image file `#{path}`" - end + # Check if sprite file exists + unless File.exists? path + raise Error, "Cannot find sprite image file `#{path}`" end # Sprite image file path diff --git a/lib/ruby2d/text.rb b/lib/ruby2d/text.rb index 1b2207d..4d1d74c 100644 --- a/lib/ruby2d/text.rb +++ b/lib/ruby2d/text.rb @@ -16,10 +16,8 @@ module Ruby2D @rotate = opts[:rotate] || 0 @font = opts[:font] - unless RUBY_ENGINE == 'opal' - unless File.exists? @font - raise Error, "Cannot find font file `#{@font}`" - end + unless File.exists? @font + raise Error, "Cannot find font file `#{@font}`" end self.color = opts[:color] || 'white' diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb index 5b0b7cb..c610d0f 100644 --- a/lib/ruby2d/window.rb +++ b/lib/ruby2d/window.rb @@ -320,10 +320,8 @@ module Ruby2D # Add controller mappings from file def add_controller_mappings - unless RUBY_ENGINE == 'opal' - if File.exists? @controller_mappings - ext_add_controller_mappings(@controller_mappings) - end + if File.exists? @controller_mappings + ext_add_controller_mappings(@controller_mappings) end end -- cgit v1.2.3