Class: Thing

Inherits:
Object show all
Defined in:
ext/ruby/qtruby/examples/ruboids/ruboids/Thing.rb

Direct Known Subclasses

Boid, Cloud

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pos = nil, vec = nil) ⇒ Thing

Returns a new instance of Thing.



14
15
16
17
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/Thing.rb', line 14

def initialize(pos = nil, vec = nil)
	@position = pos ? pos : Point.new
	@vector = vec ? vec : Point.new
end

Instance Attribute Details

#positionObject

Returns the value of attribute position.



12
13
14
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/Thing.rb', line 12

def position
  @position
end

#vectorObject

Returns the value of attribute vector.



12
13
14
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/Thing.rb', line 12

def vector
  @vector
end

#viewObject

Returns the value of attribute view.



12
13
14
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/Thing.rb', line 12

def view
  @view
end

Instance Method Details

#drawObject



25
26
27
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/Thing.rb', line 25

def draw
	view.draw() if view
end

#moveObject



19
20
21
22
23
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/Thing.rb', line 19

def move
	position.x += vector.x
	position.y += vector.y
	position.z += vector.z
end

#pixelsPerSecToPixelsPerMove(pixelsPerSecond) ⇒ Object



29
30
31
32
33
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/Thing.rb', line 29

def pixelsPerSecToPixelsPerMove(pixelsPerSecond)
	pps = (pixelsPerSecond.to_f / (1000.0 / 75.0)).to_i
	pps = 1 if pps == 0
	return pps
end