TiTRIS

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

commit 8af9fbe17b3f191644b0155f059fd8df97ef76c8
parent d834be27eb826f89917bcf2a7344b72b914eeca0
Author: joshiemoore <jxm5210@g.rit.edu>
Date:   Thu, 27 Sep 2018 23:02:30 -0400

Define piece shapes

Diffstat:
MGAME_CONSTANTS.h | 16++++++----------
Ashapelayout.txt | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtitris.c | 24++++++++++++++++++++++++
3 files changed, 90 insertions(+), 10 deletions(-)

diff --git a/GAME_CONSTANTS.h b/GAME_CONSTANTS.h @@ -31,15 +31,11 @@ enum PIECE { PIECE_Z }; -// piece colors -enum COLORS { - 0xFF0000FF, // I - RED - 0xFF00FFFF, // J - MAGENTA - 0xFFFF00FF, // L - YELLOW - 0x00FFFFFF, // O - CYAN - 0x0000FFFF, // S - BLUE - 0xC0C0C0FF, // T - SILVER - 0x00FF00FF // Z - GREEN -} +// PIECE COLORS +extern const unsigned int COLORS[]; + +// PIECE SHAPES +// see shapelayout.txt for details +extern const short SHAPES[7][4]; #endif diff --git a/shapelayout.txt b/shapelayout.txt @@ -0,0 +1,59 @@ +Pieces are represented as 2 hex bytes. +Each row of the piece is represented by one nibble. +Rotations are performed by using an array of hex values. + + +I-PIECE [0xF000, 0x6666, 0xF000, 0x6666] + +1111 0100 1111 0100 +0000 0100 0000 0100 +0000 0100 0000 0100 +0000 0100 0000 0100 + + +J-PIECE [0xC200, 0x66A0, 0x8E00, 0xA880] + +1110 0100 1000 1100 +0010 0100 1110 1000 +0000 1100 0000 1000 +0000 0000 0000 0000 + + +L-PIECE [0xC800, 0xA660, 0x2E00, 0x88A0] + +1110 1100 0010 1000 +1000 0100 1110 1000 +0000 0100 0000 1100 +0000 0000 0000 0000 + + +O-PIECE [0xCC00, 0xCC00, 0xCC00, 0xCC00] + +1100 1100 1100 1100 +1100 1100 1100 1100 +0000 1100 0000 0000 +0000 1100 0000 0000 + + +S-PIECE [0x6C00, 0x8C40, 0x6C00, 0x8C40] + +0110 1000 0110 1000 +1100 1100 1100 1100 +0000 0100 0000 0100 +0000 0000 0000 0000 + + +T-PIECE [0xE400, 0x4C40, 0x4E00, 0x8C80] + +1110 0100 0100 1000 +0100 1100 1110 1100 +0000 0100 0000 1000 +0000 0000 0000 0000 + + +Z-PIECE [0xC600, 0x4C80, 0xC600, 0x4C80] + +1100 0100 1100 0100 +0110 1100 0110 1100 +0000 1000 0000 1000 +0000 0000 0000 0000+ \ No newline at end of file diff --git a/titris.c b/titris.c @@ -13,6 +13,30 @@ #include "GAME_CONSTANTS.h" #include "graphics.h" +// PIECE COLORS +const unsigned int COLORS[] = + { + 0xFF0000FF, // I - RED + 0xFF00FFFF, // J - MAGENTA + 0xFFFF00FF, // L - YELLOW + 0x00FFFFFF, // O - CYAN + 0x0000FFFF, // S - BLUE + 0xC0C0C0FF, // T - SILVER + 0x00FF00FF // Z - GREEN + }; + +// PIECE SHAPES +const short SHAPES[7][4] = + { + {0xF000, 0x6666, 0xF000, 0x6666}, + {0xC200, 0x66A0, 0x8E00, 0xA880}, + {0xC800, 0xA660, 0x2E00, 0x88A0}, + {0xCC00, 0xCC00, 0xCC00, 0xCC00}, + {0x6C00, 0x8C40, 0x6C00, 0x8C40}, + {0xE400, 0x4C40, 0x4E00, 0x8C80}, + {0xC600, 0x4C80, 0xC600, 0x4C80} + }; + int main(void) { // init screen SDL_Surface* screen;