GameClient.TileEngine.Engine CreateTileLayers

From VbGORE Visual Basic Online RPG Engine

Contents

Purpose

Creates the tile layers used for rendering the tiles so they can be drawn faster. Has to happen every time the user warps or moves a tile. Only the tiles in view will be stored. The created array information, TileLayers() stores the following information:

  • TileX / TileY: The co-ordinate of the map tile in the MapData() array.
  • PixelPosX / PixelPosY: The screen pixel co-ordinate where the tile is rendered, disincluding offset values for the screen moving.

Parameters

None

Special notes

For each layer (1 to 6), the following is done:

  • 1. The number of tiles are set to 0
  • 2. Enough memory is allocated to fit every tile
  • 3. Every tile is looped through to check if there is a graphic on it
  • 4. A check is made if the tile is in range of the map, then if the tile has a graphic - if no graphic is found or it is an invalid tile, start over at step 3
  • 5. If a valid tile was found, NumTiles is raised 1, then the TileX, TileY, PixelPosX and PixelPosY values are stored so they don't have to be calculated again.
  • 6. After every tile of the layer has been looped through, the array is deallocated to the smallest possible value to free up memory

PixelPosX and PixelPosY do not include the offset values, so when the screen is moving between tiles, it is just a simple addition to the final pixel position.

Calls functions

Personal tools