From 1af772beadf5d03822c2cbdf80987e0580813602 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 19 Jun 2009 11:35:01 -0400 Subject: Backed out changeset 9cb52f41967c 'Twas a bad idea --- src/Makefile.am | 3 - src/Makefile.in | 417 ----------------------------------------------------- src/gamestate.cpp | 273 ----------------------------------- src/gamestate.h | 59 -------- src/includes.h | 7 - src/mazeoflife.cpp | 90 ------------ src/mazeoflife.h | 10 -- src/state.h | 12 -- 8 files changed, 871 deletions(-) delete mode 100644 src/Makefile.am delete mode 100644 src/Makefile.in delete mode 100644 src/gamestate.cpp delete mode 100644 src/gamestate.h delete mode 100644 src/includes.h delete mode 100644 src/mazeoflife.cpp delete mode 100644 src/mazeoflife.h delete mode 100644 src/state.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 4533bc4..0000000 --- a/src/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -gamesdir = /usr/games -games_PROGRAMS = mazeoflife -mazeoflife_SOURCES = mazeoflife.cpp gamestate.cpp diff --git a/src/Makefile.in b/src/Makefile.in deleted file mode 100644 index 6460691..0000000 --- a/src/Makefile.in +++ /dev/null @@ -1,417 +0,0 @@ -# Makefile.in generated by automake 1.10.2 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -games_PROGRAMS = mazeoflife$(EXEEXT) -subdir = src -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -am__installdirs = "$(DESTDIR)$(gamesdir)" -gamesPROGRAMS_INSTALL = $(INSTALL_PROGRAM) -PROGRAMS = $(games_PROGRAMS) -am_mazeoflife_OBJECTS = mazeoflife.$(OBJEXT) gamestate.$(OBJEXT) -mazeoflife_OBJECTS = $(am_mazeoflife_OBJECTS) -mazeoflife_LDADD = $(LDADD) -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLD = $(CXX) -CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ -SOURCES = $(mazeoflife_SOURCES) -DIST_SOURCES = $(mazeoflife_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -SDL_CFLAGS = @SDL_CFLAGS@ -SDL_LIBS = @SDL_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -gamesdir = /usr/games -mazeoflife_SOURCES = mazeoflife.cpp gamestate.cpp -all: all-am - -.SUFFIXES: -.SUFFIXES: .cpp .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -install-gamesPROGRAMS: $(games_PROGRAMS) - @$(NORMAL_INSTALL) - test -z "$(gamesdir)" || $(MKDIR_P) "$(DESTDIR)$(gamesdir)" - @list='$(games_PROGRAMS)'; for p in $$list; do \ - p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - if test -f $$p \ - ; then \ - f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(gamesPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(gamesdir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(gamesPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(gamesdir)/$$f" || exit 1; \ - else :; fi; \ - done - -uninstall-gamesPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(games_PROGRAMS)'; for p in $$list; do \ - f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f '$(DESTDIR)$(gamesdir)/$$f'"; \ - rm -f "$(DESTDIR)$(gamesdir)/$$f"; \ - done - -clean-gamesPROGRAMS: - -test -z "$(games_PROGRAMS)" || rm -f $(games_PROGRAMS) -mazeoflife$(EXEEXT): $(mazeoflife_OBJECTS) $(mazeoflife_DEPENDENCIES) - @rm -f mazeoflife$(EXEEXT) - $(CXXLINK) $(mazeoflife_OBJECTS) $(mazeoflife_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gamestate.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mazeoflife.Po@am__quote@ - -.cpp.o: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: - for dir in "$(DESTDIR)$(gamesdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-gamesPROGRAMS clean-generic mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: install-gamesPROGRAMS - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-gamesPROGRAMS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean \ - clean-gamesPROGRAMS clean-generic ctags distclean \ - distclean-compile distclean-generic distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-gamesPROGRAMS \ - install-html install-html-am install-info install-info-am \ - install-man install-pdf install-pdf-am install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ - ps ps-am tags uninstall uninstall-am uninstall-gamesPROGRAMS - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/gamestate.cpp b/src/gamestate.cpp deleted file mode 100644 index 39d589d..0000000 --- a/src/gamestate.cpp +++ /dev/null @@ -1,273 +0,0 @@ -#include "includes.h" - -GameState::GameState() -{ - player_color = getColor(255, 255, 0); - event_color = getColor(0, 0, 255); - - newGame = false; - - info.playerx = 1; - info.playery = 1; - info.level = Level(); - info.doneMaking = false; - board = Board(&info); - - SDL_WM_SetCaption("Maze Of Life - Level 1", NULL); -} - -void GameState::input(SDLKey key) -{ - if (info.doneMaking) - { - switch (key) - { - case SDLK_LEFT: - move(info.playerx-1, info.playery); - - break; - case SDLK_RIGHT: - move(info.playerx+1, info.playery); - - break; - case SDLK_UP: - move(info.playerx, info.playery-1); - - break; - case SDLK_DOWN: - move(info.playerx, info.playery+1); - - break; - case SDLK_ESCAPE: - newGame = false; - - info.playerx = 1; - info.playery = 1; - info.level = Level(); - info.doneMaking = false; - board = Board(&info); - - SDL_WM_SetCaption("Maze Of Life - Level 1", NULL); - - break; - } - } -} - -void GameState::tick() -{ - if (newGame) - { - switch (rand()%4) - { - case 0: info.playerx = 1; info.playery = 1; break; - case 1: info.playerx = 1; info.playery = HEIGHT-2; break; - case 2: info.playerx = WIDTH-2; info.playery = HEIGHT-2; break; - case 3: info.playerx = WIDTH-2; info.playery = 1; break; - } - - info.level.incrementLevel(); - info.doneMaking = false; - board = Board(&info); - newGame = false; - - char title[32]; - sprintf(title, "Maze Of Life - Level %d", info.level.getLevel()); - SDL_WM_SetCaption(title, NULL); - } - - board.tick(); -} - -void GameState::move(int x, int y) -{ - wrap(&x, &y); - - if (board.isObstructed(x,y)) return; - if ((x==15)&&(y==15)) newGame = true; - - info.playerx = x; - info.playery = y; -} - -void GameState::render(SDL_Surface* screen) -{ - // Paint maze - board.render(screen); - - // Paint player - SDL_Rect block; - block.x = info.playerx*16; - block.y = info.playery*16; - block.w = 16; - block.h = 16; - - SDL_FillRect(screen, &block, player_color); - - // Paint event - block.x = 15*16; - block.y = 15*16; - - SDL_FillRect(screen, &block, event_color); -} - -GameState::Level::Level() -{ - level = 1; - - alive[0] = getColor(0, 0, 0); // Black - alive[1] = getColor(255, 0, 0); // Red - alive[2] = getColor(0, 255, 0); // Green - alive[3] = getColor(85, 85, 85); // Dark Gray - alive[4] = getColor(255, 0, 255); // Magenta - - dead[0] = getColor(255, 255, 255); // White - dead[1] = getColor(255, 192, 203); // Pink - dead[2] = getColor(0, 255, 255); // Cyan - dead[3] = getColor(170, 170, 170); // Light Gray - dead[4] = getColor(255, 128, 0); // Orange -} - -int GameState::Level::getLevel() -{ - return level; -} - -bool GameState::Level::checkSquare(int x, int y) -{ - switch (level/10+1) - { - case 1: - return ((x>13)&&(x<16)&&(y>13)&&(y<16)); - case 2: - return ((x>13)&&(x<17)&&(y>13)&&(y<17)); - case 3: - case 4: - return ((x>12)&&(x<18)&&(y>12)&&(y<18)); - case 5: - case 6: - return ((x>11)&&(x<19)&&(y>11)&&(y<19)); - default: - return true; - } -} - -Uint32 GameState::Level::getAliveColor() -{ - return alive[(level/10)%5]; -} - -Uint32 GameState::Level::getDeadColor() -{ - return dead[(level/10)%5]; -} - -void GameState::Level::incrementLevel() -{ - level++; -} - -GameState::Board::Board() -{ - GameState::Board::Board(new GameState::Info()); -} - -GameState::Board::Board(GameState::Info* info) -{ - this->info = info; - - int x,y; - for (y=0;ylevel.checkSquare(x, y)) - { - blocks[x][y] = rand() % 2; - } else { - blocks[x][y] = false; - } - } - } - - blocks[15][15] = false; -} - -bool GameState::Board::isObstructed(int x, int y) -{ - return blocks[x][y]; -} - -void GameState::Board::render(SDL_Surface* screen) -{ - SDL_Rect block; - block.w = 16; - block.h = 16; - - int x,y; - - for (y=0;ylevel.getAliveColor() : info->level.getDeadColor())); - } - } -} - -void GameState::Board::tick() -{ - bool temp[WIDTH][HEIGHT]; - int x,y; - for (x=0;x0)&&(y>0)) incrementIfNeighbor(x-1,y-1,temp,&neighbors); - if ((x>0)) incrementIfNeighbor(x-1,y,temp,&neighbors); - if ((x>0)&&(y0)) incrementIfNeighbor(x,y-1,temp,&neighbors); - if ((y0)) incrementIfNeighbor(x+1,y-1,temp,&neighbors); - if ((x= 1) && (neighbors <= 4)); - } else { - blocks[x][y] = (neighbors == 3); - } - } - } - - if (!info->doneMaking && ++gens > 100) info->doneMaking = true; -} - -void GameState::Board::incrementIfNeighbor(int x, int y, bool temp[WIDTH][HEIGHT], int* tick) -{ - wrap(&x, &y); - - if ((temp[x][y])||((info->playerx==x)&&(info->playery==y))||((x==15)&&(y==15))) - { - ++*tick; - } -} diff --git a/src/gamestate.h b/src/gamestate.h deleted file mode 100644 index 7d9d798..0000000 --- a/src/gamestate.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef GAMESTATE_H -#define GAMESTATE_H - -class GameState : public State { - public: - GameState(); - void input(SDLKey key); - void tick(); - void render(SDL_Surface* screen); - - class Level - { - private: - int level; - Uint32 alive[5]; - Uint32 dead[5]; - - public: - Level(); - int getLevel(); - int getLevelGroup(); - bool checkSquare(int x, int y); - Uint32 getAliveColor(); - Uint32 getDeadColor(); - void incrementLevel(); - }; - - struct Info { - int playerx, playery; - Level level; - bool doneMaking; - }; - - class Board - { - private: - bool blocks[WIDTH][HEIGHT]; - void incrementIfNeighbor(int x, int y, bool temp[WIDTH][HEIGHT], int* tick); - GameState::Info* info; - int gens; - - public: - Board(); - Board(GameState::Info* info); - bool isObstructed(int x, int y); - void render(SDL_Surface* screen); - void tick(); - }; - - private: - Uint32 player_color; - Uint32 event_color; - bool newGame; - Info info; - Board board; - void move(int x, int y); -}; - -#endif diff --git a/src/includes.h b/src/includes.h deleted file mode 100644 index a47a307..0000000 --- a/src/includes.h +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include -#include -#include -#include "mazeoflife.h" -#include "state.h" -#include "gamestate.h" diff --git a/src/mazeoflife.cpp b/src/mazeoflife.cpp deleted file mode 100644 index 7819ffd..0000000 --- a/src/mazeoflife.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "includes.h" - -SDL_Surface *screen; -bool gameSleep = false; - -int main(int argc, char *argv[]) -{ - srand(time(NULL)); - - /* Initialize defaults, Video and Audio */ - if((SDL_Init(SDL_INIT_VIDEO)==-1)) { - printf("Could not initialize SDL: %s.\n", SDL_GetError()); - exit(-1); - } - - /* Clean up on exit */ - atexit(SDL_Quit); - - SDL_WM_SetCaption("Maze Of Life", NULL); - - /* - * Initialize the display in a 640x480 8-bit palettized mode, - * requesting a software surface - */ - screen = SDL_SetVideoMode(WIDTH*16, HEIGHT*16, 8, SDL_DOUBLEBUF); - if ( screen == NULL ) { - fprintf(stderr, "Couldn't set %dx%dx8 video mode: %s\n", WIDTH*16, WIDTH*16, SDL_GetError()); - exit(1); - } - - SDL_EnableKeyRepeat(100, 50); - - State* state = new GameState(); - - SDL_Event anEvent; - for (;;) - { - state->tick(); - - while (SDL_PollEvent(&anEvent)) - { - switch (anEvent.type) - { - case SDL_ACTIVEEVENT: - if (anEvent.active.state == SDL_APPINPUTFOCUS) - { - gameSleep = !anEvent.active.gain; - } - - break; - case SDL_QUIT: - exit(0); - - break; - case SDL_KEYDOWN: - state->input(anEvent.key.keysym.sym); - - break; - } - } - - state->render(screen); - - SDL_Flip(screen); - } - - exit(0); -} - -void wrap(int* x, int* y) -{ - if (*x < 0) - { - *x = WIDTH-(0-*x); - } else if (*y < 0) - { - *y = HEIGHT-(0-*y); - } else if (*x >= WIDTH) - { - *x = *x-WIDTH; - } else if (*y >= HEIGHT) - { - *y = *y-HEIGHT; - } -} - -Uint32 getColor(int r, int g, int b) -{ - return SDL_MapRGB(screen->format, r, g, b); -} diff --git a/src/mazeoflife.h b/src/mazeoflife.h deleted file mode 100644 index 6af0cf4..0000000 --- a/src/mazeoflife.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef MAZEOFLIFE_H -#define MAZEOFLIFE_H - -const int WIDTH = 30; -const int HEIGHT = 30; - -void wrap(int* x, int* y); -Uint32 getColor(int r, int g, int b); - -#endif diff --git a/src/state.h b/src/state.h deleted file mode 100644 index 1a97a1b..0000000 --- a/src/state.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef STATE_H -#define STATE_H - -class State -{ - public: - virtual void input(SDLKey key) = 0; - virtual void tick() = 0; - virtual void render(SDL_Surface* screen) = 0; -}; - -#endif -- cgit 1.4.1