CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
map_tile_iterator Class Reference

Utility class for iterating over map tiles within a screen rectangle. More...

#include <th_map.h>

Public Member Functions

 map_tile_iterator ()=delete
 
 map_tile_iterator (const level_map *pMap, int iScreenX, int iScreenY, int iWidth, int iHeight, map_scanline_iterator_direction eScanlineDirection=map_scanline_iterator_direction::forward)
 
 operator bool () const
 Returns false if the iterator has exhausted its tiles.
 
map_tile_iteratoroperator++ ()
 Advances the iterator to the next tile.
 
const map_tileoperator-> () const
 Accessor for the current tile.
 
int tile_x_position_on_screen () const
 
int tile_y_position_on_screen () const
 
int tile_x () const
 
int tile_y () const
 
const level_mapget_map ()
 
const map_tileget_map_tile ()
 
int get_scanline_count ()
 
int get_tile_step ()
 
bool is_last_on_scanline () const
 Returns true if the next tile will be on a different scanline.
 

Friends

class map_scanline_iterator
 

Detailed Description

Utility class for iterating over map tiles within a screen rectangle.

To easily iterate over the map tiles which might draw something within a certain rectangle of screen space, an instance of this class can be used.

By default, it iterates by scanline, top-to-bottom, and then left-to-right within each scanline. Alternatively, by passing ScanlineBackward to the constructor, it will iterate bottom-to-top. Within a scanline, to visit tiles right-to-left, wait until isLastOnScanline() returns true, then use an instance of THMapScanlineIterator.

Constructor & Destructor Documentation

◆ map_tile_iterator() [1/2]

map_tile_iterator::map_tile_iterator ( )
delete

◆ map_tile_iterator() [2/2]

map_tile_iterator::map_tile_iterator ( const level_map pMap,
int  iScreenX,
int  iScreenY,
int  iWidth,
int  iHeight,
map_scanline_iterator_direction  eScanlineDirection = map_scanline_iterator_direction::forward 
)
  • pMap The map whose tiles should be iterated
  • iScreenX The X coordinate of the top-left corner of the screen-space rectangle to iterate.
  • iScreenY The Y coordinate of the top-left corner of the screen-space rectangle to iterate.
  • iWidth The width of the screen-space rectangle to iterate.
  • iHeight The width of the screen-space rectangle to iterate.
  • eScanlineDirection The direction in which to iterate scanlines; forward for top-to-bottom, backward for bottom-to-top.

Member Function Documentation

◆ get_map()

const level_map * map_tile_iterator::get_map ( )
inline

◆ get_map_tile()

const map_tile * map_tile_iterator::get_map_tile ( )
inline

◆ get_scanline_count()

int map_tile_iterator::get_scanline_count ( )
inline

◆ get_tile_step()

int map_tile_iterator::get_tile_step ( )
inline

◆ is_last_on_scanline()

bool map_tile_iterator::is_last_on_scanline ( ) const
inline

Returns true if the next tile will be on a different scanline.

To visit a scanline in right-to-left order, or to revisit a scanline, wait until this method returns true, then use a THMapScanlineIterator.

◆ operator bool()

map_tile_iterator::operator bool ( ) const
inline

Returns false if the iterator has exhausted its tiles.

◆ operator++()

map_tile_iterator & map_tile_iterator::operator++ ( )
inline

Advances the iterator to the next tile.

◆ operator->()

const map_tile * map_tile_iterator::operator-> ( ) const
inline

Accessor for the current tile.

◆ tile_x()

int map_tile_iterator::tile_x ( ) const
inline

◆ tile_x_position_on_screen()

int map_tile_iterator::tile_x_position_on_screen ( ) const
inline

Get the X position of the tile relative to the top-left corner of the screen-space rectangle

◆ tile_y()

int map_tile_iterator::tile_y ( ) const
inline

◆ tile_y_position_on_screen()

int map_tile_iterator::tile_y_position_on_screen ( ) const
inline

Get the Y position of the tile relative to the top-left corner of the screen-space rectangle

Friends And Related Symbol Documentation

◆ map_scanline_iterator


The documentation for this class was generated from the following files: