nsnake
Classic snake game for the terminal
Functions | Variables
Globals Namespace Reference

Container for global settings on the game. More...

Functions

void init ()
 Initializes global variables with default values. More...
 
void loadFile ()
 Loads global variables from the default file. More...
 
void saveFile ()
 Loads global variables to the default file. More...
 
void warnErrors ()
 Warns the user about any errors and warnings found during the program's execution. More...
 

Variables

char version [3]
 Game version (format MMP - Major Minor Patch). More...
 

Detailed Description

Container for global settings on the game.

It holds all global variables, properly initializing their default values.


Global variables are spread across inner namespaces.

Usage

Make sure to follow this order:

Globals::init();
Globals::loadFile();
// Run your game...
Globals::saveFile();
Globals::exit();

Function Documentation

◆ init()

void Globals::init ( )

Initializes global variables with default values.

HACK Initializing the default level file directory. I know this is hacky, but couldn't find another way to initialize it.

Making sure they both exist...!

Definition at line 78 of file Globals.cpp.

◆ loadFile()

void Globals::loadFile ( )

Loads global variables from the default file.

Check Globals::Config::file for its filename.

Definition at line 141 of file Globals.cpp.

◆ saveFile()

void Globals::saveFile ( )

Loads global variables to the default file.

Check Globals::Config::file for its filename.

Definition at line 262 of file Globals.cpp.

◆ warnErrors()

void Globals::warnErrors ( )

Warns the user about any errors and warnings found during the program's execution.

Note
You must call this after finishing up nCurses, otherwise things will get messed up on the terminal.

Definition at line 371 of file Globals.cpp.

Variable Documentation

◆ version

char Globals::version
Initial value:
= { VERSION[0],
VERSION[2],
VERSION[4] }

Game version (format MMP - Major Minor Patch).

On the Makefile we define a constant VERSION which is a string like "2.0.8". It contains the current game version on MAJOR.MINOR.PATCH format.

This variable contains the same info, but without the dots.

Definition at line 15 of file Globals.cpp.