A game engine for top-down 2D RPG games.
rpg game-engine raylib c99
1#include <keraforge.h> 2#include <stdio.h> 3#include <stdlib.h> 4 5int kf_exists(char *filename) 6{ 7 FILE *fp = fopen(filename, "r"); 8 bool opened = fp != NULL; 9 if (opened) 10 fclose(fp); 11 return opened; 12} 13 14u8 *kf_readbin(char *filename, size_t *plen) 15{ 16 FILE *fp = fopen(filename, "rb"); 17 if (!fp) 18 return NULL; 19 20 *plen = 0; 21 fseek(fp, 0, SEEK_END); 22 *plen = ftell(fp); 23 fseek(fp, 0, SEEK_SET); 24 if (*plen == 0) 25 { 26 fclose(fp); 27 return NULL; 28 } 29 30 u8 *data = malloc(*plen); 31 (void)fread(data, 1, *plen, fp); 32 fclose(fp); 33 34 return data; 35} 36 37int kf_writebin(char *filename, u8 *data, size_t len) 38{ 39 FILE *fp = fopen(filename, "wb"); 40 if (!fp) 41 return 0; 42 43 size_t n = fwrite(data, 1, len, fp); 44 fclose(fp); 45 46 if (n != len) 47 return 0; 48 49 return 1; 50}