Hardware Reference
In-Depth Information
one, there is no point in scanning for a power pill. If you make a note of where the last pill
pixel was found, you can search close to that for the surrounding colour that indicates a
power pill. he two functions involved with pill eating are shown in Listing 6-4.
Listing 6-4 Eating the Pills
def eat(p):
global eaten, ghostPos, ghostRelease, gNumber
if pillEat(p):
eatSound.play()
# wipe the pill area
pygame.draw.rect(pillsLayer,(1,0,0), (p[0]- ;
screenOffset, p[1], pieMan,pieMan),0)
updateScore(3)
eaten += 1
if eaten >= 96:
eaten = 0
drawPills()
ghostPos = copy.deepcopy(ghostInitalPos) ;
# return ghosts to base
gNumber = 0
ghostRelease = time.time()+ 5.0 ;
# time for first ghost
pygame.display.update()
def pillEat(p): # test if you are over a pill
global ppCount
fpx = 0
fpy = 0
pill = False
ppColour = (0,255,255,255)
if p[0] > screenOffset and p[0] < rightLimit :
piy = p[1]+24
for pix in range(p[0]+10,p[0]+38,9):
if pillsLayer.get_at((pix-screenOffset, piy));
== pillColour:
pill = True
fpx = pix - screenOffset
pix = p[0]+24
for piy in range(p[1]+10,p[1]+38,9):
if pillsLayer.get_at((pix-screenOffset, piy));
== pillColour:
pill = True
fpy = piy
continued
Search WWH ::




Custom Search