Advertisement
Guest User

Mouse fix

a guest
Feb 26th, 2015
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.73 KB | None | 0 0
  1.   #--------------------------------------------------------------------------
  2.   # * Mouse Grid Position
  3.   #--------------------------------------------------------------------------
  4.   def self.grid
  5.     return nil if @pos.nil?
  6.     mx, my = SceneManager.scene.instance_variable_get(:@spriteset).tilemap_offset
  7.  
  8.     x = (@pos[0] + mx) / 32
  9.     y = (@pos[1] + my) / 32    
  10.    
  11.     #fix for widescreen resolutions
  12.     x = (@pos[0] - (Graphics.width  - ($game_map.width * 32)) / 2) /
  13.                                 32 if ($game_map.width * 32) < Graphics.width
  14.     y = (@pos[1] - (Graphics.height - ($game_map.height * 32)) / 2) /
  15.                                 32 if ($game_map.height * 32) < Graphics.height
  16.     return [x, y]
  17.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement