class

WAD::Graphic

Inherits WritingAdditions::Graphic < RaylibAdditions::Graphic < Reference < Object

A WAD graphic

WARNING: The max graphic height is 255. The max width is unlimited

NOTE: Graphic has no is_graphic? method. Instead, Graphic#parse will return nil if io is not a valid graphic

Class methods

is_sprite_mark_end?(name : String)

Checks to see if name is "S_END".

Returns true if the name is a sprite marker end:

sprite_mark_name = "S_END"
if WAD::Graphic.is_sprite_mark_end?(sprite_mark_name)
  puts "Is a Sprite Marker End"
else
  puts "Is not a Sprite Marker End"
end
is_sprite_mark_start?(name : String)

Checks to see if name is "S_START".

Returns true if the name is a sprite marker start:

sprite_mark_name = "S_START"
if WAD::Graphic.is_sprite_mark_start?(sprite_mark_name)
  puts "Is a Sprite Marker Start"
else
  puts "Is not a Sprite Marker Start"
end
parse(filename : String | Path) : Graphic | Nil

Parses a graphic file given the filename

Opens a graphic file and parses it:

my_graphic = WAD::Graphic.parse("Path/To/Graphic")
parse(file : File, file_pos : Int = 0, size : Int = -1) : Graphic | Nil

Parses a graphic file given the file

Opens a graphic file and parses it:

File.open("Path/To/Graphic") do |file|
  my_graphic = WAD::Graphic.parse(file)
end

Instance methods

[](x : Int, y : Int)
clone

Returns a copy of self with all instance variables cloned.

data
file_size
file_size=(file_size : UInt32)
height
height=(height : UInt16)
leftoffset
leftoffset=(leftoffset : Int16)
reset_data
set_pixel(x : Int, y : Int, value : Int)

Sets a pixel in the graphic 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_graphic = my_wad.graphics["MyGraphic"]

my_graphic[2, 3] # => Returns the value of the pixel at x=2 y=3

my_graphic.set_pixel(2, 3, 120) # => Sets the value of the pixel at x=2 y=3 to be 120

my_graphic[2, 3] # => 120

my_graphic.set_pixel(2, 3, -1) # => Raises an exception

my_graphic.set_pixel(2, 3, 256) # => Raises an exception
topoffset
topoffset=(topoffset : Int16)
width
width=(width : UInt16)

Nested types