Class: Sidedef

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

Constant Summary collapse

FORMAT =
"ss888s"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSidedef

Returns a new instance of Sidedef.



492
493
494
495
496
497
498
499
# File 'lib/ruby-doom.rb', line 492

def initialize()
  @x_offset=0
  @y_offset=0
  @upper_texture="-"
  @lower_texture="-"
  @middle_texture="BROWN96"
  @sector_id=0
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



491
492
493
# File 'lib/ruby-doom.rb', line 491

def id
  @id
end

#lower_textureObject

Returns the value of attribute lower_texture.



491
492
493
# File 'lib/ruby-doom.rb', line 491

def lower_texture
  @lower_texture
end

#middle_textureObject

Returns the value of attribute middle_texture.



491
492
493
# File 'lib/ruby-doom.rb', line 491

def middle_texture
  @middle_texture
end

#sector_idObject

Returns the value of attribute sector_id.



491
492
493
# File 'lib/ruby-doom.rb', line 491

def sector_id
  @sector_id
end

#upper_textureObject

Returns the value of attribute upper_texture.



491
492
493
# File 'lib/ruby-doom.rb', line 491

def upper_texture
  @upper_texture
end

#x_offsetObject

Returns the value of attribute x_offset.



491
492
493
# File 'lib/ruby-doom.rb', line 491

def x_offset
  @x_offset
end

#y_offsetObject

Returns the value of attribute y_offset.



491
492
493
# File 'lib/ruby-doom.rb', line 491

def y_offset
  @y_offset
end

Instance Method Details

#read(bytes) ⇒ Object



500
501
502
# File 'lib/ruby-doom.rb', line 500

def read(bytes)
  @x_offset, @y_offset, @upper_texture, @lower_texture, @middle_texture, @sector_id = Codec.decode(FORMAT, bytes)
end

#to_sObject



506
507
508
# File 'lib/ruby-doom.rb', line 506

def to_s
  " Sidedef for sector " + @sector_id.to_s + "; upper/lower/middle textures are " + @upper_texture + "/" + @lower_texture + "/" + @middle_texture + " with offsets of " + @x_offset.to_s + "/" + @y_offset.to_s
end

#writeObject



503
504
505
# File 'lib/ruby-doom.rb', line 503

def write
  Codec.encode(FORMAT, [@x_offset, @y_offset, @upper_texture, @lower_texture, @middle_texture, @sector_id])
end