Module: Chingu::Traits::Retrofy

Defined in:
lib/chingu/traits/retrofy.rb

Overview

A chingu trait providing easier handling of the “retrofy” effect (non-blurry zoom) Aims to help out when using scaling with “factor” to create a retrofeeling with big pixels. Provides screen_x and screen_y which takes the scaling into account Also provides new code for draw() which uses screen_x / screen_y instead of x / y

Instance Method Summary collapse

Instance Method Details

#drawObject



65
66
67
# File 'lib/chingu/traits/retrofy.rb', line 65

def draw
  @image.draw_rot(self.screen_x, self.screen_y, @zorder, @angle, @center_x, @center_y, @factor_x, @factor_y, @color, @mode)
end

#inside_window?Boolean

Returns true if object is inside the game window, false if outside this special version takes @factor into consideration

Returns:

  • (Boolean)


55
56
57
# File 'lib/chingu/traits/retrofy.rb', line 55

def inside_window?
  self.x >= 0 && self.x <= $window.width/self.factor && self.y >= 0 && self.y <= $window.height/self.factor
end

#outside_window?Boolean

Returns true object is outside the game window this special version takes @factor into consideration

Returns:

  • (Boolean)


61
62
63
# File 'lib/chingu/traits/retrofy.rb', line 61

def outside_window?
  not inside_window?
end

#screen_heightObject



41
42
43
# File 'lib/chingu/traits/retrofy.rb', line 41

def screen_height
  (self.image.heigt * self.factor).to_i
end

#screen_widthObject



37
38
39
# File 'lib/chingu/traits/retrofy.rb', line 37

def screen_width
  (self.image.width * self.factor).to_i
end

#screen_xObject



45
46
47
# File 'lib/chingu/traits/retrofy.rb', line 45

def screen_x
  (self.x * self.factor).to_i
end

#screen_yObject



49
50
51
# File 'lib/chingu/traits/retrofy.rb', line 49

def screen_y
  (self.y * self.factor).to_i
end

#setup_trait(options) ⇒ Object



32
33
34
35
# File 'lib/chingu/traits/retrofy.rb', line 32

def setup_trait(options)
  @retrofy_options = {:debug => false}.merge(options)        
  super
end