class TL_Class

TileLib Game Library

Public Methods

[more] TL_Class(char *name)
Creates a new TileLib map object and loads the mapfile
[more] TL_Class()
Creates a new TileLib map object.
[more] ~TL_Class()
Destructor, frees up memory allocated
[more]void update(BITMAP *buffer)
Draws a map to the specified buffer.
[more]int scroll(int xAmt, int yAmt)
Scrolls the screen in whole tile increments, may be negative
[more]int smoothScroll(int xAmt, int yAmt)
Scrolls the screen in single pixel increments, may be negative
[more]int tileInfo(unsigned int x, unsigned int y, BaseStruct *base)
given PIXEL coordinates, retrieves the data on that particular tile and stores it in the structure passed in
[more]int tileInfo(unsigned int x, unsigned int y, FringeStruct *fringe)
given PIXEL coordinates, retrieves the data on that particular tile and stores it in the structure passed in
[more]int tileInfo(unsigned int x, unsigned int y, ObjectStruct *obj)
given PIXEL coordinates, retrieves the data on that particular tile and stores it in the structure passed in
[more]int tileInfo(unsigned int x, unsigned int y, RoofStruct *roof)
given PIXEL coordinates, retrieves the data on that particular tile and stores it in the structure passed in
[more]int modifyTile(unsigned int x, unsigned int y, BaseStruct bs)
This function lets you modify the tile attributes of the base layer at a given pixel coordinate
[more]int modifyTile(unsigned int x, unsigned int y, FringeStruct fs)
This function lets you modify the tile attributes of the fringe layer at a given pixel coordinate
[more]int modifyTile(unsigned int x, unsigned int y, ObjectStruct os)
This function lets you modify the tile attributes of the object layer at a given pixel coordinate
[more]int modifyTile(unsigned int x, unsigned int y, RoofStruct rs)
This function lets you modify the tile attributes of the roof layer at a given pixel coordinate
[more]int loadMap(char *name)
Loads a map into memory.
[more]void setPalette(void)
Changes the color palette to that defined in the resource datafile
[more]int removeRoofVisibleWindow(unsigned int group_no)
Removes all tiles from screen (actually just hides them) belonging to the specified group number, and ONLY on the visible portion of the screen
[more]int removeRoofBoundedWindow(unsigned int group_no, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
This function removes all tiles belonging to group number group_no from a given boundary (ie.
[more]int removeRoofEntireMap(unsigned int group_no)
This function removes every tile in group_no from the ENTIRE map, so this might be slow if you have a huge map.
[more]int replaceRoofVisibleWindow(unsigned int group_no)
Makes the roof layer in the specified group visible ONLY on the visible screen portion
[more]int replaceRoofBoundedWindow(unsigned int group_no, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
Makes visible all tiles belonging to group number group_no from a given boundary (ie.
[more]int replaceRoofEntireMap(unsigned int group_no)
Makes visible all tiles in the specified group number in the ENTIRE map world This may be time consuming for large maps
[more]void setBorderX1(unsigned int x)
Creates a border of the specified pixel amount around the map
[more]void setBorderX2(unsigned int x)
Creates a border of the specified pixel amount around the map
[more]void setBorderY1(unsigned int y)
Creates a border of the specified pixel amount around the map
[more]void setBorderY2(unsigned int y)
Creates a border of the specified pixel amount around the map
[more]unsigned int getBorderX1(void)
Returns the upper left amount of the border width
[more]unsigned int getBorderX2(void)
Returns the lower right amount of the border width
[more]unsigned int getBorderY1(void)
Returns the upper left amount of the border width
[more]unsigned int getBorderY2(void)
Returns the lower right amount of the border width
[more]int getVideoMode(void)
Returns the current video mode as a standard Allegro GFX_ define
[more]unsigned int getResX(void)
Returns the current screen width in pixels
[more]unsigned int getResY(void)
Returns the current screen height in pixels
[more]unsigned int getTileW(void)
Returns the width in pixels of the tiles in the world
[more]unsigned int getTileH(void)
Returns the height in pixels of the tiles in the world

Protected Fields

[more]MapStruct** map
[more]DATAFILE* data
a 2D array holding the map data
[more]unsigned int resX
holds the graphics/sounds/etc
[more]unsigned int tileW
screen resolution, in pixels
[more]unsigned int mapW
pixel size of the tiles
[more]byte numLayers
dimension of the map, in tiles
[more]int palNo
number of map layers
[more]char dataFile[80]
palette number
[more]unsigned int borderX1
data file name (holds graphics, etc)
[more]unsigned int borderY1
border, if any, from the
[more]unsigned int borderX2
top left corner of the screen
[more]unsigned int borderY2
[more]unsigned int mapXStart
border from bottom right of screen, if any
[more]unsigned int mapYStart
[more]int videoMode
which tiles to start at in the map array
[more]byte bl
[more]int xOff
set to 1 if the base, fringe, object or roof layers are used (or all)

Protected Methods

[more]int freeMem(void)
Free up all the memory in the map array
[more]void clearAll(void)
zero out the entire map array


Documentation

TileLib Game Library
o TL_Class(char *name)
Creates a new TileLib map object and loads the mapfile
Parameters:
name - a char* that is the FULL path name of the map to load

o TL_Class()
Creates a new TileLib map object. You must later call loadMap() to load a map into memory.

o ~TL_Class()
Destructor, frees up memory allocated

ovoid update(BITMAP *buffer)
Draws a map to the specified buffer. Pass in "screen" to draw directly to screen.
Parameters:
buffer - a BITMAP* to draw to, most likely you will want this to be your double buffer.

oint scroll(int xAmt, int yAmt)
Scrolls the screen in whole tile increments, may be negative
Parameters:
xAmt - the number of tiles to scroll in the X direction
yAmt - the number of tiles to scroll in the Y direction
Returns:
0 if error or couldn't scroll entire amount requested, otherwise 1

oint smoothScroll(int xAmt, int yAmt)
Scrolls the screen in single pixel increments, may be negative
Parameters:
xAmt - the number of pixels to scroll in the X direction
yAmt - the number of pixels to scroll in the Y direction
Returns:
0 if error or couldn't scroll entire amount requested, otherwise 1

oint tileInfo(unsigned int x, unsigned int y, BaseStruct *base)
given PIXEL coordinates, retrieves the data on that particular tile and stores it in the structure passed in
Parameters:
x - the x coordinate at which you want to retrieve information
y - the y coordinate at which you want to retrieve information
base - the BaseStruct to store the result in
Returns:
0 on error, otherwise 1.

oint tileInfo(unsigned int x, unsigned int y, FringeStruct *fringe)
given PIXEL coordinates, retrieves the data on that particular tile and stores it in the structure passed in
Parameters:
x - the x coordinate at which you want to retrieve information
y - the y coordinate at which you want to retrieve information
fringe - the FringeStruct to store the result in
Returns:
0 on error, otherwise 1.

oint tileInfo(unsigned int x, unsigned int y, ObjectStruct *obj)
given PIXEL coordinates, retrieves the data on that particular tile and stores it in the structure passed in
Parameters:
x - the x coordinate at which you want to retrieve information
y - the y coordinate at which you want to retrieve information
obj - the ObjectStruct to store the result in
Returns:
0 on error, otherwise 1.

oint tileInfo(unsigned int x, unsigned int y, RoofStruct *roof)
given PIXEL coordinates, retrieves the data on that particular tile and stores it in the structure passed in
Parameters:
x - the x coordinate at which you want to retrieve information
y - the y coordinate at which you want to retrieve information
roof - the RoofStruct to store the result in
Returns:
0 on error, otherwise 1.

oint modifyTile(unsigned int x, unsigned int y, BaseStruct bs)
This function lets you modify the tile attributes of the base layer at a given pixel coordinate
Parameters:
x - the x coordinate at which you want to retrieve information
y - the y coordinate at which you want to retrieve information
bs - the BaseStruct to store the result in
Returns:
0 on error, otherwise 1.

oint modifyTile(unsigned int x, unsigned int y, FringeStruct fs)
This function lets you modify the tile attributes of the fringe layer at a given pixel coordinate
Parameters:
x - the x coordinate at which you want to retrieve information
y - the y coordinate at which you want to retrieve information
fs - the FringeStruct to store the result in
Returns:
0 on error, otherwise 1.

oint modifyTile(unsigned int x, unsigned int y, ObjectStruct os)
This function lets you modify the tile attributes of the object layer at a given pixel coordinate
Parameters:
x - the x coordinate at which you want to retrieve information
y - the y coordinate at which you want to retrieve information
os - the ObjectStruct to store the result in
Returns:
0 on error, otherwise 1.

oint modifyTile(unsigned int x, unsigned int y, RoofStruct rs)
This function lets you modify the tile attributes of the roof layer at a given pixel coordinate
Parameters:
x - the x coordinate at which you want to retrieve information
y - the y coordinate at which you want to retrieve information
rs - the RoofStruct to store the result in
Returns:
0 on error, otherwise 1.

oint loadMap(char *name)
Loads a map into memory. WARNING: This must __ONLY__ be called after Allegro has been placed into a graphics mode or you will get a core dump!
Parameters:
name - the char* thta is the full path name of the map to load.

ovoid setPalette(void)
Changes the color palette to that defined in the resource datafile

oint removeRoofVisibleWindow(unsigned int group_no)
Removes all tiles from screen (actually just hides them) belonging to the specified group number, and ONLY on the visible portion of the screen
Parameters:
group_no - the group number of the roof tiles to hide.
Returns:
0 on error, otherwise non-zero.

oint removeRoofBoundedWindow(unsigned int group_no, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
This function removes all tiles belonging to group number group_no from a given boundary (ie. can encompass more than just the visible screen). NOTE: COORDINATES ARE IN TILE UNITS, NOT PIXELS!! So basically, think of your world as starting at tile location (0, 0). The bottom most corner is (x2, y2) of your world. You could have a variable that keeps track of the current tile x,y that the user is on, in addition to what you probably already have, that being the x,y of the user in pixels. See the examples for ideas on how to implement this, or read the documentation
Parameters:
group_no - the group number of the roof tiles to hide.
x1 - the upper left x coordinate in tiles to begin removing roof tiles from
y1 - the upper left y coordinate in tiles to begin removing roof tiles from
x2 - the lower right x coordinate in tiles to begin removing roof tiles from
y2 - the lower right y coordinate in tiles to begin removing roof tiles from
Returns:
0 on error, otherwise 1.

oint removeRoofEntireMap(unsigned int group_no)
This function removes every tile in group_no from the ENTIRE map, so this might be slow if you have a huge map.
Parameters:
group_no - the group number of the roof tiles to hide.
Returns:
0 on error, otherwise 1.

oint replaceRoofVisibleWindow(unsigned int group_no)
Makes the roof layer in the specified group visible ONLY on the visible screen portion
Parameters:
group_no - the group number of the roof tiles to hide.
Returns:
0 on error, otherwise 1

oint replaceRoofBoundedWindow(unsigned int group_no, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
Makes visible all tiles belonging to group number group_no from a given boundary (ie. can encompass more than just the visible screen). NOTE: COORDINATES ARE IN TILE UNITS, NOT PIXELS!! So basically, think of your world as starting at tile location (0, 0). The bottom most corner is (x2, y2) of your world. You could have a variable that keeps track of the current tile x,y that the user is on, in addition to what you probably already have, that being the x,y of the user in pixels. See the examples for ideas on how to implement this, or read the documentation
Parameters:
group_no - the group number of the roof tiles to hide.
x1 - the upper left x coordinate in tiles
y1 - the upper left y coordinate in tiles
x2 - the lower right x coordinate in tiles
y2 - the lower right y coordinate in tiles
Returns:
0 on error, otherwise 1.

oint replaceRoofEntireMap(unsigned int group_no)
Makes visible all tiles in the specified group number in the ENTIRE map world This may be time consuming for large maps
Parameters:
group_no - the group number of the roof tiles to hide.
Returns:
0 on error, otherwise 1.

ovoid setBorderX1(unsigned int x)
Creates a border of the specified pixel amount around the map
Parameters:
x - the border in pixels to set in the x direction of the upper left corner

ovoid setBorderX2(unsigned int x)
Creates a border of the specified pixel amount around the map
Parameters:
x - the border in pixels to set in the x direction of the lower right corner

ovoid setBorderY1(unsigned int y)
Creates a border of the specified pixel amount around the map
Parameters:
y - the border in pixels to set in the y direction of the upper left corner

ovoid setBorderY2(unsigned int y)
Creates a border of the specified pixel amount around the map
Parameters:
y - the border in pixels to set in the y direction of the lower right corner

ounsigned int getBorderX1(void)
Returns the upper left amount of the border width

ounsigned int getBorderX2(void)
Returns the lower right amount of the border width

ounsigned int getBorderY1(void)
Returns the upper left amount of the border width

ounsigned int getBorderY2(void)
Returns the lower right amount of the border width

oint getVideoMode(void)
Returns the current video mode as a standard Allegro GFX_ define

ounsigned int getResX(void)
Returns the current screen width in pixels

ounsigned int getResY(void)
Returns the current screen height in pixels

ounsigned int getTileW(void)
Returns the width in pixels of the tiles in the world

ounsigned int getTileH(void)
Returns the height in pixels of the tiles in the world

oint freeMem(void)
Free up all the memory in the map array

ovoid clearAll(void)
zero out the entire map array

oMapStruct** map

oDATAFILE* data
a 2D array holding the map data

ounsigned int resX
holds the graphics/sounds/etc

ounsigned int tileW
screen resolution, in pixels

ounsigned int mapW
pixel size of the tiles

obyte numLayers
dimension of the map, in tiles

oint palNo
number of map layers

ochar dataFile[80]
palette number

ounsigned int borderX1
data file name (holds graphics, etc)

ounsigned int borderY1
border, if any, from the

ounsigned int borderX2
top left corner of the screen

ounsigned int borderY2

ounsigned int mapXStart
border from bottom right of screen, if any

ounsigned int mapYStart

oint videoMode
which tiles to start at in the map array

obyte bl

oint xOff
set to 1 if the base, fringe, object or roof layers are used (or all)


This class has no child classes.
Author:
Jeff Weinstein, jeffw@ucsd.edu, http://coredump.cc Main (and in fact only) TileLib class. All programs wishing to use a TileLib object must create a new TL_Class variable. It is highly recommended that you make this dynamic, for reasons explained in the manual. If you don't know how to do this, here is an example: TL_Class map; map = new TL_Class(); simple. Make sure you clean up the memory when done with a: delete map; Accessing works the same way, only use a "->" instead of a "."
Version:
0.4

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.