orton_runner/configure

112 lines
3.8 KiB
Bash
Executable File

#! /bin/bash
# output file
file_gcc="gcc.cfg"
declare -A config
config[FILE_DEBUG]=
config[NO_WALL_MOVE]=
config[VALGRIND]=
config[WALL_SPEED]=5
config[CAMERA_SPEED]=32
config[FRAME_RATE]=64
config[PLAYER_JUMP_MAX]=7
config[PLAYER_SPEED]=6
config[CAMERA_SHAKY]=15
config[THROWER_STONE_SLEEP]=35
config[THROWER_BULLET_SLEEP]=100
config[BULLET_SPEED]=32
config[NB_STONE]=64
config[THROWER_DX_SLEEP]=4
function help()
{
echo -e "Configuration script for my_runner."
echo -e "\nOption that will print some debug log:"
echo -e "\t\033[1;32m--file-debug [default: false]\033[0m"
echo -e "\tEnable some indication when map file are loading."
echo -e "\t\033[1;32m--valgrind-debug [default: false]\033[0m"
echo -e "\tAdd some flags for debugging with valgrind."
echo -e "\t\033[1;32m--help | -h\033[0m"
echo -e "\tPrint this text."
echo -e "\nOption that will affect the game:"
echo -e "\t\033[1;32m--wall-speed=<interger> [default: 5]\033[0m"
echo -e "\tAjuste wall speed."
echo -e "\t\033[1;32m--camera-speed=<interger> [default: 32]\033[0m"
echo -e "\tAjuste camera speed."
echo -e "\t\033[1;32m--camera-shaky=<interger> [default: 15]\033[0m"
echo -e "\tAjuste camera when player's dead."
echo -e "\t\033[1;32m--player-jump-time=<interger> [default: 7]\033[0m"
echo -e "\tAjuste player jump time."
echo -e "\t\033[1;32m--frame-rate=<interger> [default: 64]\033[0m"
echo -e "\tAjust frame rate."
echo -e "\t\033[1;32m--stone-dx=<interger> [default: 4]\033[0m"
echo -e "\tAjust X axis of thrower object."
echo -e "\t\033[1;32m--stone-nb=<interger> [default:64]\033[0m"
echo -e "\tAjust number of thrower object."
echo -e "\t\033[1;32m--thrower-stone-sleep=<interger> [default: 35]\033[0m"
echo -e "\tAjust the \"sleep\" of thrower. (stone)"
echo -e "\t\033[1;32m--thrower-bullet-sleep=<interger> [default: 100]\033[0m"
echo -e "\tAjust the \"sleep\" of thrower. (bullet)"
echo -e "\t\033[1;32m--no-wall [default: false]\033[0m"
echo -e "\tDisable moving wall."
exit 0
}
function option_update()
{
if [[ "$1" -gt "0" ]]; then config[$2]=$1
else errror; fi
}
function error()
{
echo -e "\033[1;33merror\033[0m need positive interger value."
exit 1
}
function out_gcc()
{
if [ "${config[VALGRIND]}" != "" ]; then echo "-g3"
else echo "-g0"; fi
[ "${config[FILE_DEBUG]}" != "" ] && echo "-D DEBUG_LOAD_FILE"
[ "${config[NO_WALL_MOVE]}" != "" ] && echo "-D NO_WALL_MOVE"
echo "-D WALL_SPEED=${config[WALL_SPEED]}"
echo "-D CAMERA_SPEED=${config[CAMERA_SPEED]}"
echo "-D FRAME_RATE=${config[FRAME_RATE]}"
echo "-D PLAYER_MAX_JUMP=${config[PLAYER_JUMP_MAX]}"
echo "-D PLAYER_SPEED=${config[PLAYER_SPEED]}"
echo "-D CAMERA_SHAKY=${config[CAMERA_SHAKY]}"
echo "-D THROWER_STONE_SLEEP=${config[THROWER_STONE_SLEEP]}"
echo "-D THROWER_BULLET_SLEEP=${config[THROWER_BULLET_SLEEP]}"
echo "-D THROWER_DX_SLEEP=${config[THROWER_DX_SLEEP]}"
echo "-D NB_OBJECT=${config[NB_STONE]}"
}
for arg; do case "$arg" in
--help | -h) help;;
--file-debug) config[FILE_DEBUG]=true;;
--no-wall) config[NO_WALL_MOVE]=true;;
--valgrind-debug) config[VALGRIND]=true;;
--wall-speed=*) option_update ${arg#*=} WALL_SPEED;;
--camera-speed=*) option_update ${arg#*=} CAMERA_SPEED;;
--camera-shaky=*) option_update ${arg#*=} CAMERA_SHAKY;;
--player-jump-time=*) option_update ${arg#*=} PLAYER_JUMP_MAX;;
--player-speed=*) option_update ${arg#*=} PLAYER_SPEED;;
--frame-rate=*) option_update ${arg#*=} FRAME_RATE;;
--object-speed=*) option_update ${arg#*=} OBJECT_SPEED;;
--thrower-stone-sleep=*) option_update ${arg#*=} THROWER_STONE_SLEEP;;
--thrower-bullet-sleep=*) option_update ${arg#*=} THROWER_BULLET_SLEEP;;
--stone-dx=*) option_update ${arg#*=} THROWER_DX_SLEEP;;
--stone-nb=*) option_update ${arg#*=} NB_STONE;;
*)
echo -e "\033[1;33merror\033[0m unreconized argument '$arg'"
exit 1
esac; done
echo "Configuration saved in $file_gcc."
out_gcc > $file_gcc
cat $file_gcc
exit 0