mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-17 05:55:46 +01:00
rework rendering slightly to include a border
This commit is contained in:
@@ -35,7 +35,7 @@ int renderer_init(SDL_Window** window, SDL_Renderer** renderer) {
|
||||
|
||||
// draws a block at the specified position
|
||||
static inline int draw_block(SDL_Renderer* renderer, int8_t x, int8_t y) {
|
||||
return SDL_RenderFillRect(renderer, &(SDL_Rect){x * BLOCK_WIDTH + 1, y * BLOCK_HEIGHT + 1, BLOCK_WIDTH - 1, BLOCK_HEIGHT - 1});
|
||||
return SDL_RenderFillRect(renderer, &(SDL_Rect){x * BLOCK_WIDTH + 1 + TET_PADDING, y * BLOCK_HEIGHT + 1 + TET_PADDING, BLOCK_WIDTH - 1, BLOCK_HEIGHT - 1});
|
||||
}
|
||||
|
||||
// sets the colour32 from the colour8
|
||||
@@ -84,6 +84,9 @@ void renderer_update(const RenderData* render_data) {
|
||||
set_colour(renderer, COLOUR_BLACK);
|
||||
success |= SDL_RenderClear(renderer);
|
||||
|
||||
set_colour(renderer, COLOUR_WHITE);
|
||||
SDL_RenderDrawRect(renderer, &(SDL_Rect){TET_PADDING, TET_PADDING, TET_WIDTH + 1, TET_HEIGHT + 1});
|
||||
|
||||
render_level(renderer, render_data->game_data);
|
||||
render_selected(renderer, render_data->game_data);
|
||||
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
|
||||
#include "../game/game.h"
|
||||
|
||||
#define SCREEN_WIDTH (COLUMNS * 25)
|
||||
#define SCREEN_HEIGHT (SCREEN_WIDTH / COLUMNS * ROWS)
|
||||
#define BLOCK_WIDTH (SCREEN_WIDTH / COLUMNS)
|
||||
#define BLOCK_HEIGHT (SCREEN_HEIGHT / ROWS)
|
||||
#define SCREEN_RESOLUTION 25 // pixels per block
|
||||
#define SCREEN_WIDTH ((COLUMNS) * 25) // window width
|
||||
#define SCREEN_HEIGHT (SCREEN_WIDTH / COLUMNS * ROWS) // window height
|
||||
#define TET_PADDING 10 // padding around the tetris playing field
|
||||
#define TET_WIDTH (SCREEN_WIDTH - TET_PADDING * 2) // tetris playing field width
|
||||
#define TET_HEIGHT (SCREEN_HEIGHT - TET_PADDING * 2) // tetris playing field height
|
||||
#define BLOCK_WIDTH (TET_WIDTH / COLUMNS) // width of a block
|
||||
#define BLOCK_HEIGHT (TET_HEIGHT / ROWS) // height of a block
|
||||
|
||||
typedef struct {
|
||||
SDL_Window* window;
|
||||
|
||||
Reference in New Issue
Block a user