Hardware Reference
In-Depth Information
Listing 6-3 Making a Move
def makeStep(p,direction, increment):
global moved
moved = False
if direction == 6:
if wallH(p,p[1]+pieMan+increment):
p[1] += increment
moved = True
else:
while wallH(p,p[1]+pieMan+1):
p[1] +=1 # pull into bottom
elif direction == 4:
if wallH(p,p[1]-increment):
p[1] -= increment
moved = True
else :
while wallH(p,p[1]-1):
p[1] -= 1 # pull into top
elif direction == 2:
if wallV(p,p[0]+pieMan+increment):
p[0] += increment
moved = True
else :
while wallV(p,p[0]+pieMan+1):
p[0] += 1 # pull in to left side
if p[0] > screenOffset + playWidth:
# leaving the screen
p[0] = screenOffset - pieMan
moved = True
elif direction == 0:
if wallV(p,p[0]-increment):
p[0] -= increment
moved = True
else :
while wallV(p,p[0]-1):
p[0] -= 1 # pull in to side
if p[0] < screenOffset - pieMan:
# leaving the screen
p[0] = screenOffset + playWidth
moved = True
Search WWH ::




Custom Search