summaryrefslogtreecommitdiffhomepage
path: root/lib/ruby2d/camera/sprite.rb
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-08-08 02:14:53 -0400
committerrealtradam <[email protected]>2021-08-08 02:14:53 -0400
commitcad7a2876013ae52f248d7d3fd35bb6d7a2d36cb (patch)
tree7888eb2df8401feaa1426d9ca411a7e7b76cb792 /lib/ruby2d/camera/sprite.rb
parente9a05cecd41b244977c794931b4706015097774f (diff)
downloadruby2d-camera-cad7a2876013ae52f248d7d3fd35bb6d7a2d36cb.tar.gz
ruby2d-camera-cad7a2876013ae52f248d7d3fd35bb6d7a2d36cb.zip
fixed formatting and file structure
Diffstat (limited to 'lib/ruby2d/camera/sprite.rb')
-rw-r--r--lib/ruby2d/camera/sprite.rb22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/ruby2d/camera/sprite.rb b/lib/ruby2d/camera/sprite.rb
index 0d239a1..a1fb7b8 100644
--- a/lib/ruby2d/camera/sprite.rb
+++ b/lib/ruby2d/camera/sprite.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Ruby2D
module Camera
# Wraps existing variables as well as adding new methods
@@ -8,6 +9,7 @@ module Ruby2D
# Use after changing variables
def _draw
return if @hide
+
angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
@@ -22,26 +24,26 @@ module Ruby2D
temp_height = height * Camera.zoom
case @flip
when :both
- temp_x = temp_x + temp_height
- temp_y = temp_y + temp_width
+ temp_x += temp_height
+ temp_y += temp_width
temp_width = -temp_width
temp_height = -temp_height
puts 'both'
when :horizontal
- temp_y = temp_y + temp_width
+ temp_y += temp_width
temp_height = -temp_height
when :vertical
temp_width = -temp_width
- temp_x = temp_x + temp_height
+ temp_x += temp_height
end
- self.draw(x: temp_x, y: temp_y,
- width: temp_width,
- height: temp_height,
- rotate: temp_rotate)
- self.update
+ draw(x: temp_x, y: temp_y,
+ width: temp_width,
+ height: temp_height,
+ rotate: temp_rotate)
+ update
end
- def initialize(path, opts= {})
+ def initialize(path, opts = {})
super(path, opts)
Ruby2D::Camera << self
Window.remove(self)