Class: CollidableShape

Inherits:
Object show all
Defined in:
lib/gamebox/behaviors/collidable/collidable_shape.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actor, options) ⇒ CollidableShape

Returns a new instance of CollidableShape.



6
7
8
9
10
11
12
13
14
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 6

def initialize(actor, options)
  @opts = options
  @actor = actor

  @x_offset = opts[:x_offset]
  @y_offset = opts[:y_offset]
  @x_offset ||= 0
  @y_offset ||= 0
end

Instance Attribute Details

#actorObject

Returns the value of attribute actor.



2
3
4
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 2

def actor
  @actor
end

#cw_local_pointsObject (readonly)

Returns the value of attribute cw_local_points.



4
5
6
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 4

def cw_local_points
  @cw_local_points
end

#cw_world_edge_normalsObject (readonly)

Returns the value of attribute cw_world_edge_normals.



4
5
6
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 4

def cw_world_edge_normals
  @cw_world_edge_normals
end

#cw_world_linesObject (readonly)

Returns the value of attribute cw_world_lines.



4
5
6
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 4

def cw_world_lines
  @cw_world_lines
end

#cw_world_pointsObject (readonly)

Returns the value of attribute cw_world_points.



4
5
6
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 4

def cw_world_points
  @cw_world_points
end

#optsObject

Returns the value of attribute opts.



2
3
4
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 2

def opts
  @opts
end

#radiusObject

Returns the value of attribute radius.



2
3
4
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 2

def radius
  @radius
end

Instance Method Details

#actor_xObject



16
17
18
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 16

def actor_x
  @actor.x + @x_offset
end

#actor_yObject



20
21
22
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 20

def actor_y
  @actor.y + @y_offset
end

#recalculate_collidable_cacheObject



33
34
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 33

def recalculate_collidable_cache
end

#setupObject

TODO find out if this is called



25
26
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 25

def setup
end

#widthObject Also known as: height



28
29
30
# File 'lib/gamebox/behaviors/collidable/collidable_shape.rb', line 28

def width
  @radius * 2
end