from cmu_graphics import *

def onAppStart(app):
    restart(app)

def restart(app):
    app.dotRadius = 20
    app.dotCx = app.dotRadius
    app.ticksLeft = 100

def drawGameOverMessage(app):
    if app.ticksLeft == 0:
        dotColor = 'pink'
        message = 'You lost!'
    else:
        dotColor = 'lightGreen'
        message = 'You won!'
    drawLabel(message, 200, 100, size=16)
    drawLabel('Press r to restart', 200, 120, size=16)
    drawCircle(app.dotCx, 200, app.dotRadius, fill=dotColor, border='black')

def redrawAll(app):
    drawLabel('Dot Race', 200, 30, size=16)
    drawLabel('Alternate pressing m and n to move the dot', 200, 50, size=16)
    drawLabel(f'Time left: {app.ticksLeft}', 200, 70, size=16)

def onStep(app):
    pass

def onKeyPress(app, key):
    pass

def main():
    runApp()

main()
