Class: RedBird::RelativeEntity
- Defined in:
- lib/red_bird/relative_entity.rb
Overview
Instance Attribute Summary collapse
- #collision_box ⇒ RedBird::Rect readonly
Attributes inherited from Entity
Class Method Summary collapse
- .scenario ⇒ RedBird::TileMap
-
.scenario=(scenario) ⇒ Object
Define which scenario to use as a reference for every RelativeEntity.
Instance Method Summary collapse
- #height ⇒ Integer
-
#initialize(relative_pos_x, relative_pos_y, width, height) ⇒ RelativeEntity
constructor
A new instance of RelativeEntity.
-
#pos_x ⇒ Float
Gets absolute position (position in the screen).
-
#pos_y ⇒ Float
Gets absolute position (position in the screen).
-
#relative_pos_x ⇒ Integer
Position in the scenario.
- #relative_pos_x=(x) ⇒ Object
-
#relative_pos_y ⇒ Integer
Position in the scenario.
- #relative_pos_y=(y) ⇒ Object
- #width ⇒ Integer
Methods inherited from Entity
#cursor_down, #cursor_hover, #cursor_up, #render, #tick
Constructor Details
#initialize(relative_pos_x, relative_pos_y, width, height) ⇒ RelativeEntity
Returns a new instance of RelativeEntity.
19 20 21 22 23 24 25 26 |
# File 'lib/red_bird/relative_entity.rb', line 19 def initialize(relative_pos_x, relative_pos_y, width, height) super() @priority = 1 @collision_box = RedBird::Rect.new( relative_pos_x, relative_pos_y, width, height) end |
Instance Attribute Details
#collision_box ⇒ RedBird::Rect (readonly)
12 13 14 |
# File 'lib/red_bird/relative_entity.rb', line 12 def collision_box @collision_box end |
Class Method Details
.scenario ⇒ RedBird::TileMap
39 40 41 |
# File 'lib/red_bird/relative_entity.rb', line 39 def self.scenario return @@scenario end |
.scenario=(scenario) ⇒ Object
Define which scenario to use as a reference for every RedBird::RelativeEntity.
33 34 35 |
# File 'lib/red_bird/relative_entity.rb', line 33 def self.scenario=(scenario) @@scenario = scenario end |
Instance Method Details
#height ⇒ Integer
91 92 93 |
# File 'lib/red_bird/relative_entity.rb', line 91 def height @collision_box.height end |
#pos_x ⇒ Float
Gets absolute position (position in the screen).
71 72 73 |
# File 'lib/red_bird/relative_entity.rb', line 71 def pos_x @collision_box.x - @@scenario.hor_offset + @@scenario.pos_x end |
#pos_y ⇒ Float
Gets absolute position (position in the screen).
79 80 81 |
# File 'lib/red_bird/relative_entity.rb', line 79 def pos_y @collision_box.y - @@scenario.ver_offset + @@scenario.pos_y end |
#relative_pos_x ⇒ Integer
Returns position in the scenario.
45 46 47 |
# File 'lib/red_bird/relative_entity.rb', line 45 def relative_pos_x return @collision_box.x end |
#relative_pos_x=(x) ⇒ Object
57 58 59 |
# File 'lib/red_bird/relative_entity.rb', line 57 def relative_pos_x=(x) @collision_box.x = x end |
#relative_pos_y ⇒ Integer
Returns position in the scenario.
51 52 53 |
# File 'lib/red_bird/relative_entity.rb', line 51 def relative_pos_y return @collision_box.y end |
#relative_pos_y=(y) ⇒ Object
63 64 65 |
# File 'lib/red_bird/relative_entity.rb', line 63 def relative_pos_y=(y) @collision_box.y = y end |
#width ⇒ Integer
85 86 87 |
# File 'lib/red_bird/relative_entity.rb', line 85 def width @collision_box.width end |