Skip to content

Commit

Permalink
Rolled back to classic C nsnake
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Dantas committed Aug 19, 2013
1 parent 7a0cac8 commit 0f56c11
Show file tree
Hide file tree
Showing 59 changed files with 2,274 additions and 4,677 deletions.
7 changes: 6 additions & 1 deletion ChangeLog
@@ -1,4 +1,9 @@
14-05-2013 V1.7
08-08-2013 V1.7
* Abandoned development - nsnake is now deprecated in favor of
"nsnake++", the new master branch on git. The old version will still be
kept on the "nsnake-classic" branch.

05-14-2013 V1.7

* Changed: High-score file stays on the user's home directory.
* Added: vim-like control keys (hjkl).
Expand Down
22 changes: 4 additions & 18 deletions Doxyfile
@@ -1,4 +1,4 @@
# Doxyfile 1.8.4
# Doxyfile 1.8.2

#---------------------------------------------------------------------------
# Project related configuration options
Expand Down Expand Up @@ -44,6 +44,7 @@ SUBGROUPING = YES
INLINE_GROUPED_CLASSES = NO
INLINE_SIMPLE_STRUCTS = NO
TYPEDEF_HIDES_STRUCT = YES
SYMBOL_CACHE_SIZE = 0
LOOKUP_CACHE_SIZE = 0
#---------------------------------------------------------------------------
# Build related configuration options
Expand Down Expand Up @@ -99,8 +100,8 @@ WARN_LOGFILE =
INPUT = ./src/ \
./doc/doxygen_mainpage.h
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.cpp \
*.hpp
FILE_PATTERNS = *.c \
*.h
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
Expand All @@ -114,7 +115,6 @@ INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
FILTER_SOURCE_PATTERNS =
USE_MDFILE_AS_MAINPAGE =
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
Expand Down Expand Up @@ -179,17 +179,10 @@ EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
USE_MATHJAX = NO
MATHJAX_FORMAT = HTML-CSS
MATHJAX_RELPATH = http://www.mathjax.org/mathjax
MATHJAX_EXTENSIONS =
MATHJAX_CODEFILE =
SEARCHENGINE = YES
SERVER_BASED_SEARCH = NO
EXTERNAL_SEARCH = NO
SEARCHENGINE_URL =
SEARCHDATA_FILE = searchdata.xml
EXTERNAL_SEARCH_ID =
EXTRA_SEARCH_MAPPINGS =
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
Expand All @@ -202,7 +195,6 @@ PAPER_TYPE = a4
EXTRA_PACKAGES =
LATEX_HEADER =
LATEX_FOOTER =
LATEX_EXTRA_FILES =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
Expand Down Expand Up @@ -234,11 +226,6 @@ XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options related to the DOCBOOK output
#---------------------------------------------------------------------------
GENERATE_DOCBOOK = NO
DOCBOOK_OUTPUT = docbook
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
Expand Down Expand Up @@ -268,7 +255,6 @@ TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
Expand Down
211 changes: 129 additions & 82 deletions Makefile
@@ -1,105 +1,151 @@
# nsnake Makefile
# (2013) Alexandre Dantas (kure) <eu@alexdantas.net>

SHELL = /bin/bash
DATE = $(shell date "+%B%Y")

PACKAGE = nsnake
VERSION = 2.0
EXE = nsnake

CXXFLAGS = -Wall -Wextra -g
LDFLAGS = -lncurses
INCLUDE =

LIBS_CXXFILES = $(shell find src/lib -maxdepth 1 -type f -name '*.cpp')

DEFINES = -DVERSION=\""$(VERSION)"\" \
-DPACKAGE=\""$(PACKAGE)"\" \
-DDATE=\""$(DATE)"\"

###################################################################
########## Do NOT edit this
CXX = g++

# All C++ file sources of the projects
CXXFILES = $(shell find src -maxdepth 1 -type f -name '*.cpp')
CXXOBJECTS = $(CXXFILES:.cpp=.o)

SOURCES = $(CXXFILES)
OBJECTS = $(CXXOBJECTS)

LIBS_CXXOBJECTS = $(LIBS_CXXFILES:.cpp=.o)

