summaryrefslogtreecommitdiffhomepage
path: root/lib/camera/wrappers/triangle_wrapper.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/camera/wrappers/triangle_wrapper.rb
parente9a05cecd41b244977c794931b4706015097774f (diff)
downloadruby2d-camera-cad7a2876013ae52f248d7d3fd35bb6d7a2d36cb.tar.gz
ruby2d-camera-cad7a2876013ae52f248d7d3fd35bb6d7a2d36cb.zip
fixed formatting and file structure
Diffstat (limited to 'lib/camera/wrappers/triangle_wrapper.rb')
-rw-r--r--lib/camera/wrappers/triangle_wrapper.rb90
1 files changed, 0 insertions, 90 deletions
diff --git a/lib/camera/wrappers/triangle_wrapper.rb b/lib/camera/wrappers/triangle_wrapper.rb
deleted file mode 100644
index 0aba2c0..0000000
--- a/lib/camera/wrappers/triangle_wrapper.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-# frozen_string_literal: true
-
-module Camera
-# Wraps existing variables as well as adding new methods
-# so that it can be handled by the Camera Module
- module TriangleWrapped
- # Recalculates real coordiantes
- # Use after changing variables
- def redraw
- angle = Camera.angle * (Math::PI / 180)
- half_width = Window.width * 0.5
- half_height = Window.height * 0.5
- @x1 = (((x + x1 - Camera.x) * Math.cos(angle)) - ((y + y1 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
- @y1 = (((x + x1 - Camera.x) * Math.sin(angle)) + ((y + y1 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
- @x2 = (((x + x2 - Camera.x) * Math.cos(angle)) - ((y + y2 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
- @y2 = (((x + x2 - Camera.x) * Math.sin(angle)) + ((y + y2 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
- @x3 = (((x + x3 - Camera.x) * Math.cos(angle)) - ((y + y3 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
- @y3 = (((x + x3 - Camera.x) * Math.sin(angle)) + ((y + y3 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
- end
-
- #Methods for moving the shape
- def x
- @x ||= 0
- end
-
- def x=(x)
- @x = x
- end
-
- def y
- @y ||= 0
- end
-
- def y=(y)
- @y = y
- end
-
- # Wrappers for the coordinates so that
- # they are handled by the Camera instead
- # and for ease of programming
- def x1
- @virtual_x1 ||= @x1
- end
-
- def x1=(x1)
- @virtual_x1 = x1
- end
-
- def y1
- @virtual_y1 ||= @y1
- end
-
- def y1=(y1)
- @virtual_y1 = y1
- end
-
- def x2
- @virtual_x2 ||= @x2
- end
-
- def x2=(x2)
- @virtual_x2 = x2
- end
-
- def y2
- @virtual_y2 ||= @y2
- end
-
- def y2=(y2)
- @virtual_y2 = y2
- end
-
- def x3
- @virtual_x3 ||= @x3
- end
-
- def x3=(x3)
- @virtual_x3 = x3
- end
-
- def y3
- @virtual_y3 ||= @y3
- end
-
- def y3=(y3)
- @virtual_y3 = y3
- end
- end
-end
-