summaryrefslogtreecommitdiffhomepage
path: root/lib/ruby2d/camera/line.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/line.rb
parente9a05cecd41b244977c794931b4706015097774f (diff)
downloadruby2d-camera-cad7a2876013ae52f248d7d3fd35bb6d7a2d36cb.tar.gz
ruby2d-camera-cad7a2876013ae52f248d7d3fd35bb6d7a2d36cb.zip
fixed formatting and file structure
Diffstat (limited to 'lib/ruby2d/camera/line.rb')
-rw-r--r--lib/ruby2d/camera/line.rb32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/ruby2d/camera/line.rb b/lib/ruby2d/camera/line.rb
index 9113b92..f6d8f03 100644
--- a/lib/ruby2d/camera/line.rb
+++ b/lib/ruby2d/camera/line.rb
@@ -9,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
@@ -18,22 +19,23 @@ module Ruby2D
temp_y2 = (((x + @x2 - Camera.x) * Math.sin(angle)) + ((y + @y2 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
temp_width = width * Camera.zoom
Ruby2D::Line.draw(x1: temp_x1, y1: temp_y1,
- x2: temp_x2, y2: temp_y2,
- width: temp_width,
- color: [
- [self.color.r, self.color.g, self.color.b, self.color.a],
- [self.color.r, self.color.g, self.color.b, self.color.a],
- [self.color.r, self.color.g, self.color.b, self.color.a],
- [self.color.r, self.color.g, self.color.b, self.color.a]
- ],
- z: self.z)
+ x2: temp_x2, y2: temp_y2,
+ width: temp_width,
+ color: [
+ [color.r, color.g, color.b, color.a],
+ [color.r, color.g, color.b, color.a],
+ [color.r, color.g, color.b, color.a],
+ [color.r, color.g, color.b, color.a]
+ ],
+ z: z)
end
- def initialize(opts= {})
+ def initialize(opts = {})
super(opts)
Ruby2D::Camera << self
Window.remove(self)
end
+
def remove
@hide = true
end
@@ -42,22 +44,16 @@ module Ruby2D
@hide = false
end
- #Methods for moving the shape
+ # Methods for moving the shape
def x
@x ||= 0
end
- def x=(x)
- @x = x
- end
+ attr_writer :x, :y
def y
@y ||= 0
end
-
- def y=(y)
- @y = y
- end
end
end
end