Class: Chobo::GameObject

Inherits:
Object
  • Object
show all
Defined in:
lib/chobo/game_object.rb

Direct Known Subclasses

Entity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGameObject

Returns a new instance of GameObject.



5
6
7
8
9
10
11
12
# File 'lib/chobo/game_object.rb', line 5

def initialize 
	@position = Vec2.new
	@velocity = Vec2.new
	@origin = Vec2.new(0.5, 0.5)
	@rotation = 0.0
	@scale = Vec2.new(1.0, 1.0)
	@color = Chobo.color()
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



3
4
5
# File 'lib/chobo/game_object.rb', line 3

def color
  @color
end

#originObject

Returns the value of attribute origin.



3
4
5
# File 'lib/chobo/game_object.rb', line 3

def origin
  @origin
end

#positionObject

Returns the value of attribute position.



3
4
5
# File 'lib/chobo/game_object.rb', line 3

def position
  @position
end

#rotationObject

Returns the value of attribute rotation.



3
4
5
# File 'lib/chobo/game_object.rb', line 3

def rotation
  @rotation
end

#scaleObject

Returns the value of attribute scale.



3
4
5
# File 'lib/chobo/game_object.rb', line 3

def scale
  @scale
end

#velocityObject

Returns the value of attribute velocity.



3
4
5
# File 'lib/chobo/game_object.rb', line 3

def velocity
  @velocity
end

Instance Method Details

#set_color(r = 255, g = 255, b = 255, a = 255) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/chobo/game_object.rb', line 40

def set_color r = 255, g = 255, b = 255, a = 255
	@color.red = r
	@color.green = g
	@color.blue = b
	@color.alpha = a
	self
end

#set_position(x, y) ⇒ Object



14
15
16
17
# File 'lib/chobo/game_object.rb', line 14

def set_position x, y
	@position.x, @position.y = x, y
	self
end

#set_rotation(rotation) ⇒ Object



35
36
37
38
# File 'lib/chobo/game_object.rb', line 35

def set_rotation rotation
	@rotation = rotation
	self
end

#set_scale(scale_x, scale_y = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/chobo/game_object.rb', line 24

def set_scale scale_x, scale_y = nil
	if scale_y
		@scale.x = scale_x
		@scale.y = scale_y
	else
		@scale.x = scale_x
		@scale.y = scale_x
	end
	self			
end

#set_velocity(x, y) ⇒ Object



19
20
21
22
# File 'lib/chobo/game_object.rb', line 19

def set_velocity x, y
	@velocity.x, @velocity.y = x, y
	self
end

#update(dt) ⇒ Object



48
49
# File 'lib/chobo/game_object.rb', line 48

def update dt
end