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
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
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
Parses a graphic file given the filename
Opens a graphic file and parses it:
my_graphic = WAD::Graphic.parse("Path/To/Graphic")
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
Returns a copy of self with all instance variables cloned.
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