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
- #draw ⇒ Object
-
#inside_window? ⇒ Boolean
Returns true if object is inside the game window, false if outside this special version takes @factor into consideration.
-
#outside_window? ⇒ Boolean
Returns true object is outside the game window this special version takes @factor into consideration.
- #real_x ⇒ Object
- #real_y ⇒ Object
- #retrofied_x ⇒ Object
-
#retrofied_x=(x) ⇒ Object
def setup_trait(options) @retrofy_options = => false.merge(options) super end.
- #retrofied_y ⇒ Object
- #retrofied_y=(y) ⇒ Object
Instance Method Details
#draw ⇒ Object
73 74 75 |
# File 'lib/chingu/traits/retrofy.rb', line 73 def draw self.image.draw_rot(self.screen_x, self.screen_y, self.zorder, self.angle, self.center_x, self.center_y, self.factor_x, self.factor_y, self.color, self.mode) end |
#inside_window? ⇒ Boolean
Returns true if object is inside the game window, false if outside this special version takes @factor into consideration
63 64 65 |
# File 'lib/chingu/traits/retrofy.rb', line 63 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
69 70 71 |
# File 'lib/chingu/traits/retrofy.rb', line 69 def outside_window? not inside_window? end |
#real_x ⇒ Object
45 46 47 |
# File 'lib/chingu/traits/retrofy.rb', line 45 def real_x (self.x / self.factor).to_i end |
#real_y ⇒ Object
49 50 51 |
# File 'lib/chingu/traits/retrofy.rb', line 49 def real_y (self.y / self.factor).to_i end |
#retrofied_x ⇒ Object
53 54 55 |
# File 'lib/chingu/traits/retrofy.rb', line 53 def retrofied_x (self.x * self.factor).to_i end |
#retrofied_x=(x) ⇒ Object
def setup_trait(options)
@retrofy_options = => false.merge(options)
super
end
37 38 39 |
# File 'lib/chingu/traits/retrofy.rb', line 37 def retrofied_x=(x) self.x = x / self.factor end |
#retrofied_y ⇒ Object
57 58 59 |
# File 'lib/chingu/traits/retrofy.rb', line 57 def retrofied_y (self.y * self.factor).to_i end |
#retrofied_y=(y) ⇒ Object
41 42 43 |
# File 'lib/chingu/traits/retrofy.rb', line 41 def retrofied_y=(y) self.y = y / self.factor end |