Knight's Quest is a 2D side-scrolling action-platformer written in Python with pygame-ce. You play Aldric, a knight whose kingdom has lost its Golden Crown to a goblin raid. You get it back by running, jumping, climbing and hitting things with a sword.
That is the whole pitch. If you've played a platformer before, you already know how to play this one. If you haven't, the controls are below and it will take you about a minute.
| Genre | Action platformer |
| Perspective | 2D side-scrolling, 1280 × 720 at 60 FPS |
| Players | One |
| Input | Keyboard and mouse, or any gamepad |
| Audio | Soft sound effects, quiet music on the menu and story screens, a victory fanfare. M mutes everything |
| Window | Custom title bar (drag, minimize, close) and F11 for fullscreen |
| Length | Two levels, roughly five minutes a run |
| Target | Windows, macOS and Linux, Python 3.10+ |
Someone who wants a short, honest game they can start in under a minute and beat the high score on. Also: anyone grading it, who would like to see the requirements without hunting for them. They're in section 6.
You need Python 3.10 or newer (python.org/downloads). On Windows, tick "Add python.exe to PATH" in the installer. It's the single most common reason this fails, so we're saying it twice.
Windows
git clone https://github.com/akhil-kk15/PythonSideScroller_game.git cd PythonSideScroller_game py -m venv .venv .venv\Scripts\python -m pip install -r requirements.txt .venv\Scripts\python main.py
macOS and Linux
git clone https://github.com/akhil-kk15/PythonSideScroller_game.git
cd PythonSideScroller_game
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/python main.pyNext time, just run the last line. Everything else is already done. Sprites ship with the repository and are prepared automatically on first launch.
Already have the game? Update it. Running git clone again will not update anything, and you will keep seeing the old version. Open a terminal in the game folder and run git pull origin main, then start the game as usual. Your saved highscores stay.
In each level, find the Gold Key, use it to open the locked gate, and walk into the cave exit. Do it in Level 1 (Emerald Grasslands), then again in Level 2 (Dark Forest, where the Goblin Brute lives). Beat both and the crown comes home.
Move, jump (tap to hop, hold to go high), climb ladders, drop through wooden bridges, and swing the sword in a three-hit combo. The game is generous about timing: it remembers a jump you pressed slightly early and allows one you pressed slightly late. This is deliberate. Nobody has ever enjoyed missing a jump by two frames.
Sound. Footsteps, sword swings, hits, coins and button clicks are all soft and low in the mix. Music plays on the main menu and on the story screens before a level, then steps aside so you can hear the game. A short fanfare plays when you win. Press M to mute everything.
You have 3 lives, and each life has 3 hearts. Lose all your hearts and the level restarts. Lose all your lives and the run is over. Health potions restore a heart.
| Enemy | Health | Damage | What it does | Points |
|---|---|---|---|---|
| Slime | 1 | 1 | Patrols, chases when you get close | 150 |
| Bat | 1 | 1 | Flies, then swoops | 200 |
| Goblin Warrior | 2 | 2 | Chases, raises its weapon, strikes. Dodge the wind-up | 300 |
| Goblin Archer | 2 | 1 | Stands still and fires arrows | 350 |
| Goblin Brute | 4 | 3 | Slow and heavy. Its swing cannot be interrupted | 800 |
| Action | Points |
|---|---|
| Coin | 100 |
| Blue gem | 250 |
| Health potion | 150 (plus one heart) |
| Gold key | 500 |
| Smash a crate or barrel | 50 |
| Open a chest | 300 (plus 3 coins and 1 gem) |
| Reach a level exit | 1,000 |
Pull a lever and three bonus gems appear. Your best five runs are saved, with the level reached and the date.
| Action | Keyboard and mouse | Gamepad |
|---|---|---|
| Move | A D or ← → |
Left stick or D-pad |
| Jump | Space, W or ↑ |
A or LB |
| Drop through a bridge | Hold S/↓, press Space |
Hold Down, press A |
| Climb | W S or ↑ ↓ |
Left stick or D-pad |
| Attack | J Z X F K or left click |
X B Y RB or RT |
| Pause | Esc or P |
Start |
| Restart level | R or Enter |
Back / Select |
| Fullscreen on / off | F11 |
n/a |
| Mute / unmute sound | M |
n/a |
| Menus | Mouse, or W/S + Enter |
Stick or D-pad + A (B = back) |
| Cutscenes | Enter / Space / click = next, Esc = skip |
A = next, B or Start = skip |
You can plug in a controller at any time, even mid-level.
The bar at the top of the window has minimize and close buttons, and you can drag it to move the window. Press F11 for fullscreen and M to mute the sound.
We wrote these down so nobody has to guess what the game is supposed to do.
| ID | The game must... |
|---|---|
| FR-1 | let the player move, jump at variable height, climb ladders, drop through bridges and attack with a three-hit combo |
| FR-2 | provide two levels with distinct layouts, parallax backgrounds, spike hazards and interactive props (crates, chests, levers, a locked gate) |
| FR-3 | provide five enemy types with different behaviour: patrol and chase, swoop, telegraphed melee, ranged attack, and an uninterruptible boss swing |
| FR-4 | gate progress in each level behind a key and a locked gate |
| FR-5 | show health, lives, coins, gems and score at all times |
| FR-6 | offer main, pause, controls, game-over and victory menus usable by mouse, keyboard and gamepad |
| FR-7 | play animated story cutscenes before Level 1, before Level 2 and at the ending |
| FR-8 | save a top-five leaderboard to highscores.txt |
| FR-9 | support gamepads that can be plugged in at any time, in Auto, XInput or DirectInput mode |
| FR-10 | show a custom title bar with minimize and close buttons, and let the player drag the window by it |
| FR-11 | switch between windowed and fullscreen mode with F11 |
| FR-12 | play soft sound effects (jumping, attacking, footsteps, button clicks, collecting items, taking damage), quiet background music in the main menu and story screens, and a victory fanfare, with M to mute |
| ID | The game must... |
|---|---|
| NFR-1 | run at 60 FPS in a 1280 × 720 window |
| NFR-2 | need only Python 3.10+ and one dependency, pygame-ce |
| NFR-3 | run on Windows, macOS and Linux |
| NFR-4 | need nothing beyond pip install; sprites are prepared automatically on first launch |
| NFR-5 | forgive near-miss input (jump buffering and coyote time) |
| NFR-6 | keep running, silently, if the computer has no audio device |
Online multiplayer, multiple save slots, and a level editor. This is a two-level game and it knows it.
main.py Game loop, HUD, state machine, level interactions
player.py Knight physics, ladders, jump buffering, combo attacks
level.py Level 1 and 2 layouts, enemy AI, collectibles, projectiles
story.py Animated pixel-art cutscenes
ui.py Mouse, keyboard and gamepad menus
joystick.py XInput and DirectInput controller support with hot-plug
highscores.py Persistent top-five leaderboard
background.py Parallax scrolling backgrounds
animation.py Sprite animation system
sounds.py Sound effects, music playback and the mute key
make_music.py Builds the background music (assets/music/theme.wav)
titlebar.py Custom title bar with minimize and close buttons
slice_assets.py Cuts the master sprite sheets into individual PNGs
assets/ Sprite sheets, sliced sprites and backgrounds
Useful for developers:
python main.py --controller-mode auto # or: xinput, directinput python -m compileall -q *.py # syntax check python slice_assets.py # re-slice assets/base.jpg, knight.jpg, goblin.jpg
Press 1 or 2 in-game to jump straight to a level (that run's score isn't saved). Delete highscores.txt to reset the leaderboard.
To change the background music, edit make_music.py and run python make_music.py. It rewrites assets/music/theme.wav.
"python", "py" or "python3" is not recognized
Python isn't installed, or isn't on your PATH. Install Python 3.10+. On Windows, re-run the installer, choose Modify, enable Add python.exe to PATH, then reopen your terminal.
"No such file or directory: requirements.txt" or "main.py"
Your terminal isn't in the game folder. cd PythonSideScroller_game and try again.
"No module named pygame"
Start the game with the virtual environment's Python: .venv\Scripts\python main.py (Windows) or .venv/bin/python main.py (macOS/Linux).
PowerShell: "running scripts is disabled on this system"
You don't need to activate the environment. Call .venv\Scripts\python directly, as shown above.
Linux: "ensurepip is not available"
sudo apt update && sudo apt install -y python3-venvMy controller does nothing, or the buttons feel swapped
Open Controls from the main or pause menu, check the Gamepad status line, and click Mode to switch between Auto, XInput (Xbox-style) and DirectInput (classic USB or Bluetooth). Or launch with --controller-mode xinput or --controller-mode directinput.
I still see the old version of the game
git clone only works the first time. If the folder already exists, open a terminal inside it and run git pull origin main, then start the game again.
I hear no sound
Look at the first lines the game prints in the terminal. "Sound is on" means the game is playing audio, so check your Windows volume and output device, and that you have not pressed M (mute). "Sound is off" shows the reason, usually that no audio device could be opened. Music plays only on the main menu and story screens, not during levels.







