inital commit. Not all games work 100, or even 50 percent lol.

This commit is contained in:
Storm Dragon
2014-05-04 13:43:52 -04:00
parent cedd7a8ef5
commit d53c2eb074
71 changed files with 1753 additions and 0 deletions

11
numnastics/README Normal file
View File

@ -0,0 +1,11 @@
Numnastics
Written by Storm Dragon
released under the terms of the WTFPL http://wtfpl.net/
Requirements
sox
bash version 4 or greater
TTYtter (optional)
Playing
You are given a scrambled list of numbers from 1 to 9. Press the number you want to flip from, and that number, plus all the numbers after it will reverse. the object of the game is to get the numbers in the right order, 123456789, in as few tries as possible.

75
numnastics/numnastics Executable file
View File

@ -0,0 +1,75 @@
#!/bin/bash
check_dependancies()
{
if [ $# -eq 0 ] ; then
if [[ $(bash --version | head -n 1 | cut -f 1 -d "." | tr -d "[:alpha:]") < "4" ]] ; then
echo "This game requires bash version 4 or higher. Earlier versions may not be able to successfully run this code."
fi
if ! hash sox &> /dev/null ; then
echo "The program sox is required but does not appear to be installed on your system. Please install sox and try again."
exit 1
fi
fi
for i in $@ ; do
if ! hash $i &> /dev/null ; then
echo "The program $i is required but does not appear to be installed on your system. Please install $i and try again."
exit 1
fi
done
}
initializer()
{
tries=0
numberString="$(shuf -e 1 2 3 4 5 6 7 8 9 | tr -d "[:space:]")"
}
check_dependancies
initializer
while [ $numberString -ne 123456789 ] ; do
read -n 1 -p "$numberString " number
if [ "$number" == "Q" ] ; then
echo
exit 0
fi
if ! [[ "$number" =~ ^[0-9]+$ ]] ; then
unset number
fi
if [ "$number" == "0" ] ; then
unset number
fi
echo
if [ "$number" != "" ] ; then
i=0
while [ ${numberString:$i:1} -ne $number ] ; do
let i++
done
newNumberString=$(echo ${numberString:$i:9} | rev)
numberString=${numberString:0:$i}$newNumberString
let tries++
play -nqV0 synth .05 tri C2:C7 norm -7
else
play -qV0 "|sox -n -p synth saw E2 fade 0 0.25 0.05" "|sox -n -p synth saw E2 fade 0 0.25 0.05" norm -7
fi
done
if [ -f ".numnastics-score" ] ; then
oldHighScore=$(cat .numnastics-score | tr -d "[:alpha:][:cntrl:][:punct:][:space:]")
else
oldHighScore=0
fi
echo "Congratulations! You win with $tries moves."
if [ $oldHighScore -ne 0 ] ; then
echo " The record is $oldHighScore."
fi
if [ $tries -lt $oldHighScore -o $oldHighScore -eq 0 ] ; then
echo "$tries" > .numnastics-score
read -n 1 -p "You have set a new record! Would you like to post this score to Twitter using TTYtter? " answer
if [ "${answer^}" == "Y" ] ; then
check_dependancies ttytter
ttytter -readline=0 -silent -status="I just beat #numnastics in $tries moves! $(if [ $oldHighScore -ne 0 ] ; then echo "This is $(($oldHighScore - $tries)) fewer moves than my previous record!";fi)" &> /dev/null &
fi
fi
play -qV0 sounds/win.ogg
echo
exit 0

BIN
numnastics/sounds/win.ogg Normal file

Binary file not shown.