From: Tobias Gläßer Date: Mon, 29 Dec 2003 20:40:32 +0000 (+0000) Subject: update, the location of themes has changed. You can also find a initial save & load... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d4ee7a81b7b3dd9d2288d301c10aeb0bc48396e9;p=supertux.git update, the location of themes has changed. You can also find a initial save & load feature, but it is far from beeing finished. SVN-Revision: 80 --- diff --git a/src/gameloop.c b/src/gameloop.c index e1f4e7324..91cf437ef 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #ifdef LINUX @@ -103,7 +104,6 @@ void unloadlevelsong(void); void loadshared(void); void unloadshared(void); void drawshape(int x, int y, unsigned char c); -void savegame(void); unsigned char shape(int x, int y, int sx); int issolid(int x, int y, int sx); int isbrick(int x, int y, int sx); @@ -2585,7 +2585,7 @@ SDL_Surface * load_level_image(char * file, int use_alpha) { char fname[1024]; - snprintf(fname, 1024, "%s/images/%s/%s", DATA_PREFIX, leveltheme, file); + snprintf(fname, 1024, "%s/images/themes/%s/%s", DATA_PREFIX, leveltheme, file); return(load_image(fname, use_alpha)); } @@ -3842,4 +3842,65 @@ void drawresultscreen(void) } void savegame(void) -{} +{ +char savefile[300]; + +time_t current_time = time(NULL); +struct tm* time_struct; +time_struct = localtime(¤t_time); +sprintf(savefile,"%s/%d-%d-%d-%d.save",st_save_dir,time_struct->tm_year+1900,time_struct->tm_mon,time_struct->tm_mday,time_struct->tm_hour); +printf("%s",savefile); + +FILE* fi; + + fi = fopen(savefile, "wb"); + + if (fi == NULL) + { + fprintf(stderr, "Warning: I could not open the high score file "); + + } + else + { + fwrite(&level,4,1,fi); + fwrite(&score,4,1,fi); + fwrite(&distros,4,1,fi); + fwrite(&tux_x,4,1,fi); + fwrite(&tux_y,4,1,fi); + fwrite(&scroll_x,4,1,fi); + } + fclose(fi); + +} + +void loadgame(char* filename) +{ +char savefile[300]; + +time_t current_time = time(NULL); +struct tm* time_struct; +time_struct = localtime(¤t_time); +sprintf(savefile,"%s/%d-%d-%d-%d.save",st_save_dir,time_struct->tm_year+1900,time_struct->tm_mon,time_struct->tm_mday,time_struct->tm_hour); +printf("%s",savefile); + +FILE* fi; + + fi = fopen(savefile, "rb"); + + if (fi == NULL) + { + fprintf(stderr, "Warning: I could not open the high score file "); + + } + else + { + fread(&level,4,1,fi); + fread(&score,4,1,fi); + fread(&distros,4,1,fi); + fread(&tux_x,4,1,fi); + fread(&tux_y,4,1,fi); + fread(&scroll_x,4,1,fi); + fclose(fi); + } + +} \ No newline at end of file diff --git a/src/gameloop.h b/src/gameloop.h index 6b6c825d2..256430ecf 100644 --- a/src/gameloop.h +++ b/src/gameloop.h @@ -144,6 +144,8 @@ /* Function prototypes: */ int gameloop(void); - + void savegame(void); + void loadgame(char* filename); + #endif