Class: Thing

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-doom.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_angleObject

Returns the value of attribute facing_angle.



552
553
554
# File 'lib/ruby-doom.rb', line 552

def facing_angle
  @facing_angle
end

#idObject

Returns the value of attribute id.



552
553
554
# File 'lib/ruby-doom.rb', line 552

def id
  @id
end

#locationObject (readonly)

Returns the value of attribute location.



551
552
553
# File 'lib/ruby-doom.rb', line 551

def location
  @location
end

#type_idObject (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_sObject



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

#writeObject



563
564
565
# File 'lib/ruby-doom.rb', line 563

def write
  Codec.encode("sssss", [@location.x, @location.y, @facing_angle, @type_id, @flags])
end