TORONTO KIDS COMPUTER CLUB | PMCA Sunday 10:00 Practice -26.
18520
post-template-default,single,single-post,postid-18520,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

PMCA Sunday 10:00 Practice -26.

28 Oct PMCA Sunday 10:00 Practice -26.

Question:
We have created class Laser, however we haven’t put it into use, please make change in the main program so that the fighter can shoot laser when we press the mouse.

  1. define an update() method for laser, so laser will keep moving up. the laser object will be killed if reached the top of the screen.
  2. create a pygame.sprite.Group() for all the lasers.
  3. every time you click down the mouse, the program will create the laser object and add the object to the laser group, we can use the following code to check if you click the mouse or not:
    if True in pygame.mouse.get_pressed():
    ….
  4. do not forget to update every laser object in the laser group so the laser can move up
  5. do not forget to blit every leaser object in the laser group so the laser will be put to the game screen at correct location.
No Comments

Sorry, the comment form is closed at this time.