Class: Ruby2D::Camera::Circle
- Inherits:
-
Ruby2D::Circle
- Object
- Ruby2D::Circle
- Ruby2D::Camera::Circle
- Defined in:
- lib/ruby2d/camera/circle.rb
Overview
Wraps existing variables as well as adding new methods so that it can be handled by the Camera Module
Instance Method Summary collapse
-
#_draw ⇒ Object
Recalculates real coordiantes Use after changing variables.
- #add ⇒ Object
-
#initialize(opts = {}) ⇒ Circle
constructor
A new instance of Circle.
- #remove ⇒ Object
- #z=(z) ⇒ Object
Constructor Details
Instance Method Details
#_draw ⇒ Object
Recalculates real coordiantes Use after changing variables
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruby2d/camera/circle.rb', line 10 def _draw return if @hide angle = Camera.angle * (Math::PI / 180) half_width = Window.width * 0.5 half_height = Window.height * 0.5 temp_radius = @radius * Camera.zoom temp_x = (((@x - Ruby2D::Camera.x + radius) * Math.cos(angle)) - ((@y - Ruby2D::Camera.y + radius) * Math.sin(angle))) * Ruby2D::Camera.zoom + half_width temp_y = (((@x - Ruby2D::Camera.x + radius) * Math.sin(angle)) + ((@y - Ruby2D::Camera.y + radius) * Math.cos(angle))) * Ruby2D::Camera.zoom + half_height Ruby2D::Circle.draw(x: temp_x, y: temp_y, radius: temp_radius, sectors: sectors, color: [color.r, color.g, color.b, color.a]) end |
#add ⇒ Object
40 41 42 |
# File 'lib/ruby2d/camera/circle.rb', line 40 def add @hide = false end |
#remove ⇒ Object
36 37 38 |
# File 'lib/ruby2d/camera/circle.rb', line 36 def remove @hide = true end |
#z=(z) ⇒ Object
31 32 33 34 |
# File 'lib/ruby2d/camera/circle.rb', line 31 def z=(z) super(z) Ruby2D::Camera._sort_by_z end |