fixed issue with a and u commands
This commit is contained in:
66
Makefile
66
Makefile
@ -1,33 +1,33 @@
|
||||
# Universal makefile for single C++ program
|
||||
#
|
||||
# Use gcc flag -MMD (user) or -MD (user/system) to generate dependencies among source files.
|
||||
# Use make default rules for commonly used file-name suffixes and make variables names.
|
||||
#
|
||||
# % make [ a.out ]
|
||||
|
||||
########## Variables ##########
|
||||
|
||||
CXX = g++ # compiler
|
||||
CXXFLAGS = -std=c++20 -g -Wall -MMD -lncurses -O0 # compiler flags
|
||||
MAKEFILE_NAME = ${firstword ${MAKEFILE_LIST}} # makefile name
|
||||
|
||||
SOURCES = $(wildcard src/*.cc) # source files (*.cc)
|
||||
OBJECTS = ${SOURCES:.cc=.o} # object files forming executable
|
||||
DEPENDS = ${OBJECTS:.o=.d} # substitute ".o" with ".d"
|
||||
EXEC = bin/cc3k # executable name
|
||||
|
||||
########## Targets ##########
|
||||
|
||||
.PHONY : clean # not file names
|
||||
|
||||
${EXEC} : ${OBJECTS} # link step
|
||||
${CXX} ${CXXFLAGS} $^ -o $@ # additional object files before $^
|
||||
|
||||
${OBJECTS} : ${MAKEFILE_NAME} # OPTIONAL : changes to this file => recompile
|
||||
|
||||
# make implicitly generates rules to compile C++ files that generate .o files
|
||||
|
||||
-include ${DEPENDS} # include *.d files containing program dependences
|
||||
|
||||
clean : # remove files that can be regenerated
|
||||
rm -f ${DEPENDS} ${OBJECTS} ${EXEC}
|
||||
# Universal makefile for single C++ program
|
||||
#
|
||||
# Use gcc flag -MMD (user) or -MD (user/system) to generate dependencies among source files.
|
||||
# Use make default rules for commonly used file-name suffixes and make variables names.
|
||||
#
|
||||
# % make [ a.out ]
|
||||
|
||||
########## Variables ##########
|
||||
|
||||
CXX = g++ # compiler
|
||||
CXXFLAGS = -std=c++20 -g -Wall -MMD -lncurses -O0 # compiler flags
|
||||
MAKEFILE_NAME = ${firstword ${MAKEFILE_LIST}} # makefile name
|
||||
|
||||
SOURCES = $(wildcard src/*.cc) # source files (*.cc)
|
||||
OBJECTS = ${SOURCES:.cc=.o} # object files forming executable
|
||||
DEPENDS = ${OBJECTS:.o=.d} # substitute ".o" with ".d"
|
||||
EXEC = bin/cc3k # executable name
|
||||
|
||||
########## Targets ##########
|
||||
|
||||
.PHONY : clean # not file names
|
||||
|
||||
${EXEC} : ${OBJECTS} # link step
|
||||
${CXX} ${CXXFLAGS} $^ -o $@ # additional object files before $^
|
||||
|
||||
${OBJECTS} : ${MAKEFILE_NAME} # OPTIONAL : changes to this file => recompile
|
||||
|
||||
# make implicitly generates rules to compile C++ files that generate .o files
|
||||
|
||||
-include ${DEPENDS} # include *.d files containing program dependences
|
||||
|
||||
clean : # remove files that can be regenerated
|
||||
rm -f ${DEPENDS} ${OBJECTS} ${EXEC}
|
||||
|
@ -10,21 +10,26 @@ game_command console_input::get_command() {
|
||||
in >> cmd;
|
||||
game_command tmp;
|
||||
|
||||
if (in.eof())
|
||||
return game_command_terminate;
|
||||
|
||||
if (cmd == "q")
|
||||
return game_command_terminate;
|
||||
else if (cmd == "f")
|
||||
return the_world;
|
||||
else if (cmd == "r")
|
||||
return game_restart;
|
||||
else if (cmd == "u")
|
||||
else if (cmd == "u" || cmd == "a") {
|
||||
in >> cmd;
|
||||
|
||||
if (in.eof())
|
||||
return game_command_panic;
|
||||
|
||||
return (game_command)((tmp = get_direction(cmd)) ==
|
||||
game_command_panic
|
||||
? tmp : tmp - move_north + apply_north);
|
||||
else if (cmd == "a")
|
||||
return (game_command)((tmp = get_direction(cmd)) ==
|
||||
game_command_panic
|
||||
? tmp : tmp - move_north + attack_north);
|
||||
else // is just moving
|
||||
? tmp : tmp - move_north +
|
||||
(cmd == "u" ? apply_north : attack_north));
|
||||
} else // is just moving
|
||||
return get_direction(cmd);
|
||||
|
||||
return game_command_pass;
|
||||
|
@ -10,21 +10,26 @@ game_command file_input::get_command() {
|
||||
in >> cmd;
|
||||
game_command tmp;
|
||||
|
||||
if (in.eof())
|
||||
return game_command_terminate;
|
||||
|
||||
if (cmd == "q")
|
||||
return game_command_terminate;
|
||||
else if (cmd == "f")
|
||||
return the_world;
|
||||
else if (cmd == "r")
|
||||
return game_restart;
|
||||
else if (cmd == "u")
|
||||
else if (cmd == "u" || cmd == "a") {
|
||||
in >> cmd;
|
||||
|
||||
if (in.eof())
|
||||
return game_command_panic;
|
||||
|
||||
return (game_command)((tmp = get_direction(cmd)) ==
|
||||
game_command_panic
|
||||
? tmp : tmp - move_north + apply_north);
|
||||
else if (cmd == "a")
|
||||
return (game_command)((tmp = get_direction(cmd)) ==
|
||||
game_command_panic
|
||||
? tmp : tmp - move_north + attack_north);
|
||||
else // is just moving
|
||||
? tmp : tmp - move_north +
|
||||
(cmd == "u" ? apply_north : attack_north));
|
||||
} else // is just moving
|
||||
return get_direction(cmd);
|
||||
|
||||
return game_command_pass;
|
||||
|
50
tools/compile
Executable file → Normal file
50
tools/compile
Executable file → Normal file
@ -1,25 +1,25 @@
|
||||
#!/bin/bash
|
||||
# Use this script to compile your .cc files in dependency order
|
||||
|
||||
# Arguments:
|
||||
# $1 = name of file containing list of .cc files
|
||||
# $2 = name of the output file
|
||||
|
||||
cxx="g++-11"
|
||||
cxxflags="-std=c++20 -fmodules-ts -Wall -g"
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 list-filename [output-name]" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -eq 2 ]; then
|
||||
name="-o $2"
|
||||
fi
|
||||
|
||||
for x in $(cat $1); do
|
||||
$cxx $cxxflags -c $x
|
||||
done
|
||||
|
||||
$cxx *.o $name
|
||||
|
||||
#!/bin/bash
|
||||
# Use this script to compile your .cc files in dependency order
|
||||
|
||||
# Arguments:
|
||||
# $1 = name of file containing list of .cc files
|
||||
# $2 = name of the output file
|
||||
|
||||
cxx="g++-11"
|
||||
cxxflags="-std=c++20 -fmodules-ts -Wall -g"
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 list-filename [output-name]" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -eq 2 ]; then
|
||||
name="-o $2"
|
||||
fi
|
||||
|
||||
for x in $(cat $1); do
|
||||
$cxx $cxxflags -c $x
|
||||
done
|
||||
|
||||
$cxx *.o $name
|
||||
|
||||
|
0
tools/produceOutputs
Executable file → Normal file
0
tools/produceOutputs
Executable file → Normal file
0
tools/runSuite
Executable file → Normal file
0
tools/runSuite
Executable file → Normal file
Reference in New Issue
Block a user