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.
- #screen_height ⇒ Object
- #screen_width ⇒ Object
- #screen_x ⇒ Object
- #screen_y ⇒ Object
- #setup_trait(options) ⇒ Object
Instance Method Details
#draw ⇒ Object
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
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
61 62 63 |
# File 'lib/chingu/traits/retrofy.rb', line 61 def outside_window? not inside_window? end |
#screen_height ⇒ Object
41 42 43 |
# File 'lib/chingu/traits/retrofy.rb', line 41 def screen_height (self.image.heigt * self.factor).to_i end |
#screen_width ⇒ Object
37 38 39 |
# File 'lib/chingu/traits/retrofy.rb', line 37 def screen_width (self.image.width * self.factor).to_i end |
#screen_x ⇒ Object
45 46 47 |
# File 'lib/chingu/traits/retrofy.rb', line 45 def screen_x (self.x * self.factor).to_i end |
#screen_y ⇒ Object
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() @retrofy_options = {:debug => false}.merge() super end |