28 Oct PMCA Sunday 10:00 Practice -26.
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.
- 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.
- create a pygame.sprite.Group() for all the lasers.
- 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():
- do not forget to update every laser object in the laser group so the laser can move up
- 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.