Added basic saving funcionality.

This commit is contained in:
Sheldon Lee
2020-07-04 00:26:34 +01:00
parent 4e9422b672
commit 67e216d4ee
3 changed files with 29 additions and 2 deletions
+23
View File
@@ -2,6 +2,7 @@
#include "game.h"
#include "grid.h"
#include "vect.h"
#include "log.h"
static Grid* grid = 0;
@@ -122,6 +123,28 @@ void drawCurPos()
attroff(COLOR_PAIR(3));
}
void saveGame(char* name)
{
unsigned int width, height;
getDimensions(grid, &width, &height);
FILE* file = fopen(name, "w");
if (file) {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
fprintf(file, "%i", getPixel(grid, x, y));
}
fprintf(file, "\n");
}
fclose(file);
}
}
void loadGame(char* name)
{
}
void endGame()
{
// free stuff