LIBS_SOURCES = $(LIBS_CXXFILES)
LIBS_OBJECTS = $(LIBS_CXXOBJECTS)
# nSnake Makefile (2011-2012) Alexandre Dantas (kure) <alex.dantas92@gmail.com>
#
# Environment variables:
# V Print all commands as they are called.
# To turn on for the current make, add 'V=1' on the
# commandline.
# To turn on permanently, uncomment the line specified below
# PREFIX Installs the package on a custom directory (overwrites root)
# For example 'PREFIX=~/' would install the program to
# ~/bin/nsnake.
# SCORE_PATH Path to the highscore file. Defaults to /var/games
# DESTDIR Installs the package on a custom sysroot (other than /)
# CFLAGS Changes the C flags used on compilation
# LDFLAGS Specify additional linker flags
# CDEBUG If you wish to build on debug mode, add 'CDEBUG=-g'
#
# Makefile Targets:
# all Compiles the package
# run Compiles and runs the program
# install Installs the package
# clean Removes the binary and the resulting object files
# uninstall Uninstalls the package
# dist Creates the source code 'tarball' for distribution
# doc Generates the documentation with doxygen
# docclean Removes the documentation

# Uncomment line below to tun on verbose mode permanently
#V = 1;

SHELL = /bin/sh

# General Info
PACKAGE = nsnake
VERSION = 1.7
DATE = `date '+%b%Y'`

# Local source code information
LBIN = bin
LOBJ = obj
LDOC = doc
LSRC = src
LFILES = BUGS ChangeLog COPYING Doxyfile INSTALL Makefile README TODO

# Install
PREFIX ?= /usr/local

EXEC_PREFIX = $(PREFIX)
DATAROOTDIR = $(PREFIX)/share
MANROOT = $(DATAROOTDIR)/man

BINDIR = $(EXEC_PREFIX)/games
MANDIR = $(MANROOT)/man6
MANNUMBER = 6

# Package score file name
SCORE_FILE = high-scores.bin

# Compiling information
CC ?= gcc
EXE = nsnake
CDEBUG =
CFLAGS += $(CDEBUG) -Wall -Wextra -O2
LIBS = -lncurses
INCLUDESDIR =
LIBSDIR =
OBJ = $(LOBJ)/fruit.o \
$(LOBJ)/main.o \
$(LOBJ)/player.o \
$(LOBJ)/nsnake.o \
$(LOBJ)/engine.o \
$(LOBJ)/hscores.o \
$(LOBJ)/arguments.o
MANFILE = $(PACKAGE).$(MANNUMBER)
MANPAGE = $(LDOC)/man/$(MANFILE)

DEFINES = -DVERSION=\""$(VERSION)"\" \
-DDATE=\""$(DATE)"\" \
-DSCORE_FILE=\""$(SCORE_FILE)"\"

# Distribution tarball
TARNAME = $(PACKAGE)
DISTDIR = $(TARNAME)-$(VERSION)

# Verbose mode check

ifdef V
MUTE =
VTAG = -v
else
MUTE = @
endif
###################################################################

# Don't try to understand this

# BUILD is initially undefined
ifndef BUILD
# Make targets
all: dirs $(EXE)
# Build successful!

# max equals 256 x's
sixteen := x x x x x x x x x x x x x x x x
MAX := $(foreach x,$(sixteen),$(sixteen))
install: all
# Installing...
$(MUTE)install -d --mode=755 $(DESTDIR)$(BINDIR)
$(MUTE)install -g games -m 2755 $(LBIN)/$(EXE) $(DESTDIR)$(BINDIR)
$(MUTE)install -d $(DESTDIR)$(MANDIR)
$(MUTE)install $(MANPAGE) $(DESTDIR)$(MANDIR)
@echo
# $(PACKAGE) successfuly installed!

# T estimates how many targets we are building by replacing BUILD with
# a special string
T := $(shell $(MAKE) -nrRf $(firstword $(MAKEFILE_LIST)) $(MAKECMDGOALS) \
BUILD="COUNTTHIS" | grep -c "COUNTTHIS")
uninstall:
# Uninstalling...
$(MUTE)rm -f $(DESTDIR)$(BINDIR)/$(EXE)

# N is the number of pending targets in base 1, well in fact, base x
# :-)
N := $(wordlist 1,$T,$(MAX))
purge: uninstall
# Purging configuration files...
$(MUTE)rm -f $(DESTDIR)$(MANDIR)/$(MANFILE)

# auto-decrementing counter that returns the number of pending targets
# in base 10
counter = $(words $N)$(eval N := $(wordlist 2,$(words $N),$N))
$(EXE): $(OBJ)
# Linking...
$(MUTE)$(CC) $(LDFLAGS) $(OBJ) -o $(LBIN)/$(EXE) $(LIBSDIR) $(LIBS)

