
#!/usr/bin/env python
#
# my game
#
import time
import datetime
import sys

print "In this game you will try to go through an easy maze."
print "Don't hit a * or |."
print "You will be timed."
print "Use WASD to move"
print ""

arr1= " *******     ********       ******* *******"
arr1a="    |   *    **    **       *    ** **     "
arr2= "*** | *  *   *  **   *     *  **  * *  ****"
arr3= "  * | *  **  * ** **  *   *  **** * * **   "
arr4= "  * | **   * *  *  **  ***  *  *  * *  *   "
arr5= "  * | * **  *** *    *  |  *   * ** ** *   "
arr6= "  * | *  *  **  *     *   *    *  ***  *   "
arr7= "  *   *   *    **      *  *    **     **   "
arr8= "  *****    ******      ****    *********   "
hpos = 0 
vpos = 0 
x=""

origscreen = []
def formscreen():
   origscreen.append(arr1)
   origscreen.append(arr1a)
   origscreen.append(arr2)
   origscreen.append(arr3)
   origscreen.append(arr4)
   origscreen.append(arr5)
   origscreen.append(arr6)
   origscreen.append(arr7)
   origscreen.append(arr8)


totaltime=0
formscreen()
i=0
while x != "stop":
    screen = []
    mylen = len(origscreen)
    i = 0
    loseflag = 0
    win = 0
    while (i < mylen):
         x = origscreen[i]
         screen.append(x)
         if i == vpos:
               if (x[hpos] == "|") or (x[hpos] == "*"):
                     loseflag = 1
               if (hpos == 41) and (vpos == 1):
                    win = 1
               x = x[:hpos] + ("o") + x[hpos+1:]
               screen[i] = x
         i = i+1
    for s in screen:
         print s
    if loseflag == 1:
        print "You lose"
        break
    if win == 1:
        print "You win"
        break
    mybeforetime = time.time()
    x = raw_input("Please hit w(up), s(down), a(left), d(right), or stop:")
    myaftertime = time.time()
    diff = myaftertime - mybeforetime
    print ("You hit the letter: ") + x
    if x == "w":
         vpos = vpos-1
    if x == "s":
         vpos = vpos+1
    if x == "a":
         hpos = hpos-1
    if x == "d":
         hpos = hpos+1
    totaltime = totaltime + diff
    print totaltime
    i=i+1

print "Your Time: ", totaltime

