Class: Kawaii::Camera
- Inherits:
-
Object
- Object
- Kawaii::Camera
- Defined in:
- lib/kawaii/camera.rb
Instance Method Summary collapse
-
#initialize(game) ⇒ Camera
constructor
A new instance of Camera.
- #move(x, y) ⇒ Object
- #translate(&block) ⇒ Object
Constructor Details
Instance Method Details
#move(x, y) ⇒ Object
12 13 14 15 16 |
# File 'lib/kawaii/camera.rb', line 12 def move x, y @destination.x, @destination.y = x - @origin.x, y - @origin.y @pos.x = Kawaii::lerp(@pos.x, @destination.x, @speed) @pos.y = Kawaii::lerp(@pos.y, @destination.y, @speed) end |
#translate(&block) ⇒ Object
18 19 20 21 22 |
# File 'lib/kawaii/camera.rb', line 18 def translate(&block) @game.translate(@pos.x, @pos.y) do block.call() end end |