TORONTO KIDS COMPUTER CLUB | PMCA Sunday 16:00 Python Homework 20.01.26.
16986
post-template-default,single,single-post,postid-16986,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

PMCA Sunday 16:00 Python Homework 20.01.26.

29 Jan PMCA Sunday 16:00 Python Homework 20.01.26.

Question:

Modify the program we made in the class to:

  • Create Missile class
  • Add one missile to your program
  • missile will automatically move from your spaceship to the top of the screen
  • once missile reach the top of the screen, it will re-appear from the location of your fighter

Hint:

  • speed has two values in the (),  the first value is how fast it could move horizontally while the second value is how fast it could move vertically. Think: Does missile move horizontally?
  • Think: how to move missile vertically and test if it reaches out the top of the screen?
  • exam the code of move method in the Enemy class and find out the logic of its movement. It does not need any extra arguments since the movement of the enemy is automatically base on the x,y speed. But once missile reach the top of the screen, it will re-appear from the location of your fighter. So the move method of Missile class may need a argument tell the location of the fighter and you can assign the fighter’s location to the the missile’s location like this:
    self.rect = location (when the missile reach out the top of the screen)
  • so far we could consider xxxxx.rect represents for the location, such as myFighter.rect is the location of object myFighter. We could pass the value of myFighter.rect as arguments into to the move method of Missile class.

You can download all the necessary images from below:

No Comments

Sorry, the comment form is closed at this time.