# BUILD is now defined to show the progress, this also avoids
# redefining T in loop
BUILD = @echo $(counter) of $(T)
endif
###################################################################
$(LOBJ)/%.o: $(LSRC)/%.c
# Compiling $<...
$(MUTE)$(CC) $(CFLAGS) $< -c -o $@ $(DEFINES) $(INCLUDESDIR)

all: dirs $(EXE)
# Build successful!
dist: clean $(DISTDIR).tar.gz

$(EXE): $(OBJECTS) $(LIBS_OBJECTS)
# Linking...
$(MUTE)$(CXX) $(OBJECTS) $(LIBS_OBJECTS) -o $(EXE) $(LDFLAGS)
$(DISTDIR).tar.gz: $(DISTDIR)
# Creating distribution tarball...
$(MUTE)tar czf $(DISTDIR).tar.gz $(DISTDIR)
$(MUTE)rm -rf $(DISTDIR)

src/%.o: src/%.cpp
# Compiling $<...
$(MUTE)$(CXX) $(CXXFLAGS) $(INCLUDE) $< -c -o $@
$(BUILD)
$(DISTDIR):
$(MUTE)mkdir -p $(DISTDIR)/$(LSRC) $(DISTDIR)/$(LDOC)
$(MUTE)mkdir -p $(DISTDIR)/$(LBIN) $(DISTDIR)/$(LOBJ)
-$(MUTE)cp $(LFILES) -t $(DISTDIR)
-$(MUTE)cp -r $(LSRC)/* $(DISTDIR)/$(LSRC)
-$(MUTE)cp -r $(LBIN)/* $(DISTDIR)/$(LBIN)
-$(MUTE)cp -r $(LDOC)/* $(DISTDIR)/$(LDOC)

src/%.o: src/%.c
# Compiling $<...
$(MUTE)$(CC) $(CFLAGS) $(INCLUDE) $< -c -o $@
# Phony targets
dirs:
-mkdir -p $(LOBJ) $(LBIN)

run: all
$(MUTE)./$(EXE)
# Running...
$(MUTE)./$(LBIN)/$(EXE)

clean:
# Cleaning...
-$(MUTE)rm -f $(EXE) $(OBJECTS)

libclean: clean
# Cleaning libs...
-$(MUTE)rm -f $(LIBS_OBJECTS)

# Assure directories exist
dirs:
$(MUTE)mkdir -p src/lib
# Cleaning files...
$(MUTE)rm $(VTAG) -f $(LOBJ)/*.o
$(MUTE)rm $(VTAG) -f $(LBIN)/*

doc:
# Generating documentation...
Expand All @@ -109,5 +155,6 @@ docclean:
# Removing documentation...
-$(MUTE)rm $(VTAG) -rf $(LDOC)/html

.PHONY: clean doc docclean
.PHONY: clean doc docclean uninstall

#------------------------------------------------------------------------------
24 changes: 15 additions & 9 deletions README
@@ -1,16 +1,21 @@
nsnake README
=============

nsnake is the classic snake game playable on the console.
It has two modes (with or without borders) and 9 speed levels.
Uses the nCurses C library for text-like interface.
Has text-like interface, using the nCurses C library.

This is the README for nsnake (also known as "nsnake classic").
It was entirely coded in C, with a simple and documented source
code, to serve as a reference to beginning game programmers.

This is the README for nsnake (also known as "nsnake++").
It is a complete rewrite of nsnake in C++.
The source code is highly documented and clean, although it's
architecture is not that simple.
The development for this version is halted.
I've only kept it for historical reasons.

For the classic nsnake in C, check out the "nsnake-classic"
branch on git. The source is way simpler and easy to build upon.
I recommend you to check the new version of nsnake
(also known as "nsnake++"), that was entirely rewritten in C++
with new game mechanics and features.
That's where I'm more focused on.

README Index
------------
Expand Down Expand Up @@ -107,7 +112,7 @@ this project.
You can send me comments, bugs, ideas or anything else by email.
And if you have time, please visit my blog!

My email: alex.dantas92@gmail.com
My email: eu@alexdantas.net
My homepage: http://www.alexdantas.net/
nsnake main page: http://www.alexdantas.net/projects/nsnake/

Expand Down Expand Up @@ -178,4 +183,5 @@ Special thanks to:
along with this program. If not, see <http://www.gnu.org/licenses/>.

homepage: http://www.alexdantas.net/projects/nsnake/
mailto: alex.dantas92@gmail.com
mailto: eu@alexdantas.net

0 comments on commit 0f56c11

Please sign in to comment.