Add common.h with LOG macro, Add '#pragma once'
- add conditional logging macro in common.h - add '#pragma once' to every header file - fix typo in food.h
This commit is contained in:
parent
ffbe61a6e5
commit
71c054f092
24
include/common.h
Normal file
24
include/common.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "config.h"
|
||||
|
||||
//===========================
|
||||
//========= LOGGING =========
|
||||
//===========================
|
||||
//conditional logging when DEBUG_OUTPUT_ENABLED is defined in config.h
|
||||
//example: LOGD("game: %d", count)
|
||||
#ifdef DEBUG_OUTPUT_ENABLED
|
||||
#define LOGD(format, ...) printf(format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define LOGD(format, ...) do {} while (0)
|
||||
#endif
|
||||
|
||||
//conditional logging when INFO_OUTPUT_ENABLED is defined in config.h
|
||||
//example: LOGD("game: %d", count)
|
||||
#ifdef INFO_OUTPUT_ENABLED
|
||||
#define LOGI(format, ...) printf(format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define LOGI(format, ...) do {} while (0)
|
||||
#endif
|
@ -3,6 +3,9 @@
|
||||
// global configuration macros
|
||||
#define MAX_MAP_SIZE 10
|
||||
#define MAX_MAP_FIELDS (MAX_MAP_SIZE*MAX_MAP_SIZE)
|
||||
// logging settings
|
||||
#define DEBUG_OUTPUT_ENABLED
|
||||
#define INFO_OUTPUT_ENABLED
|
||||
|
||||
// struct for storing game configuration
|
||||
typedef struct config_t
|
||||
|
@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
|
||||
void placeFood();
|
||||
// platziert zufällig (mit bestimmtem Algorithmus) Fressen auf dem Spielfeld
|
||||
// darf nicht auf der Schlange oder auf Wänden sein
|
||||
|
||||
bool ckeckEaten();
|
||||
bool checkEaten();
|
||||
// Überprüft, ob Snake gefressen hat -> true wenn gefressen
|
||||
// Vergleich mit gameData_t foodX, foodY
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "snake.h"
|
||||
|
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
void processInputEvent();
|
||||
//wird von SDL aufgerufen, wenn Taste gedrückt wurde
|
||||
//bekommt Info darüber, welche Taste gedrückt wurde
|
||||
|
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
void showStartScreen();
|
||||
//zum Starten Enter drücken
|
||||
//optional: "E" eingeben für Settings
|
||||
|
@ -1,4 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "game.h"
|
||||
#include "snake.h"
|
||||
|
||||
void renderGame();
|
||||
//erstellt aus Spielfeldstruktur die graphische Anzeige mit SDL-Framework
|
@ -1,5 +1,5 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "config.h"
|
||||
|
||||
|
@ -8,7 +8,7 @@ void placeFood(int count)
|
||||
}
|
||||
|
||||
// Überprüft, ob Snake gefressen hat
|
||||
bool ckeckEaten()
|
||||
bool checkEaten()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "map.h"
|
||||
#include "game.h"
|
||||
#include "common.h"
|
||||
|
||||
// generate random map based on difficulty level
|
||||
map_t generateMap(int difficulty)
|
||||
@ -12,6 +13,7 @@ map_t generateMap(int difficulty)
|
||||
// search and load map by name (if not found loads default map)
|
||||
void loadMapByName(char *name)
|
||||
{
|
||||
LOGI("map: loading map %s", name);
|
||||
return;
|
||||
// TODO add map presets
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user