Sha256: 16843bd6311a4a7a9fad6b934f8b7f64f0bedf335c405d0112ba1661886f382b

Contents?: true

Size: 1.66 KB

Versions: 16

Compression:

Stored size: 1.66 KB

Contents

# Extend Numeric with simple angle conversion methods,
# for easier integration with Chipmunk.
class ::Numeric
  def degrees_to_radians
    self * Math::PI / 180.0
  end

  def radians_to_degrees
    self * 180.0 / Math::PI
  end

  def gosu_to_radians
    (self - 90) * Math::PI / 180.0
  end

  def radians_to_gosu
    self * 180.0 / Math::PI + 90
  end
end

# Color constants.
# This is cleaner than having SWIG define them.
module Gosu
  class ImmutableColor < Color
    private :alpha=, :red=, :green=, :blue=, :hue=, :saturation=, :value=
  end

  class Color
    NONE    = Gosu::ImmutableColor.new(0x00_000000)
    BLACK   = Gosu::ImmutableColor.new(0xff_000000)
    GRAY    = Gosu::ImmutableColor.new(0xff_808080)
    WHITE   = Gosu::ImmutableColor.new(0xff_ffffff)
    AQUA    = Gosu::ImmutableColor.new(0xff_00ffff)
    RED     = Gosu::ImmutableColor.new(0xff_ff0000)
    GREEN   = Gosu::ImmutableColor.new(0xff_00ff00)
    BLUE    = Gosu::ImmutableColor.new(0xff_0000ff)
    YELLOW  = Gosu::ImmutableColor.new(0xff_ffff00)
    FUCHSIA = Gosu::ImmutableColor.new(0xff_ff00ff)
    CYAN    = Gosu::ImmutableColor.new(0xff_00ffff)

    alias hash gl
    def eql?(other)
      gl == other.gl
    end
  end
end

class Gosu::Window
  # Call Thread.pass every tick, which may or may not be necessary for friendly co-existence with
  # Ruby's Thread class.

  alias _tick tick

  def tick
    Thread.pass
    _tick
  end
end

# Release OpenAL resources during Ruby's shutdown, not Gosu's.
at_exit do
  begin
    Gosu::Song.current_song.stop if Gosu::Song.current_song
    Gosu._release_all_openal_resources
  rescue
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
gosu-0.14.0.pre2-x64-mingw32 lib/gosu/patches.rb
gosu-0.14.0.pre2-x86-mingw32 lib/gosu/patches.rb
gosu-0.14.0.pre1-x64-mingw32 lib/gosu/patches.rb
gosu-0.14.0.pre1-x86-mingw32 lib/gosu/patches.rb
gosu-0.13.3-x64-mingw32 lib/gosu/patches.rb
gosu-0.13.3-x86-mingw32 lib/gosu/patches.rb
gosu-0.13.2-x64-mingw32 lib/gosu/patches.rb
gosu-0.13.2-x86-mingw32 lib/gosu/patches.rb
gosu-0.12.1-x64-mingw32 lib/gosu/patches.rb
gosu-0.12.1-x86-mingw32 lib/gosu/patches.rb
gosu-0.12.0-x64-mingw32 lib/gosu/patches.rb
gosu-0.12.0-x86-mingw32 lib/gosu/patches.rb
gosu-0.11.3.1-x64-mingw32 lib/gosu/patches.rb
gosu-0.11.3.1-x86-mingw32 lib/gosu/patches.rb
gosu-0.11.3-x64-mingw32 lib/gosu/patches.rb
gosu-0.11.3-x86-mingw32 lib/gosu/patches.rb