Class: Budgie::Camera
Instance Attribute Summary collapse
-
#alpha ⇒ Object
Returns the value of attribute alpha.
-
#beta ⇒ Object
Returns the value of attribute beta.
-
#step ⇒ Object
Returns the value of attribute step.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Instance Method Summary collapse
- #backward ⇒ Object
- #down ⇒ Object
- #forward ⇒ Object
-
#initialize ⇒ Camera
constructor
A new instance of Camera.
- #left ⇒ Object
- #move(step, direction = 0) ⇒ Object
- #right ⇒ Object
- #up ⇒ Object
Constructor Details
#initialize ⇒ Camera
Returns a new instance of Camera.
6 7 8 9 |
# File 'lib/budgie/camera.rb', line 6 def initialize @x = @y = @z = @alpha = @beta = 0 @step = 0.1 end |
Instance Attribute Details
#alpha ⇒ Object
Returns the value of attribute alpha.
4 5 6 |
# File 'lib/budgie/camera.rb', line 4 def alpha @alpha end |
#beta ⇒ Object
Returns the value of attribute beta.
4 5 6 |
# File 'lib/budgie/camera.rb', line 4 def beta @beta end |
#step ⇒ Object
Returns the value of attribute step.
4 5 6 |
# File 'lib/budgie/camera.rb', line 4 def step @step end |
#x ⇒ Object
Returns the value of attribute x.
4 5 6 |
# File 'lib/budgie/camera.rb', line 4 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
4 5 6 |
# File 'lib/budgie/camera.rb', line 4 def y @y end |
#z ⇒ Object
Returns the value of attribute z.
4 5 6 |
# File 'lib/budgie/camera.rb', line 4 def z @z end |
Instance Method Details
#backward ⇒ Object
20 21 22 |
# File 'lib/budgie/camera.rb', line 20 def backward move @step, 180 end |
#down ⇒ Object
36 37 38 |
# File 'lib/budgie/camera.rb', line 36 def down @y -= @step end |
#forward ⇒ Object
16 17 18 |
# File 'lib/budgie/camera.rb', line 16 def forward move @step end |
#left ⇒ Object
24 25 26 |
# File 'lib/budgie/camera.rb', line 24 def left move @step, 90 end |
#move(step, direction = 0) ⇒ Object
11 12 13 14 |
# File 'lib/budgie/camera.rb', line 11 def move(step, direction = 0) @x += step * cos(PI * (90.0 + @alpha + direction) / 180.0) @z += step * sin(PI * (90.0 + @alpha + direction) / 180.0) end |
#right ⇒ Object
28 29 30 |
# File 'lib/budgie/camera.rb', line 28 def right move @step, -90 end |
#up ⇒ Object
32 33 34 |
# File 'lib/budgie/camera.rb', line 32 def up @y += @step end |