Roguelike
 All Classes Namespaces Functions Variables Typedefs Friends Pages
Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
Game Class Reference

#include <game.h>

Public Member Functions

void init (const MapTileMatrix &, IntPoint)
 
Chunkget_current_chunk ()
 
bool is_initialized ()
 
void act (long)
 
bool is_paused ()
 
void pause ()
 
void unpause ()
 
void toggle_pause ()
 
const std::vector< std::vector
< Tile * > > & 
get_canvas ()
 
IntPoint get_vis_coords (IntPoint, IntPoint)
 
std::vector< Enemy * > get_vis_enemies ()
 
void show_vis_items ()
 
std::vector< Animation > & get_animations ()
 
void tick_animations (long delta_ms)
 
bool is_vis (IntPoint coords)
 
void refresh ()
 
void recalculate_visibility_lines (int radius)
 
void update_buffer (IntPoint)
 
void update_chunk_map (IntPoint)
 
void draw_visibility_lines ()
 
void undo_visibility ()
 
void run_spawners ()
 
void run_enemies (long)
 
void remove_targets (Character *enem)
 
std::vector< Enemy * > & get_enemies ()
 
void change_depth (int, Character *)
 
void move_char (int, int, Character *)
 
void get_item (Character *)
 
void drop_item (Item *, Character *)
 
void spawn_enemy (int, int, int, int, int, int)
 
void teleport (int chunk_x, int chunk_y, int x, int y)
 
void create_explosion (int x, int y, int chunk_x, int chunk_y)
 

Public Attributes

Main_Character main_char
 

Private Types

typedef std::vector
< std::vector< Tile > > 
TileMatrix
 
typedef std::vector
< std::vector< Tile * > > 
TilePointerMatrix
 
typedef std::vector
< std::vector< MapTile > > 
MapTileMatrix
 

Private Member Functions

void point_assertions (int row, int col)
 
void set_tile (int row, int col, Tile *tile)
 
void set_tile (IntPoint point, Tile *tile)
 
Itemitem_at_coords (IntPoint, IntPoint, int)
 
Tileget_tile (int row, int col)
 
Tileget_tile (IntPoint point)
 
bool out_of_bounds (IntPoint point)
 
bool out_of_bounds (int row, int col)
 
bool in_buffer (int row, int col)
 
bool in_range (IntPoint chunk, IntPoint coords, IntPoint range_chunk, IntPoint center, IntPoint radius)
 
void update_main_char_chunk ()
 
IntPoint get_canvas_coords (IntPoint, IntPoint)
 
IntPoint get_buffer_coords (IntPoint, IntPoint)
 
Characterenemy_at_loc (IntPoint, IntPoint)
 

Private Attributes

bool initialized
 
bool paused
 
MapTileMatrix world_map
 
ChunkMatrix chunk_map
 
Tile tile_index [td::TILE_TYPE_COUNT]
 
std::vector< Animationanim_queue
 
TilePointerMatrix canvas
 
TilePointerMatrix buffer
 
std::vector< std::vector
< IntPoint > > 
bresenham_lines
 
std::vector< Enemy * > enemy_list
 

Detailed Description

GAME.H

This file is part of ROGUELIKETHING.

ROGUELIKETHING is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ROGUELIKETHING is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROGUELIKETHING. If not, see http://www.gnu.org/licenses/. struct TilePoint { Tile tile; IntPoint loc; };

Member Function Documentation

void Game::get_item ( Character chara)
Todo:
Make this take in a character so that other characters can call it?
Todo:
Add a check if the inventory is full
Tile * Game::get_tile ( int  row,
int  col 
)
private

Public accessor for the tile at canvas[row][col].

Tile * Game::get_tile ( IntPoint  point)
private

Public accessor for the tile at canvas[point.row][point.col].

bool Game::in_buffer ( int  row,
int  col 
)
private

Returns whether or not the chunk is currently in the buffer.

