Fixed some messages with bad newlines and added crash notification.
This commit is contained in:
parent
8e2d6b0fd4
commit
dda89f65e7
33
src/main.c
33
src/main.c
|
@ -39,25 +39,26 @@ bool initSDL(void)
|
||||||
//Dimension dim = (Dimension) { 1920, 1080 };
|
//Dimension dim = (Dimension) { 1920, 1080 };
|
||||||
|
|
||||||
if (dim.height > 1080) {
|
if (dim.height > 1080) {
|
||||||
info("Hi resolution screen detected (%u x %u)\n", dim.width, dim.height);
|
info("Hi resolution screen detected (%u x %u)", dim.width, dim.height);
|
||||||
renderScale = ((double) dim.height)/1080;
|
//renderScale = ((double) dim.height)/1080;
|
||||||
info("Scaling by %f\n", renderScale);
|
renderScale = 4;
|
||||||
|
info("Scaling by %f", renderScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||||
{
|
{
|
||||||
error("Could not initiate SDL2: %s\n", SDL_GetError());
|
error("Could not initiate SDL2: %s", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (IMG_Init(imgFlags) & imgFlags) == 0 ) {
|
if ( (IMG_Init(imgFlags) & imgFlags) == 0 ) {
|
||||||
error("Unable to initiate img loading: %s\n",
|
error("Unable to initiate img loading: %s",
|
||||||
IMG_GetError());
|
IMG_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( TTF_Init() == -1 ) {
|
if ( TTF_Init() == -1 ) {
|
||||||
error("Unable to initiate ttf library: %s\n",
|
error("Unable to initiate ttf library: %s",
|
||||||
TTF_GetError());
|
TTF_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -66,27 +67,27 @@ bool initSDL(void)
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
(int)(SCREEN_WIDTH * renderScale),
|
(int)(SCREEN_WIDTH * renderScale),
|
||||||
(int)((SCREEN_HEIGHT * renderScale)),
|
(int)(SCREEN_HEIGHT * renderScale),
|
||||||
SDL_WINDOW_SHOWN);
|
SDL_WINDOW_SHOWN);
|
||||||
if (gWindow == NULL)
|
if (gWindow == NULL)
|
||||||
{
|
{
|
||||||
error("Unable to create window: %s\n", SDL_GetError());
|
error("Unable to create window: %s", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED);
|
gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED);
|
||||||
if (gRenderer == NULL)
|
if (gRenderer == NULL)
|
||||||
{
|
{
|
||||||
error("Unable to create renderer: %s\n", SDL_GetError());
|
error("Unable to create renderer: %s", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (SDL_SetRenderDrawBlendMode(gRenderer, SDL_BLENDMODE_BLEND) < 0) {
|
if (SDL_SetRenderDrawBlendMode(gRenderer, SDL_BLENDMODE_BLEND) < 0) {
|
||||||
error("Unable to set blend mode: %s\n", SDL_GetError());
|
error("Unable to set blend mode: %s", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (SDL_RenderSetLogicalSize(gRenderer, SCREEN_WIDTH, SCREEN_HEIGHT) < 0)
|
if (SDL_RenderSetLogicalSize(gRenderer, SCREEN_WIDTH, SCREEN_HEIGHT) < 0)
|
||||||
{
|
{
|
||||||
error("Unable to initiate scaling: %s\n",
|
error("Unable to initiate scaling: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -168,11 +169,11 @@ check_next_level(void)
|
||||||
|
|
||||||
MapTile *tile = room->tiles[pos.x][pos.y];
|
MapTile *tile = room->tiles[pos.x][pos.y];
|
||||||
if (!tile) {
|
if (!tile) {
|
||||||
error("Looks like we are out of place\n");
|
error("Looks like we are out of place");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tile->levelExit) {
|
if (tile->levelExit) {
|
||||||
info("Building new map\n");
|
info("Building new map");
|
||||||
map_destroy(gMap);
|
map_destroy(gMap);
|
||||||
gMap = map_lua_generator_run(++cLevel, gRenderer);
|
gMap = map_lua_generator_run(++cLevel, gRenderer);
|
||||||
gPlayer->sprite->pos = (Position) {
|
gPlayer->sprite->pos = (Position) {
|
||||||
|
@ -234,13 +235,13 @@ void run(void)
|
||||||
run_game();
|
run_game();
|
||||||
break;
|
break;
|
||||||
case MENU:
|
case MENU:
|
||||||
error("MENU not implemented\n");
|
error("MENU not implemented");
|
||||||
break;
|
break;
|
||||||
case IN_GAME_MENU:
|
case IN_GAME_MENU:
|
||||||
error("IN_GAME_MENU not implemented\n");
|
error("IN_GAME_MENU not implemented");
|
||||||
break;
|
break;
|
||||||
case GAME_OVER:
|
case GAME_OVER:
|
||||||
error("GAME_OVER not implemented\n");
|
error("GAME_OVER not implemented");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -49,6 +49,8 @@ has_collided(Player *player, RoomMatrix *matrix)
|
||||||
|
|
||||||
gui_log("You killed '%s' and gained %d xp", space->monster->label, 10);
|
gui_log("You killed '%s' and gained %d xp", space->monster->label, 10);
|
||||||
}
|
}
|
||||||
|
} else if (collided) {
|
||||||
|
gui_log("Ouch! There is something in the way");
|
||||||
}
|
}
|
||||||
|
|
||||||
return collided;
|
return collided;
|
||||||
|
|
Loading…
Reference in New Issue