![]() |
4-gewinnt
1.0.0
Klassiker "4-gewinnt" als Konsolenanwendung
|
#include <string.h>
gehe zum Quellcode dieser Datei
Funktionen | |
int | newBoard (struct board *target, unsigned int width, unsigned int height) |
void | clearBoard (struct board *target) |
char * | calcFieldAddress (struct board *target, int x, int y) |
char | getField (struct board *target, int x, int y) |
void | setField (struct board *target, int x, int y, char value) |
void | freeBoard (struct board *target) |
void | drawBoard (struct board *target) |
Variablen | |
struct board | myBoard |
char* calcFieldAddress | ( | struct board * | target, |
int | x, | ||
int | y | ||
) |
Internal helper method to calculate the data offset of a given field on the board
target | Board to base calculations on. |
x | X-coordinate. |
y | Y-coordinate. |
Definiert in Zeile 60 der Datei board.c.
Benutzt board::content und board::width.
Wird benutzt von animateFalling(), getField() und setField().
void clearBoard | ( | struct board * | target | ) |
Removes all chips from the board
target | Already existing board. |
Definiert in Zeile 43 der Datei board.c.
Benutzt board::content, FIELD_EMPTY und board::numberOfFields.
Wird benutzt von clearAll() und newBoard().
void drawBoard | ( | struct board * | target | ) |
Outputs a graphical representation of the given board to the console
target | Board to draw. |
Definiert in Zeile 103 der Datei board.c.
Benutzt EXITCODE_OUTOFMEMORY, FIELD_EMPTY, FIELD_PLAYER1, FIELD_PLAYER2, FONT_COIN_EMPTY, FONT_COIN_PLAYER1, FONT_COIN_PLAYER2, FONT_DPIPE_BOTTOM_LEFT, FONT_DPIPE_BOTTOM_RIGHT, FONT_DPIPE_CROSSING, FONT_DPIPE_HORI_BAR, FONT_DPIPE_TBAR_DOWN, FONT_DPIPE_TBAR_LEFT, FONT_DPIPE_TBAR_RIGHT, FONT_DPIPE_TBAR_UP, FONT_DPIPE_TOP_LEFT, FONT_DPIPE_TOP_RIGHT, FONT_DPIPE_VERT_BAR, getField(), board::height, output(), strcatRepeat() und board::width.
Wird benutzt von animateFalling(), gameFunction() und playerAction().
void freeBoard | ( | struct board * | target | ) |
Frees memory taken by a board (warning: makes it unusable until newBoard() has been called again)
target | Board to free memory. |
Definiert in Zeile 95 der Datei board.c.
Benutzt board::content.
Wird benutzt von clearAll().
char getField | ( | struct board * | target, |
int | x, | ||
int | y | ||
) |
Gets what is on a given field of the board (returns FIELD_XYZ constant)
target | Board to read. |
x | X-coordinate. |
y | Y-coordinate. |
Definiert in Zeile 72 der Datei board.c.
Benutzt calcFieldAddress(), FIELD_OUTOFBOUNDS, board::height und board::width.
Wird benutzt von checkDraw(), drawBoard(), neighbourRow() und throwCoin().
int newBoard | ( | struct board * | target, |
unsigned int | width, | ||
unsigned int | height | ||
) |
Creates new clean and usable board (including memory allocation) Warning: To resize an existing board call freeBoard() before to prevent memory leak
target | Pointer to a fresh board structure. |
width | Board width (>=4). |
height | Board height (>=4). |
Definiert in Zeile 15 der Datei board.c.
Benutzt clearBoard(), board::content, EXITCODE_OUTOFMEMORY, board::height, board::numberOfFields und board::width.
Wird benutzt von startGame().
void setField | ( | struct board * | target, |
int | x, | ||
int | y, | ||
char | value | ||
) |
Sets what is on a given field of the board (see FIELD_XYZ constants)
target | Board to change. |
x | X-coordinate. |
y | Y-coordinate. |
value | Field value (FIELD_EMPTY/FIELD_PLAYER1/FIELD_PLAYER2). |
Definiert in Zeile 87 der Datei board.c.
Benutzt calcFieldAddress().
Wird benutzt von throwCoin().