# SED accelerated racing game shell script with bash enhancements.
# Copyright (C) 200  Jan Hubicka
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#!/bin/sh
clear

trap 'left="$left 1";signal=true' 3
trap 'right="$right 1";signal=true' 2
ulimit -c 0
stty -echo quit
if [ -f ~/.shscore ] ; then
echo "High score:"
head -n 22 <~/.shscore
fi
signal=false

echo "          .----.          Copyright (C) 1999 Jan Hubicka                .
----."
echo "        ,-'     \`--                                                   ,-
'     \`--"
echo "\`\`\`\`\`\`\`\`\`--o------o-'                                         \`
\`\`\`\`\`\`\`\`--o------o-'"
while [ $signal = false ]
do
/bin/echo -e -n ".oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO Press ^C to continue oOo.oOo.o
Oo.oOo.oOo.oOo.oOo.oOo\r"
/bin/echo -e -n "oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo Press ^C to continue Oo.oOo.oO
o.oOo.oOo.oOo.oOo.oOo.\r"
/bin/echo -e -n "Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo. Press ^C to continue o.oOo.oOo
.oOo.oOo.oOo.oOo.oOo.o\r"
/bin/echo -e -n "o.oOo.oOo.oOo.oOo.oOo.oOo.oOo.o Press ^C to continue .oOo.oOo.
oOo.oOo.oOo.oOo.oOo.oO\r"
done
clear
street="                      |.........$.........|                       "
destreet="                      |...................|                       "
for x in 1 2 3 4 5 6 7 8 9
do
echo "$destreet"
done
echo "            SH-car bash version 1.0 ^Z-left ^C-right"
if [ "$RANDOM" = "" ] ; then
echo "                   (Requires BASH to be funny)"
fi
for x in 1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20 21 22 22DT3
do
echo "$destreet"
done
echo -e -n "                      |---------3---------|                       \
r"
sleep 1
echo -e -n "                      |---------2---------|                       \
r"
sleep 1
echo -e -n "                      |---------1---------|                       \
r"
sleep 1
echo -e -n "                      |-------------------|                       \
r"
signal=fase
left=""
right=""
echo &
start=$!
while true
do
while true
do
while [ 1 = 1 ]
do
sedcmd=""
case $RANDOM in
10*)
sedcmd=$sedcmd's/[\\|\||\/]/|/g;s/[\\|\||\/][^ ]/ \\/g' ;;
*[1-3])
case $street in
"  "*)
sedcmd=$sedcmd'sX [\\|\||\/]X\/\.Xg;sX[^ ][\\|\||\/]X\/ Xg' ;;
esac ;;
*[4-6])
case $street in
"                                                             "*) ;;
*"  ")
sedcmd=$sedcmd'sX[\\|\||\/] X.\\Xg;sX[\\|\||\/][^ ]X \\Xg' ;;
esac ;;
*)
sedcmd=$sedcmd's/[\\|\||\/]/|/g' ;;
esac
for name in $left
do
#echo left
sedcmd=$sedcmd';s/.\$/\$\./g'
done
left=""
for name in $right
do
sedcmd=$sedcmd';s/\$./\.\$/g'
done
right=""
bstreet=$street
bdestreet=$destreet
signal=true
while [ $signal = true ]
do
signal=false
street=$bstreet
destreet=$bdesreet
street=`echo "${street}" | sed -e "$sedcmd"`

destreet=`sed 's/\\$/\\./g' <<TEST
$street
TEST`
done
echo -n -e "$bdestreet
$street\r"
case $street in
*[\/\|\\]*\$*[\/\|\\]*) ;;
*) echo "CRASH"
 echo &
 stty echo
 score=`expr $! - $start`
 echo "score: "$score
 echo -n "enter your name:"
 read blb
 echo -e "$score\t:$blb" >>~/.shscore
 sort -n -r ~/.shscore >~/.shscore.$$
 mv ~/.shscore.$$ ~/.shscore
 head <~/.shscore
 echo "Press enter to continue"
 read blb
 exit ;;
esac
done
done
done


