![]() |
4-gewinnt
1.0.0
Klassiker "4-gewinnt" als Konsolenanwendung
|
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
gehe zum Quellcode dieser Datei
Funktionen | |
void | initBuffer () |
struct LineItem * | insertNewLineItem (struct LineItem *prev, struct LineItem *next, int maxTextLength) |
void | deleteLineItem (struct LineItem *line, int deleteAllBelow) |
int | copyChar (char *src, char *dst) |
int | output (const char *input,...) |
void | flushBuffer () |
void | startBuffer (int maxTextLength) |
void | setLineAlign (int align) |
void | printfBanner (int width, int startAt) |
void | animateBanner (int slideIn) |
void | animateBox (int wFrom, int hFrom, int wTo, int hTo) |
void | printEmptyBox (int w, int h) |
void | consoleClear () |
char | lower_to_upper (char ch1) |
void | strcatRepeat (char *target, const char *source, unsigned int howOften) |
Variablen | |
struct OutBuffer | display |
CONSOLE_SCREEN_BUFFER_INFO | csbi |
int | consoleBufferWidth = 80 |
int | consoleBufferHeight = 15 |
void animateBanner | ( | int | slideIn | ) |
Animate ASCII art logo.
slideIn | Set to 1 for slide in from top, 0 for slide out. |
Definiert in Zeile 378 der Datei system.c.
Benutzt consoleBufferWidth, consoleClear() und printfBanner().
Wird benutzt von mainMenu().
void animateBox | ( | int | wFrom, |
int | hFrom, | ||
int | wTo, | ||
int | hTo | ||
) |
Change the horizontal align of the current line within the buffer box
align | Left align (-1), centered (0) or right align (+1). |
Definiert in Zeile 392 der Datei system.c.
Benutzt printEmptyBox().
Wird benutzt von mainMenu() und showCredits().
void consoleClear | ( | ) |
Clears the console
Definiert in Zeile 428 der Datei system.c.
Wird benutzt von animateBanner(), flushBuffer() und gameFunction().
int copyChar | ( | char * | src, |
char * | dst | ||
) |
Copy one character (UTF8-aware) from the source string to the target string and append a null byte afterwards
src | Source string pointer. |
dst | Destination string pointer. |
Definiert in Zeile 114 der Datei system.c.
Benutzt LineItem::length.
Wird benutzt von output().
void deleteLineItem | ( | struct LineItem * | line, |
int | deleteAllBelow | ||
) |
Delete the given line from the buffer
line | Pointer to the line struct to delete. |
deleteAllBelow | Delete all the following lines as well (1) or just the given line (0). |
Definiert in Zeile 84 der Datei system.c.
Benutzt display, OutBuffer::lineCount, LineItem::next, LineItem::prev und LineItem::text.
Wird benutzt von flushBuffer() und startBuffer().
void flushBuffer | ( | ) |
Prints the screen (output buffer) and clears the buffer
Definiert in Zeile 188 der Datei system.c.
Benutzt LineItem::align, consoleBufferHeight, consoleBufferWidth, consoleClear(), csbi, deleteLineItem(), display, EXITCODE_BUFFERERROR, EXITCODE_OUTOFMEMORY, FANCY_FONT, OutBuffer::first, FONT_DPIPE_BOTTOM_LEFT, FONT_DPIPE_BOTTOM_RIGHT, FONT_DPIPE_HORI_BAR, FONT_DPIPE_TOP_LEFT, FONT_DPIPE_TOP_RIGHT, FONT_DPIPE_VERT_BAR, OutBuffer::hAlign, initBuffer(), OutBuffer::last, LineItem::length, OutBuffer::lineCount, OutBuffer::maxTextLength, LineItem::next, printfBanner(), strcatRepeat(), LineItem::text, UTF_MULTIPLIER und OutBuffer::vAlign.
Wird benutzt von addFrame(), drawMainMenu(), gameFunction(), mainMenuReactToEnter(), playerAction(), printEmptyBox(), showCredits(), showHallOfShame() und showRules().
void initBuffer | ( | ) |
Initializes buffering Warning: Only call once at program start
Definiert in Zeile 15 der Datei system.c.
Benutzt display, OutBuffer::first, OutBuffer::hAlign, OutBuffer::last, OutBuffer::lineCount und OutBuffer::vAlign.
Wird benutzt von flushBuffer().
struct LineItem* insertNewLineItem | ( | struct LineItem * | prev, |
struct LineItem * | next, | ||
int | maxTextLength | ||
) |
Add a new line to the buffer, may be inserted in the middle or appended to the end Info: Horizontal align is inherited from previous line, default -1. Can be changed with setLineAlign() Warning: Use output() to add text, this method is only used internally
prev | Pointer to the previous line struct, NULL appends line to start of buffer. |
next | Pointer to the next line struct, NULL if this is the last element (most used case). |
align | Text align for the new line, -1 is left aligned, 0 is centered, +1 is right aligned. |
maxTextLength | Maximum number of characters for this line. |
Definiert in Zeile 34 der Datei system.c.
Benutzt LineItem::align, LineItem::byteSize, display, EXITCODE_OUTOFMEMORY, OutBuffer::first, OutBuffer::last, LineItem::length, OutBuffer::lineCount, LineItem::next, LineItem::prev, LineItem::text und UTF_MULTIPLIER.
Wird benutzt von output() und startBuffer().
char lower_to_upper | ( | char | ch1 | ) |
convert string to upper string
ch1 | string to be uppered |
Definiert in Zeile 444 der Datei system.c.
Wird benutzt von gameFunction().
int output | ( | const char * | input, |
... | |||
) |
Add text to output buffer, use EXACTLY like printf()
input | Format string, see printf(). |
... | Parameters, see printf(). |
Definiert in Zeile 144 der Datei system.c.
Benutzt LineItem::byteSize, copyChar(), display, EXITCODE_BUFFERERROR, OutBuffer::first, insertNewLineItem(), OutBuffer::last, LineItem::length, OutBuffer::maxTextLength, LineItem::next, OUTPUT_MAXBUFFER und LineItem::text.
Wird benutzt von addFrame(), drawBoard(), drawCoin(), drawMainMenu(), gameFunction(), HelloWorld(), mainMenuReactToEnter(), playerAction(), printEmptyBox(), showCredits(), showHallOfShame() und showRules().
void printEmptyBox | ( | int | w, |
int | h | ||
) |
Print an empty buffer box with the given size
w | Width. |
h | Height. |
Definiert in Zeile 418 der Datei system.c.
Benutzt flushBuffer(), output() und startBuffer().
Wird benutzt von animateBox().
void printfBanner | ( | int | width, |
int | startAt | ||
) |
Printf-s ASCII art logo
width | Width for padding with spaces. |
startAt | Value between 0 and 4 for partial display, see animateBanner(). |
Definiert in Zeile 356 der Datei system.c.
Benutzt LineItem::length und strcatRepeat().
Wird benutzt von animateBanner() und flushBuffer().
void setLineAlign | ( | int | align | ) |
Change the horizontal align of the current line within the buffer box
align | Left align (-1), centered (0) or right align (+1). |
Definiert in Zeile 344 der Datei system.c.
Benutzt LineItem::align, display, EXITCODE_BUFFERERROR und OutBuffer::last.
Wird benutzt von drawMainMenu(), playerAction(), showCredits(), showHallOfShame() und showRules().
void startBuffer | ( | int | maxTextLength | ) |
Starts a new screen and sets line limit, empties the buffer
maxTextLength | See initBuffer(). |
Definiert in Zeile 319 der Datei system.c.
Benutzt consoleBufferWidth, deleteLineItem(), display, EXITCODE_BUFFERERROR, EXITCODE_WINDOWERROR, OutBuffer::first, insertNewLineItem(), OutBuffer::last, OutBuffer::lineCount und OutBuffer::maxTextLength.
Wird benutzt von drawMainMenu(), gameFunction(), mainMenuReactToEnter(), playerAction(), printEmptyBox(), showCredits(), showHallOfShame() und showRules().
void strcatRepeat | ( | char * | target, |
const char * | source, | ||
unsigned int | howOften | ||
) |
Definiert in Zeile 458 der Datei system.c.
Wird benutzt von drawBoard(), flushBuffer() und printfBanner().
int consoleBufferHeight = 15 |
Definiert in Zeile 9 der Datei system.c.
Wird benutzt von flushBuffer().
int consoleBufferWidth = 80 |
Definiert in Zeile 8 der Datei system.c.
Wird benutzt von animateBanner(), flushBuffer() und startBuffer().
CONSOLE_SCREEN_BUFFER_INFO csbi |
Definiert in Zeile 7 der Datei system.c.
Wird benutzt von flushBuffer().
struct OutBuffer display |
Definiert in Zeile 6 der Datei system.c.
Wird benutzt von deleteLineItem(), flushBuffer(), initBuffer(), insertNewLineItem(), output(), setLineAlign() und startBuffer().