diff --git a/src/defines.h b/src/defines.h index 6544f62..c9f975f 100644 --- a/src/defines.h +++ b/src/defines.h @@ -2,12 +2,16 @@ #define DEFINES_H_ /* Room/Map dimensions */ -#define MAP_ROOM_HEIGHT 12 #define MAP_ROOM_WIDTH 16 +#define MAP_ROOM_HEIGHT 12 #define MAP_V_ROOM_COUNT 10 #define MAP_H_ROOM_COUNT 10 -#define TILE_DIMENSION 64 +#define TILE_DIMENSION 32 + +/* Display stuff */ +#define SCREEN_WIDTH MAP_ROOM_WIDTH * TILE_DIMENSION +#define SCREEN_HEIGHT MAP_ROOM_HEIGHT * TILE_DIMENSION #endif // DEFINES_H_ diff --git a/src/main.c b/src/main.c index 52c84b0..73afc9c 100644 --- a/src/main.c +++ b/src/main.c @@ -13,9 +13,6 @@ #include "timer.h" #include "roommatrix.h" -#define SCREEN_WIDTH 1024 -#define SCREEN_HEIGHT 768 - static SDL_Window *gWindow = NULL; static SDL_Renderer *gRenderer = NULL; static Sprite *gPlayer = NULL; diff --git a/src/player.c b/src/player.c index 9de4713..0fd035a 100644 --- a/src/player.c +++ b/src/player.c @@ -101,9 +101,9 @@ Sprite* player_create(class_t class, SDL_Renderer *renderer) } sprite_load_texture(player, asset, renderer); - player->pos = (Position) { 64, 64 }; + player->pos = (Position) { TILE_DIMENSION, TILE_DIMENSION }; player->texture->clip = (SDL_Rect) { 0, 0, 16, 16 }; - player->texture->dim = (Dimension) { 64, 64 }; + player->texture->dim = (Dimension) { TILE_DIMENSION, TILE_DIMENSION }; player->handle_event = &handle_player_input; return player; diff --git a/src/roommatrix.c b/src/roommatrix.c index bda7614..9d8d70a 100644 --- a/src/roommatrix.c +++ b/src/roommatrix.c @@ -57,7 +57,7 @@ static void set_light_for_tile(RoomMatrix *matrix, int x, int y) { int x_max, x_min, y_max, y_min, i, j; - int lightval; + int lightval, distance_modifier; RoomSpace *space; space = &matrix->spaces[x][y]; @@ -74,7 +74,8 @@ set_light_for_tile(RoomMatrix *matrix, int x, int y) for (i = x_min; i <= x_max; ++i) { for (j = y_min; j <= y_max; ++j) { lightval = matrix->spaces[i][j].light; - lightval += 255 - (max(abs(x-i), abs(y-j)) * 50); + distance_modifier = abs(x-i) == abs(y-j) ? abs(x-i) + 1 : max(abs(x-i), abs(y-j)); + lightval += 255 - (distance_modifier * 50); lightval = min(255, lightval); lightval = max(0, lightval); matrix->spaces[i][j].light = lightval; @@ -104,7 +105,12 @@ roommatrix_render_lightmap(RoomMatrix *matrix, Camera *cam) light = max(0, 230 - matrix->spaces[i][j].light); SDL_SetRenderDrawColor(cam->renderer, 0, 0, 0, light); - SDL_Rect box = (SDL_Rect) { i*64, j*64, 64, 64 }; + SDL_Rect box = (SDL_Rect) { + i*TILE_DIMENSION, + j*TILE_DIMENSION, + TILE_DIMENSION, + TILE_DIMENSION + }; SDL_RenderFillRect(cam->renderer, &box); } }