Class | Joyau::Viewport |
In: |
ruby/site_ruby/joyau/viewport.rb
|
Parent: | Joyau::Drawable |
When writing game, we might have to think about hero’s position, obstacle’s position, … but this can be confusing.
When a viewport is drawed, it’s object are moved, drawed, and then, their moves are cancelled. So, you can think about the position in the world without considering the PSP’s screen.
objects | [R] |
Converts an aboslute position (given as a point) to a relative position.
# File ruby/site_ruby/joyau/viewport.rb, line 63 def abs2rel(point) return Point.new(point.x - self.x, point.y - self.y) end
Centers the view on point, which is relative to the view.
# File ruby/site_ruby/joyau/viewport.rb, line 77 def center_on(point) p = rel2abs(point) move(240 - p.x, 136 - p.y) end