TiTRIS

unfinished Tetris clone for TI-nspire CX
git clone git://squid-tech.com/TiTRIS.git
Log | Files | Refs | README

commit a9a1edc6a34c04e80af8a8985b13aea75b5816df
parent 8bf979afc786ef35aa677509586540bf8c202541
Author: joshiemoore <jxm5210@g.rit.edu>
Date:   Thu, 27 Sep 2018 22:16:01 -0400

Implement colorTile() function

Diffstat:
MGAME_CONSTANTS.h | 2+-
Mgraphics.c | 15+++++++++++----
Mgraphics.h | 5+++++
Mtitris.c | 2++
4 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/GAME_CONSTANTS.h b/GAME_CONSTANTS.h @@ -15,7 +15,7 @@ // BOARD DIMENSIONS #define BOARD_WIDTH 10 -#define BOARD_HEIGHT 18 +#define BOARD_HEIGHT 17 // TILE SIZE (square) #define TILE_SIZE 12 diff --git a/graphics.c b/graphics.c @@ -6,8 +6,8 @@ #include "graphics.h" -const int boardWidthPixels = BOARD_WIDTH * TILE_SIZE + (BOARD_WIDTH); -const int boardHeightPixels = BOARD_HEIGHT * TILE_SIZE + (BOARD_HEIGHT); +const int boardWidthPixels = BOARD_WIDTH * TILE_SIZE + (BOARD_WIDTH * 2); +const int boardHeightPixels = BOARD_HEIGHT * TILE_SIZE + (BOARD_HEIGHT * 2); const int boardLeft = SCREEN_WIDTH / 2 - boardWidthPixels / 2; const int boardRight = SCREEN_WIDTH / 2 + boardWidthPixels / 2; @@ -15,16 +15,23 @@ const int boardRight = SCREEN_WIDTH / 2 + boardWidthPixels / 2; void drawBoard(SDL_Surface* screen) { // draw horizontal lines - for (int y = 0; y <= boardHeightPixels; y += TILE_SIZE + 1) { + for (int y = 0; y <= boardHeightPixels; y += TILE_SIZE + 2) { hlineRGBA(screen, boardLeft, boardRight, y, 255, 255, 255, 255); } // draw vertical lines - for (int x = boardLeft; x <= boardRight; x += TILE_SIZE + 1) { + for (int x = boardLeft; x <= boardRight; x += TILE_SIZE + 2) { vlineRGBA(screen, x, 0, boardHeightPixels, 255, 255, 255, 255); } +} + +void colorTile(SDL_Surface* screen, int row, int col, Uint32 color) { + int x = boardLeft + (col * TILE_SIZE) + (col * 2) + 1; + int y = (row * TILE_SIZE) + (row * 2) + 1; + + boxColor(screen, x, y, x + TILE_SIZE, y + TILE_SIZE, color); } \ No newline at end of file diff --git a/graphics.h b/graphics.h @@ -16,4 +16,9 @@ */ void drawBoard(SDL_Surface* screen); +/** + * Color a single tile on the game board. + */ +void colorTile(SDL_Surface* screen, int row, int col, Uint32 color); + #endif \ No newline at end of file diff --git a/titris.c b/titris.c @@ -28,6 +28,8 @@ int main(void) { SDL_Flip(screen); wait_key_pressed(); + SDL_Quit(); + return 0; } \ No newline at end of file