Problem 1: Disappearing spaceship
This is an exercise in close-reading of code and debugging. The fix for this problem is very simple (there are several ways to fix the problem, but it can be done by modifying a single line of code), but you're given no hints, so you will have to track down the issue yourself.
Problem 2: Stuck thruster
As in the case of the previous exercise, this issue can be resolved with a small modification to a single line of code. You'll need to look closely at the thruster display logic and the keyboard event logic in several classes to see where the issue is arising.
Problem 3: Endless laser beams
At the moment, the laser beams fired by the spaceship are staying in the scene forever. This clutters up the scene and isn't good for game play. We want the laser beams to be removed from the scene when their lifespan is exhausted (set this to occur after 100 frames).
There are two places you'll be expected to modify code, which are highlighed by the labels TODO: Problem 3, Part 1
and TODO: Problem 3, Part 2
. For Part 1, you'll make whatever modifications are necessary in laserbeam.py
to implement a lifespan of 100 frames and ensure that it maintains the laser beam's remaining lifespan with passing frames.
For Part 2, you'll modify game_controller.py
to see to it that the game controller handles the laser beams appropriately based on their lifespan. Specifically, laser beams which have been in the scene for longer than their lifespan specifies (as measured in frames/draw cycles) should be removed from the scene.
Problem 4: Blowing up asteroids
Finally, our laser torpedoes are not currently having any effect on the asteroid. This is a big problem, because without blowing up asteroids, we can never win the game!
The code needed for this will all reside in the game controller class. It will be implemented in two parts:
The places where you'll need to add code are highlighted in the files by the TODOs
. If you need to add any new instance variables or constants, you should put those in an appropriate place in the code. Read the code and the comments closely for further guidance on what needs to be done.
Laser beams that hit an asteroid should also be removed from the scene.
你好,请你看 ‘有问必答’ 的规则。
请你分析一下现有的程序,提出问题,专家们会来帮助你。
你好,我是有问必答小助手。为了技术专家团更好地为您解答问题,烦请您补充下(1)问题背景详情,(2)您想解决的具体问题,(3)问题相关代码图片或者报错信息。便于技术专家团更好地理解问题,并给出解决方案。
您可以点击问题下方的【编辑】,进行补充修改问题。