class WAD::Flat

Overview

A WAD flat

Included Modules

Extended Modules

Defined in:

raylib.cr
wa-cr/wad/wad-data/texture.cr
write.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module WritingAdditions::Flat

write(file : String | Path) : UInt32
write(io : IO) : UInt32
write

Instance methods inherited from module RaylibAdditions::Flat

get_pixel(x : Int, y : Int, palette : ::WAD::Playpal::Palette) : Raylib::Color get_pixel, to_image(palette : ::WAD::Playpal::Palette) : Raylib::Image to_image, to_png(filename : String | Path, palette : ::WAD::Playpal::Palette) to_png

Constructor Detail

def self.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")

def self.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 Method Detail

def self.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

def self.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 Method Detail

def [](x : Int, y : Int) #

def clone #

Returns a copy of self with all instance variables cloned.


def colors : Array(UInt8) #

def colors=(colors : Array(UInt8)) #

def height : Int32 #

def height=(height : Int32) #

def lump_bytes : Int32 #

def lump_bytes=(lump_bytes : Int32) #

def 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

def width : Int32 #

def width=(width : Int32) #