Sha256: 742f0aec39a7aab7b3a1c5856fe562b53b10e1ea7779344e32cdbd6f1f2e43d7

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 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

module Gosu
  # Backwards compatibility: Channel was called SampleInstance before Gosu 0.13.0.
  SampleInstance = Channel
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

4 entries across 4 versions & 1 rubygems

Version Path
gosu-0.13.1-x64-mingw32 lib/gosu/patches.rb
gosu-0.13.1-x86-mingw32 lib/gosu/patches.rb
gosu-0.13.0-x64-mingw32 lib/gosu/patches.rb
gosu-0.13.0-x86-mingw32 lib/gosu/patches.rb