Game Development Reference
In-Depth Information
19 - Sound and Images
95. # draw the black background onto the surface
96. windowSurface.fill(BLACK)
97.
98. # move the player
99. if moveDown and player.bottom < WINDOWHEIGHT:
100. player.top += MOVESPEED
101. if moveUp and player.top > 0:
102. player.top -= MOVESPEED
103. if moveLeft and player.left > 0:
104. player.left -= MOVESPEED
105. if moveRight and player.right < WINDOWWIDTH:
106. player.right += MOVESPEED
107.
108.
109. # draw the block onto the surface
110. windowSurface.blit(playerStretchedImage, player)
111.
112. # check if the block has intersected with any food
squares.
113. for food in foods[:]:
114. if player.colliderect(food):
115. foods.remove(food)
116. player = pygame.Rect(player.left, player.top,
player.width + 2, player.height + 2)
117. playerStretchedImage = pygame.transform.scale
(playerImage, (player.width, player.height))
118. if musicPlaying:
119. pickUpSound.play()
120.
121. # draw the food
122. for food in foods:
123. windowSurface.blit(foodImage, food)
124.
125. # draw the window onto the screen
126. pygame.display.update()
127. mainClock.tick(40)
Search WWH ::




Custom Search