Class: Gosu::Image

Inherits:
Object
  • Object
show all
Includes:
Chingu::NamedResource
Defined in:
lib/chingu/assets.rb,
lib/chingu/core_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Chingu::NamedResource

included, #name, #name=

Class Method Details

.autoload(name) ⇒ Object



28
29
30
# File 'lib/chingu/assets.rb', line 28

def self.autoload(name)
  (path = find_file(name)) ? Gosu::Image.new($window, path, true) : nil
end

Instance Method Details

#retrofyObject

Retrofy should be called just after the image is loaded. When retrofied an image will use a non-blurry zoom. This could be used to make each pixel a sharp 4 pixelblock => retrofeeling.



47
48
49
50
51
52
# File 'lib/chingu/core_extensions.rb', line 47

def retrofy
  glBindTexture(GL_TEXTURE_2D, self.gl_tex_info.tex_name)
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
  self
end

#transparent_pixel?(x, y) ⇒ Boolean

Returns true if the pixel at x, y is 100% transperant (good for collisiondetection) Requires texplay

Returns:

  • (Boolean)


34
35
36
37
38
39
40
# File 'lib/chingu/core_extensions.rb', line 34

def transparent_pixel?(x, y)
  begin
    self.get_pixel(x,y)[3] == 0
  rescue
    puts "Error in get_pixel at x/y: #{x}/#{y}"
  end
end