map
Module¶
Source code: map.py
The map
module provides an Map
class which
derives from ReadWriteFile
and is used to read and write
Duke3D map data.
- vgio.duke3d.map.is_mapfile(filename)¶
Quickly see if a file is a map file by checking the magic number.
The filename argument may be a file for file-like object.
Map
Class¶
- class vgio.duke3d.map.Map¶
Class for working with map files
Example
Basic usage:
from vgio.duke3d.map import Map m = Map.open(file)
- version¶
Version of the map file. Build is 7
- position_x¶
Player start position x-coordinate.
- position_y¶
Player start position y-coordinate.
- position_z¶
Player start position z-coordinate.
- angle¶
Player start angle.
- start_sector¶
Sector of player start.
- sectors¶
A sequence of Sector objects.
- walls¶
A sequence of Wall objects.
- sprites¶
A sequence of Sprite objects.
- Map.__init__()¶
Constructs a Map object.
- classmethod Map.open(file, mode='r')¶
Open a ReadWriteFile object where file can be a path to a file (a string), or a file-like object.
The mode parameter should be ‘r’ to read an existing file, ‘w’ to truncate and write a new file, or ‘a’ to append to an existing file.
open() is also a context manager and supports the with statement:
with ReadWriteFile.open('file.ext') as file: file.save('file2.ext')
- Parameters
file – Either the path to the file, a file-like object, or bytes.
mode – An optional string that indicates which mode to open the file
- Returns
An ReadWriteFile object constructed from the information read from the file-like object.
- Raises
ValueError – If an invalid file mode is given.
TypeError – If attempting to write to a bytes object.
OSError – If the file argument is not a file-like object.
- Map.close()¶
Closes the file pointer if possible. If mode is ‘w’ or ‘a’, the file will be written to.
- Map.save(file)¶
Writes data to file.
- Parameters
file – Either the path to the file, or a file-like object.
- Raises
OSError – If file argument is not a file-like object.
Sector
Class¶
- class vgio.duke3d.map.Sector(wall_pointer, wall_number, ceiling_z, floor_z, ceiling_stat, floor_stat, ceiling_picnum, ceiling_heinum, ceiling_shade, ceiling_palette, ceiling_x_panning, ceiling_y_panning, floor_picnum, floor_heinum, floor_shade, floor_palette, floor_x_panning, floor_y_panning, visibility, lotag, hitag, extra)¶
Class for representing a sector
- wall_pointer¶
The index of the first wall.
- wall_number¶
The total number of walls in sector.
- ceiling_z¶
The z-coordinate of the ceiling at the first point of sector.
- floor_z¶
The z-coordinate of the floor at the first point of sector.
- ceiling_stat¶
A bitmasked field of properties.
- floor_stat¶
A bitmasked field of properties.
- ceiling_picnum¶
Texture index into Art file
- ceiling_heinum¶
Slope value. 0 is parallel to the floor, 4096 is 45 degrees.
- ceiling_shade¶
Shade offset for ceiling.
- ceiling_palette¶
Palette lookup number. 0 is the standard palette.
- ceiling_x_panning¶
Texture x align/pan value.
- ceiling_y_panning¶
Texture y align/pan value.
- floor_picnum¶
Texture index into Art file
- floor_heinum¶
Slope value. 0 is parallel to the floor, 4096 is 45 degrees.
- floor_shade¶
Shade offset for floor.
- floor_palette¶
Palette lookup number. 0 is the standard palette.
- floor_x_panning¶
Texture x align/pan value.
- floor_y_panning¶
Texture y align/pan value.
- visibility¶
Determines how fast shade changes relative to distance
- lotag¶
Tag for driving behavior.
- hitag¶
Tag for driving behavior.
- extra¶
Tag for driving behavior.
- Sector.__init__(wall_pointer, wall_number, ceiling_z, floor_z, ceiling_stat, floor_stat, ceiling_picnum, ceiling_heinum, ceiling_shade, ceiling_palette, ceiling_x_panning, ceiling_y_panning, floor_picnum, floor_heinum, floor_shade, floor_palette, floor_x_panning, floor_y_panning, visibility, lotag, hitag, extra)¶
Constructs a Sector object.
- classmethod Sector.read(file)¶
- classmethod Sector.write(file, sector)¶
Sprite
Class¶
- class vgio.duke3d.map.Sprite(x, y, z, cstat, picnum, shade, palette, clip_distance, x_repeat, y_repeat, x_offset, y_offset, sector_number, status_number, angle, owner, x_velocity, y_velocity, z_velocity, lotag, hitag, extra)¶
Class for representing a sprite
- x¶
X-coordinate of sprite position.
- y¶
Y-coordinate of sprite position.
- z¶
Z-coordinate of sprite position.
- cstat¶
A bitmasked field of properties.
- shade¶
Shade offset of sprite.
- palette¶
Palette lookup number. 0 is the standard palette.
- clip_distance¶
Size of movement clipping square.
- x_repeat¶
Used to stretch texture.
- y_repeat¶
Used to stretch texture.
- x_offset¶
Used to center texture.
- y_offset¶
Used to center texture.
- sector_number¶
Current sector of sprite.
- status_number¶
Current status of sprite.
- angle¶
Angle the sprite is facing.
- owner¶
- x_velocity¶
X-coordinate of sprite velocity.
- y_velocity¶
Y-coordinate of sprite velocity.
- z_velocity¶
Z-coordinate of sprite velocity.
- lotag¶
Tag for driving behavior.
- hitag¶
Tag for driving behavior.
- extra¶
Tag for driving behavior.
- Sprite.__init__(x, y, z, cstat, picnum, shade, palette, clip_distance, x_repeat, y_repeat, x_offset, y_offset, sector_number, status_number, angle, owner, x_velocity, y_velocity, z_velocity, lotag, hitag, extra)¶
Constructs a Sprite object.
- classmethod Sprite.read(file)¶
- classmethod Sprite.write(file, sprite)¶
Wall
Class¶
- class vgio.duke3d.map.Wall(x, y, point2, next_wall, next_sector, cstat, picnum, over_picnum, shade, palette, x_repeat, y_repeat, x_panning, y_panning, lotag, hitag, extra)¶
Class for representing a wall
- x¶
X-coordinate of left side of wall.
- y¶
Y-coordinate of left side of wall.
- point2¶
Index to the next wall on the right.
- next_wall¶
Index to wall on the other side of wall. Will be -1 if there is no sector.
- next_sector¶
Index to sector on other side of wall. Will be -1 if there is no sector.
- cstat¶
A bitmasked field of properties.
- picnum¶
Texture index into Art file.
- over_picnum¶
Texture index into Art file for masked walls.
- shade¶
Shade offset of wall.
- palette¶
Palette lookup number. 0 is the standard palette.
- x_repeat¶
Used to stretch texture.
- y_repeat¶
Used to stretch texture.
- x_panning¶
Used to align/pan texture.
- y_panning¶
Used to align/pan texture.
- lotag¶
Tag for driving behavior.
- hitag¶
Tag for driving behavior.
- extra¶
Tag for driving behavior.
- Wall.__init__(x, y, point2, next_wall, next_sector, cstat, picnum, over_picnum, shade, palette, x_repeat, y_repeat, x_panning, y_panning, lotag, hitag, extra)¶
Constructs a Wall object.
- classmethod Wall.read(file)¶
- classmethod Wall.write(file, wall)¶