nsnake
Classic snake game for the terminal
|
A level where the snake runs and eats fruits. More...
#include <Board.hpp>
Public Types | |
enum | Style { SOLID , TELEPORT } |
If the player will teleport when reaching the Board's limits or not. More... | |
Public Member Functions | |
Board (int width, int height, Style style) | |
Creates a new Board. | |
bool | isWall (int x, int y) |
Tells if there's a wall at #x #y. | |
bool | isBorder (int x, int y) |
int | getW () |
int | getH () |
void | draw (Window *win) |
void | randomlyFillExceptBy (int x, int y) |
Places random walls all over the Board except by #x and #y, allowing the Player to move a little bit when starting. | |
void | teleport (Player *player) |
Makes the Player teleport if it's on a border. | |
void | clear () |
Makes the whole level empty. | |
void | setBoard (std::vector< std::vector< bool > > &newBoard) |
Sets the whole level content. | |
int | getStartX () |
int | getStartY () |
void | setStartX (int x) |
void | setStartY (int y) |
void | setMetadata (std::string name, std::string value) |
Sets a meta information from this level. | |
std::string | getMetadata (std::string name) |
Gets a meta information from this level. | |
bool | hasMetadata (std::string name) |
Tells if this level has a specific information attached. | |
void | scrollLeft () |
void | scrollRight () |
void | scrollUp () |
void | scrollDown () |
Public Attributes | |
Style | style |
Tells if the player will teleport when reaching the Board's limits or not. | |
Static Public Attributes | |
static int | small_width = 40 |
static int | small_height = 10 |
static int | medium_width = 55 |
static int | medium_height = 14 |
static int | large_width = 78 |
static int | large_height = 21 |
A level where the snake runs and eats fruits.
This class represents a single level the snake can play on.
It is essentially a 2D matrix of tiles, where each can be either "Walls" or "Empty.
It also contains some extra info, like the position where the player should spawn, and (if this level was created by someone) the author, date and stuff.
enum Board::Style |
Board::Board | ( | int | width, |
int | height, | ||
Style | style ) |
std::string Board::getMetadata | ( | std::string | name | ) |
bool Board::hasMetadata | ( | std::string | name | ) |
bool Board::isWall | ( | int | x, |
int | y ) |
void Board::randomlyFillExceptBy | ( | int | x, |
int | y ) |
void Board::setBoard | ( | std::vector< std::vector< bool > > & | newBoard | ) |
void Board::setMetadata | ( | std::string | name, |
std::string | value ) |
void Board::teleport | ( | Player * | player | ) |
Style Board::style |