-
Notifications
You must be signed in to change notification settings - Fork 0
/
sleep.py
52 lines (36 loc) · 1.05 KB
/
sleep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# from trepan.api import debug
# import pdb
# pdb.set_trace()
import runWorld as rw
import drawWorld as dw
# Initialize world
name = "Cat Go!"
width = 500
height = 500
rw.newDisplay(width, height, name)
# World state will be single x coordinate at left edge of world
initState = 0
# Display the state by drawing a cat at that x coordinate
myimage = dw.loadImage("sullivan-kevin.bmp")
def updateDisplay(state):
dw.fill(dw.black)
dw.draw(myimage, (state, width/2))
# We'll update the state on each tick by incrementing the x stateinate
def updateState(state):
return(state+1)
# We'll terminate when the x stateinate reaches the screen edge
def endState(state):
if (state >= width):
return True
else:
return False
# For now we'll handle events just logging them to the console
#
def handleEvent(state, event):
return(state)
# Off we go! Start the cat at the left edge, and try for 30 FPS
frameRate = 60
initState = 0
# debug()
rw.runWorld(initState, updateDisplay, updateState, handleEvent,
endState, frameRate)