bool Game::in_range ( IntPoint  chunk,
IntPoint  coords,
IntPoint  range_chunk,
IntPoint  center,
IntPoint  radius 
)
private

Checks if one point is within a certain radius of another.

Parameters
chunkThe chunk of the point to check.
coordsThe coords of the point to check.
range_chunkThe chunk of the second point to check.
centerThe coords of the second chunk to check.
radiusThe radius around the first check.
Returns
Whether or not the point is in range.
Item * Game::item_at_coords ( IntPoint  coords,
IntPoint  chunk,
int  depth 
)
private

Gets the item at the specific coordinates.

Parameters
coordsThe coordinates in the chunk.
chunkThe chunk of the item.
Returns
The item at the coordinates. NULL if none is found.
bool Game::out_of_bounds ( IntPoint  point)
private

Checks if the point at (point.row, point.col) is out of the screen.

bool Game::out_of_bounds ( int  row,
int  col 
)
private

Checks if the point at (row, col) is out of the screen.

PRE: Will be given two ints representing a row and column. POST: Returns true if the given point is out of bounds on the canvas, and false otherwise.

void Game::point_assertions ( int  row,
int  col 
)
private

Assertions to ensure that the current point is in the screen.

Parameters
rowThe row of the point.
colThe column of the point.
void Game::recalculate_visibility_lines ( int  size)

PRE: Will be given :int size:, the radius of the FOV circle POST: Will set bresenham_lines, a vector of IntPoint vectors containing points for raytraced lines.

void Game::run_enemies ( long  delta_ms)

FIX THIS MEMORY LEAK!!!

void Game::set_tile ( int  row,
int  col,
Tile tile 
)
private

Sets the point in the canvas at row, col to Tile

Parameters
rowThe row of the canvas to set the tile.
colThe column of the canvas to set the tile.
tileThe tile to set row, col to.
void Game::set_tile ( IntPoint  point,
Tile tile 
)
private

Sets the point in the canvas at IntPoint to tile.

Parameters
pointThe point of the canvas to set the tile.
tileThe tile to set the IntPoint of the canvas to.
void Game::teleport ( int  chunk_x,
int  chunk_y,
int  x,
int  y 
)

Debug function to teleport the character to a new place.

void Game::update_buffer ( IntPoint  central_chunk)

This part is a bit confusing. What I need is to write the contents of the chunk to the appropriate place in the buffer. A and B represent the Y and X of individual tiles. So, for each chunk, the X and Y are written to the buffer. The chunks that we're iterating through are essentially a 3x3 array. Each chunk needs to start being written at the appropriate location (e.g. the second chunk needs to start where the first one left off...), which is where the x and y variables come in. Starting at 0, the x and y are multiplied by the width/height of the chunk, which is added to a and b to get where the tile from the chunk corresponding to a and b should be written to the buffer. For example: The first chunk should start writing tiles to the buffer at 0,0. The second chunk should start writing tiles at 0 + CHUNK_WIDTH, and the third tile should start writing at 0 + (CHUNK_WIDTH * 2).

void Game::update_main_char_chunk ( )
private

What does this do? I have no idea.

Member Data Documentation

std::vector<Animation> Game::anim_queue
private

Whenever a new animation needs to be performed, it should be added to this queue.

ChunkMatrix Game::chunk_map
private

A two dimentsional vector containing the chunks. This is the core of how the game doesn't run out of memory. It's broken up into chunks, which are then serialized/deserialized as the player moves about.

See also
Chunk
bool Game::initialized
private

Whether or not the game has been initialized.

bool Game::paused
private

If the game is currently paused. This isn't a game state because things still need to be happening in other game states while the game is paused.

Tile Game::tile_index[td::TILE_TYPE_COUNT]
private

Holds any tiles that we need to make pointers to.

MapTileMatrix Game::world_map
private

The map of the world.

See also
MapTile

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