TiTRIS

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

commit 5a95755e68c1b74cf7d50afe2fdd323431ffdc84
Author: joshiemoore <jxm5210@g.rit.edu>
Date:   Thu, 27 Sep 2018 20:34:21 -0400

Initial commit, basic setup

Diffstat:
A.gitignore | 3+++
AGAME_CONSTANTS.h | 24++++++++++++++++++++++++
AMakefile | 48++++++++++++++++++++++++++++++++++++++++++++++++
Atitris.c | 34++++++++++++++++++++++++++++++++++
4 files changed, 109 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,3 @@ +*.elf +*.o +*.tns diff --git a/GAME_CONSTANTS.h b/GAME_CONSTANTS.h @@ -0,0 +1,24 @@ +/* + * GAME_CONSTANTS.h + * Joshua Moore, 2018 + * + * Define game constants such as board size, colors, piece shapes, etc. + * + */ + +// board dimensions +const int BOARD_WIDTH = 10; +const int BOARD_HEIGHT = 20; + +// PIECE IDs +enum PIECE { + PIECE_I, + PIECE_J, + PIECE_L, + PIECE_O, + PIECE_S, + PIECE_T, + PIECE_Z +}; + +// piece colors diff --git a/Makefile b/Makefile @@ -0,0 +1,48 @@ +DEBUG = FALSE + +GCC = nspire-gcc +AS = nspire-as +GXX = nspire-g++ +LD = nspire-ld +GENZEHN = genzehn + +GCCFLAGS = -Wall -W -marm +LDFLAGS = +ZEHNFLAGS = --name "TiTRIS" + +ifeq ($(DEBUG),FALSE) + GCCFLAGS += -Os +else + GCCFLAGS += -O0 -g +endif + +OBJS = $(patsubst %.c, %.o, $(shell find . -name \*.c)) +OBJS += $(patsubst %.cpp, %.o, $(shell find . -name \*.cpp)) +OBJS += $(patsubst %.S, %.o, $(shell find . -name \*.S)) +EXE = TiTRIS +DISTDIR = . +vpath %.tns $(DISTDIR) +vpath %.elf $(DISTDIR) + +all: $(EXE).tns + +%.o: %.c + $(GCC) $(GCCFLAGS) -c $< -o $@ + +%.o: %.cpp + $(GXX) $(GCCFLAGS) -c $< -o $@ + +%.o: %.S + $(AS) -c $< -o $@ + +$(EXE).elf: $(OBJS) + mkdir -p $(DISTDIR) + $(LD) $^ -o $@ $(LDFLAGS) + +$(EXE).tns: $(EXE).elf + $(GENZEHN) --input $^ --output $@.zehn $(ZEHNFLAGS) + make-prg $@.zehn $@ + rm $@.zehn + +clean: + rm -f $(OBJS) $(DISTDIR)/$(EXE).tns $(DISTDIR)/$(EXE).elf $(DISTDIR)/$(EXE).zehn diff --git a/titris.c b/titris.c @@ -0,0 +1,33 @@ +/* + * titris.c + * Joshua Moore, 2018 + * + */ + +// library includes +#include <os.h> +#include <SDL/SDL_config.h> +#include <SDL/SDL.h> +#include <SDL/SDL_gfxPrimitives.h> + +// TiTRIS includes +#include "GAME_CONSTANTS.h" + +int main(void) { + // init screen + SDL_Surface* screen; + SDL_Init(SDL_INIT_VIDEO); + + screen = SDL_SetVideoMode(320, 240, has_colors ? 16 : 8, + SDL_SWSURFACE); + + // draw initial blank screen + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + + + SDL_Flip(screen); + wait_key_pressed(); + + return 0; + +}+ \ No newline at end of file