Switched from 64 tile dimension to 32

64 didn't look very nice on a regular HD screen. Only on my tricky hiDPI
laptop.
This commit is contained in:
Linus Probert 2017-12-10 23:49:15 +01:00
parent a1c57b62d0
commit cdf4949eea
4 changed files with 17 additions and 10 deletions

View File

@ -2,12 +2,16 @@
#define DEFINES_H_ #define DEFINES_H_
/* Room/Map dimensions */ /* Room/Map dimensions */
#define MAP_ROOM_HEIGHT 12
#define MAP_ROOM_WIDTH 16 #define MAP_ROOM_WIDTH 16
#define MAP_ROOM_HEIGHT 12
#define MAP_V_ROOM_COUNT 10 #define MAP_V_ROOM_COUNT 10
#define MAP_H_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_ #endif // DEFINES_H_

View File

@ -13,9 +13,6 @@
#include "timer.h" #include "timer.h"
#include "roommatrix.h" #include "roommatrix.h"
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768
static SDL_Window *gWindow = NULL; static SDL_Window *gWindow = NULL;
static SDL_Renderer *gRenderer = NULL; static SDL_Renderer *gRenderer = NULL;
static Sprite *gPlayer = NULL; static Sprite *gPlayer = NULL;

View File

@ -101,9 +101,9 @@ Sprite* player_create(class_t class, SDL_Renderer *renderer)
} }
sprite_load_texture(player, asset, 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->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; player->handle_event = &handle_player_input;
return player; return player;

View File

@ -57,7 +57,7 @@ static void
set_light_for_tile(RoomMatrix *matrix, int x, int y) set_light_for_tile(RoomMatrix *matrix, int x, int y)
{ {
int x_max, x_min, y_max, y_min, i, j; int x_max, x_min, y_max, y_min, i, j;
int lightval; int lightval, distance_modifier;
RoomSpace *space; RoomSpace *space;
space = &matrix->spaces[x][y]; 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 (i = x_min; i <= x_max; ++i) {
for (j = y_min; j <= y_max; ++j) { for (j = y_min; j <= y_max; ++j) {
lightval = matrix->spaces[i][j].light; 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 = min(255, lightval);
lightval = max(0, lightval); lightval = max(0, lightval);
matrix->spaces[i][j].light = 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); light = max(0, 230 - matrix->spaces[i][j].light);
SDL_SetRenderDrawColor(cam->renderer, SDL_SetRenderDrawColor(cam->renderer,
0, 0, 0, light); 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); SDL_RenderFillRect(cam->renderer, &box);
} }
} }