WAD::Flat
Inherits WritingAdditions::Flat < RaylibAdditions::Flat < Reference < Object
A WAD flat
Constructors
parse(filename : String | Path) : Flat
Parses a flat file given the filename
Opens a flat file and parses it:
my_flat = WAD::Flat.parse("Path/To/Flat")
parse(io : IO) : Flat
Parses a flat file given the io
Opens a flat io and parses it:
File.open("Path/To/Flat") do |file|
my_flat = WAD::Flat.parse(file)
end
Class methods
is_flat_mark_end?(name : String)
Checks to see if name is "F_END".
Returns true if the name is a flat marker end:
flat_mark_name = "F_END"
if WAD::Flat.is_flat_mark_end?(flat_mark_name)
puts "Is a Flat Marker End"
else
puts "Is not a Flat Marker End"
end
is_flat_mark_start?(name : String)
Checks to see if name is "F_START".
Returns true if the name is a flat marker start:
flat_mark_name = "F_START"
if WAD::Flat.is_flat_mark_start?(flat_mark_name)
puts "Is a Flat Marker Start"
else
puts "Is not a Flat Marker Start"
end
Instance methods
[](x : Int, y : Int)
clone
Returns a copy of self with all instance variables cloned.
colors
colors=(colors : Array(UInt8))
height
height=(height : Int32)
lump_bytes
lump_bytes=(lump_bytes : Int32)
set_pixel(x : Int, y : Int, value : Int)
Sets a pixel in the flat to be value.
Raises an error if value is not within the bounds
of a UInt8
NOTE: value does not refer to an rgb color,
but instead to an index in the colors of a WAD::Playpal::Palette
my_wad = WAD.read("Path/To/Wad")
my_flat = my_wad.flats["MyFlat"]
my_flat[2, 3] # => Returns the value of the pixel at x=2 y=3
my_flat.set_pixel(2, 3, 120) # => Sets the value of the pixel at x=2 y=3 to be 120
my_flat[2, 3] # => 120
my_flat.set_pixel(2, 3, -1) # => Raises an exception
my_flat.set_pixel(2, 3, 256) # => Raises an exception
width
width=(width : Int32)