TORONTO KIDS COMPUTER CLUB | Monday Online Python Homework 04.15.
post-template-default,single,single-post,postid-16218,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Monday Online Python Homework 04.15.

16 Apr Monday Online Python Homework 04.15.

Question 1:

Modify the program we made in the class. Add starting screen as below, the real game will start when play click the mouse in the range of the “PLAY” button. (Scroll down for more hint)

You can download the background images from below:

The size of the background image is 640 x 480 pixels

The location of the “PLAY” button is:
220 pixels to the left of the screen
280 pixels to the top of the screen

The size of the “PLAY” button is 235 pixels in width and 70 pixels in height



The following code is how to load an image to the background

startImage = pygame.image.load(‘put picture name here‘).convert()
screen.blit(startImage, [0, 0])

do not forget flip the screen afterwards to show the starting image


You need detect if there’s mouse down event, you can find code some where in the code


pygame.mouse.get_pos()[0]: it is mouse’s x position to the left of the screen
pygame.mouse.get_pos()[1]: it is mouse’s y position to the top of the screen

Question 2:

So far, the game only has 5 enemy spaceship. Modify your game coding, let the game create a new enemy every certain period of time. Make sure the new enemy appears at the top of the screen but random horizontal position.

No Comments

Sorry, the comment form is closed at this time.