Class: Budgie::Camera

Inherits:
Object
  • Object
show all
Includes:
Math
Defined in:
lib/budgie/camera.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCamera

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

#alphaObject

Returns the value of attribute alpha.



4
5
6
# File 'lib/budgie/camera.rb', line 4

def alpha
  @alpha
end

#betaObject

Returns the value of attribute beta.



4
5
6
# File 'lib/budgie/camera.rb', line 4

def beta
  @beta
end

#stepObject

Returns the value of attribute step.



4
5
6
# File 'lib/budgie/camera.rb', line 4

def step
  @step
end

#xObject

Returns the value of attribute x.



4
5
6
# File 'lib/budgie/camera.rb', line 4

def x
  @x
end

#yObject

Returns the value of attribute y.



4
5
6
# File 'lib/budgie/camera.rb', line 4

def y
  @y
end

#zObject

Returns the value of attribute z.



4
5
6
# File 'lib/budgie/camera.rb', line 4

def z
  @z
end

Instance Method Details

#backwardObject



20
21
22
# File 'lib/budgie/camera.rb', line 20

def backward
  move @step, 180
end

#downObject



36
37
38
# File 'lib/budgie/camera.rb', line 36

def down
  @y -= @step
end

#forwardObject



16
17
18
# File 'lib/budgie/camera.rb', line 16

def forward
  move @step
end

#leftObject



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

#rightObject



28
29
30
# File 'lib/budgie/camera.rb', line 28

def right
  move @step, -90
end

#upObject



32
33
34
# File 'lib/budgie/camera.rb', line 32

def up
  @y += @step
end