Class: Thing
- Inherits:
-
Object
- Object
- Thing
- Defined in:
- lib/ruby-doom.rb
Instance Attribute Summary collapse
-
#facing_angle ⇒ Object
Returns the value of attribute facing_angle.
-
#id ⇒ Object
Returns the value of attribute id.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#type_id ⇒ Object
readonly
Returns the value of attribute type_id.
Instance Method Summary collapse
-
#initialize(p = nil, type_id = 0) ⇒ Thing
constructor
A new instance of Thing.
- #read(bytes) ⇒ Object
- #to_s ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(p = nil, type_id = 0) ⇒ Thing
Returns a new instance of Thing.
553 554 555 556 557 558 |
# File 'lib/ruby-doom.rb', line 553 def initialize(p=nil,type_id=0) @location = p @facing_angle = 0 @type_id = type_id @flags = 7 end |
Instance Attribute Details
#facing_angle ⇒ Object
Returns the value of attribute facing_angle.
552 553 554 |
# File 'lib/ruby-doom.rb', line 552 def facing_angle @facing_angle end |
#id ⇒ Object
Returns the value of attribute id.
552 553 554 |
# File 'lib/ruby-doom.rb', line 552 def id @id end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
551 552 553 |
# File 'lib/ruby-doom.rb', line 551 def location @location end |
#type_id ⇒ Object (readonly)
Returns the value of attribute type_id.
551 552 553 |
# File 'lib/ruby-doom.rb', line 551 def type_id @type_id end |
Instance Method Details
#read(bytes) ⇒ Object
559 560 561 562 |
# File 'lib/ruby-doom.rb', line 559 def read(bytes) x, y, @facing_angle, @type_id, @flags = Codec.decode("sssss", bytes) @location = Point.new(x,y) end |
#to_s ⇒ Object
566 567 568 |
# File 'lib/ruby-doom.rb', line 566 def to_s Dictionary.get.thing_for_type_id(@type_id).name + " at " + @location.to_s + " facing " + Dictionary.get.direction_for_angle(@facing_angle) + "; flags = " + @flags.to_s end |