int main(int argc, char *argv[]) { tmx_map *m; if (argc != 2) { fprintf(stderr, "usage: %s <map.tmx>\n", argv[0]); return EXIT_FAILURE; } tmx_alloc_func = dbg_alloc; /* alloc/free dbg */ tmx_free_func = dbg_free; m = tmx_load(argv[1]); if (!m) tmx_perror("error"); dump_map(m); tmx_map_free(m); printf("\n%d mem alloc not freed\n", mal_vs_free_count); #ifdef PAUSE puts("press <Enter> to quit\n"); getchar(); #endif return EXIT_SUCCESS; }
/* We use libtmx to load our game's Tiled file and * then call read_map to store our required tilemap * layers. */ static int build_tilemap(struct game* game) { tmx_map* m; m = tmx_load("res/game.tmx"); if (m == NULL) { printf("Error reading tmx file."); goto error; } else { if (read_map(game, m) == -1) goto error; } return 0; error: return -1; }
int main(int argc, char *argv[]) { /*main code here.*/ tmx_img_load_func = (void* (*)(const char *))sdl_img_loader; tmx_img_free_func = (void (*)(void *)) SDL_DestroyTexture; tmx_map *mmap = tmx_load("data/class_school01.tmx"); init(&g); g.map = mmap; //tmx_load("data/class_school01.tmx"); g.game_state = GAME_INIT; while(g.game_state != GAME_EXIT) { update(&g); render(&g); } printf("exited\n"); }