73 lines
1.8 KiB
C
73 lines
1.8 KiB
C
#include "main.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include "logHelper.h"
|
|
#include <SDL2/SDL.h>
|
|
#include <SDL2/SDL_image.h>
|
|
//#include <SDL2/SDL_ttf.h>
|
|
//#include <SDL2/SDL_thread.h>
|
|
//#include <SDL2/SDL_mutex.h>
|
|
#include "arenaEngine.h"
|
|
#include "arenaGUI.h"
|
|
#include "IAEngine.h"
|
|
#include "playerInterface.h"
|
|
|
|
|
|
void initDisplayLib() {
|
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
|
addLogCritical("Init SDL libs failed !");
|
|
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
|
|
int random_lim(int max) {
|
|
int r, d = RAND_MAX / max;
|
|
max *= d;
|
|
do { r = rand(); } while (r >= max);
|
|
return r / d;
|
|
}
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
addLogInfo("Starting game...");
|
|
srand(time(NULL));
|
|
addLogInfo("Try init SDL libs...");
|
|
initDisplayLib();
|
|
|
|
addLogInfo("Load ressources in memory...");
|
|
TILE *tile_ressources = createTileList();
|
|
PLAYER *player_ressources = createPlayerList();
|
|
|
|
addLogInfo("Create SDL windows instance...");
|
|
SDL_Window* gameWindows = SDL_CreateWindow("Arena Survival Tournament - alpha 0.3", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOWS_WIDTH, WINDOWS_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS);
|
|
|
|
addLogInfo("Creating new arena...");
|
|
ARENA_H_TILE* arena = NULL;
|
|
arena = genNewArena(A_HEIGHT, A_WIDTH);
|
|
if (arena == NULL) {
|
|
addLogCritical("Error with arena generator !");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
addLogInfo("Successfully created arena.");
|
|
|
|
addLogInfo("Display arena GUI...");
|
|
displayArena(arena, gameWindows, tile_ressources, A_HEIGHT, A_WIDTH, TILE_SIZE);
|
|
|
|
|
|
SDL_Delay(3000);
|
|
|
|
deleteArena(arena);
|
|
addLogInfo("Cleared arena.");
|
|
|
|
clearRessourcesCache(tile_ressources, player_ressources);
|
|
addLogInfo("Free ressources.");
|
|
|
|
|
|
addLogInfo("Unload SDL libs...");
|
|
SDL_Quit();
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|