TiTRIS

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

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

Implement drawBoard() function

Diffstat:
MGAME_CONSTANTS.h | 2+-
Mgraphics.c | 21++++++++++++++++++++-
Mgraphics.h | 2++
Mtitris.c | 2+-
4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/GAME_CONSTANTS.h b/GAME_CONSTANTS.h @@ -15,7 +15,7 @@ // BOARD DIMENSIONS #define BOARD_WIDTH 10 -#define BOARD_HEIGHT 20 +#define BOARD_HEIGHT 18 // TILE SIZE (square) #define TILE_SIZE 12 diff --git a/graphics.c b/graphics.c @@ -6,6 +6,25 @@ #include "graphics.h" +const int boardWidthPixels = BOARD_WIDTH * TILE_SIZE + (BOARD_WIDTH); +const int boardHeightPixels = BOARD_HEIGHT * TILE_SIZE + (BOARD_HEIGHT); + +const int boardLeft = SCREEN_WIDTH / 2 - boardWidthPixels / 2; +const int boardRight = SCREEN_WIDTH / 2 + boardWidthPixels / 2; + + void drawBoard(SDL_Surface* screen) { - return; + // draw horizontal lines + for (int y = 0; y <= boardHeightPixels; y += TILE_SIZE + 1) { + hlineRGBA(screen, + boardLeft, boardRight, y, + 255, 255, 255, 255); + } + + // draw vertical lines + for (int x = boardLeft; x <= boardRight; x += TILE_SIZE + 1) { + vlineRGBA(screen, + x, 0, boardHeightPixels, + 255, 255, 255, 255); + } } \ No newline at end of file diff --git a/graphics.h b/graphics.h @@ -9,6 +9,8 @@ #include <SDL/SDL_gfxPrimitives.h> +#include "GAME_CONSTANTS.h" + /** * Draw the game board consisting of a simple grid of white lines. */ diff --git a/titris.c b/titris.c @@ -17,13 +17,13 @@ int main(void) { // init screen SDL_Surface* screen; SDL_Init(SDL_INIT_VIDEO); - screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, has_colors ? 16 : 8, SDL_SWSURFACE); // draw initial blank screen SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + drawBoard(screen); SDL_Flip(screen); wait_key_pressed();