TORONTO KIDS COMPUTER CLUB | Friday 17:00 Python Practice 20.10.02.
18404
post-template-default,single,single-post,postid-18404,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

Friday 17:00 Python Practice 20.10.02.

05 Oct Friday 17:00 Python Practice 20.10.02.

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. create a pygame.sprite.Group() for all the lasers.
  2. 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():
    ….
  3. do not forget to update every laser object in the laser group so the laser can move up
  4. 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.