This project is a single-file Defender-lite clone using Pygame. It introduces students to camera wrapping, world-space vs. screen-space coordinates, and multi-stage enemy AI using a small, readable object-oriented codebase.
A working Defender-lite game with:
- A player ship that thrusts left/right and adjusts altitude, wrapping around a world several screens wide
- Humanoids on the ground that landers try to abduct, carry upward, and turn into a faster "mutant" enemy if they reach the top
- A radar strip along the top meant to show where everything is across the whole world
- Waves, lives, scoring, and bonus points for rescuing a humanoid mid-fall
It has one deliberate bug and three optional features left as empty functions. You are expected to analyze, interact with an AI assistant, and complete/fix the game to make it fully functional and more interesting.
- Make sure you have Python 3.10+ installed.
- Install dependencies:
pip install pygame- Run the game:
python game.pyControls: Left/Right to thrust, Up/Down to change altitude, Space to fire, R to reset.
Each task must be completed using an iterative process involving LLM suggestions and your critical code review.
The radar strip is supposed to show every humanoid, lander, and the player at their true position across the entire wrapping world, so threats anywhere in the world are visible at a glance. In the current build, the radar only ever shows things clustered near the player's own position, because it plots each blip's position relative to the player (screen space) instead of its absolute position in the world. Fix
draw_radarso each blip's horizontal position on the radar reflects its actual place in the world, from one edge to the other, regardless of where the player currently is.
Called once per frame in
draw, asscreen.fill(sky_color(self.wave) or (5, 5, 20)). It receives the current wave number and should return an(r, g, b)color, orNoneto keep the default near-black sky. Idea: brighten or shift hue as waves progress.
Called from
update()the moment the player catches a falling humanoid (one a lander dropped or released mid-air), right after the 500-point bonus is added and the humanoid is placed safely back on the ground. It receives the rescuedHumanoid. Its return value is ignored. Idea: a "+500" popup, or a short invulnerability boost as a reward.
Called every frame in
update(). It takes no arguments and should return an integer score value, orNoneto disable bonus lives entirely. Whenever the score crosses a multiple of that value for the first time, one life is awarded automatically — the bookkeeping (self.bonus_awarded) is already implemented, so you only need to choose the threshold. Idea: return10000.
- The player and every enemy wrap smoothly across both edges of the world
- The radar shows the whole world at once; only the main viewport centers on the player, not the radar
- A lander that finishes carrying a humanoid off the top of the screen becomes a faster, more aggressive mutant
- Catching a humanoid mid-fall returns it safely to the ground and awards points; letting it fall too far kills it
- The game ends when lives reach zero
defender/
├── game.py
└── README.md
Submission is only the following three things:
- [] A 10-second video of gameplay before your changes, showing the bug/broken behavior
- [] A 10-second video of gameplay after your changes, showing the bug fixed and the new features working
- [] The Chat/LLM used page link, with the complete chat history