Course: CS50's Introduction to Game Development
Assignment: Super Mario Bros
Engine / Language: LÖVE2D (Lua)
This repository contains my implementation of the Super Mario Bros assignment from CS50's Introduction to Game Development.
🎮 Inspired by the classic, this project introduces keys, locks, and a progressive level system that extends gameplay dynamically.
📺 You can also watch my gameplay demo on YouTube.
- ✔️ Safe Player Spawn — Player always spawns above solid ground, never over a pit.
- ✔️ Keys & Locks — Randomly generated colored key and lock block (from
keys_and_locks.png). Picking up the key unlocks the block and makes it disappear. - ✔️ Goal Post System — Unlocking the block spawns a goal post at the end of the level using assets from
flags.png. - ✔️ Progressive Levels — Touching the goal post regenerates a longer level and restarts the player at the beginning, while preserving score across levels.
- ✔️ PlayState Enhancements — Modified
PlayState:enterto handle level tracking, score persistence, and map resizing.
-
Install LÖVE2D.
-
Clone this repository:
git clone https://github.com/huzaifa-gamedev/cs50-super-mario-bros.git cd cs50-mario -
Run the game:
love .
- Arrow Keys (↑ ↓ ← →) — Move Mario.
- Spacebar — Jump.
- Escape — Quit game.
- Player Ground Check: Iterated over columns in
LevelMaker.luato ensure spawn above a solid tile (TILE_ID_GROUND). - Keys & Locks: Added random placement during level generation with
onConsumecallback logic for key pickup. - Goal Post: Spawned pole + flag pieces in
onCollidewhen lock is removed. UsedGameObjectinstances to construct the flagpole. - Level Progression: Extended
PlayState:enterwith parameters (level,score,mapWidth) to enable regenerating levels with increasing difficulty. - State Persistence: Updated
gStateMachine:change('play')calls to pass score and level width for continuity.
- Original skeleton code & assets: CS50's Introduction to Game Development (Harvard). Licensed under CC BY-NC-SA 4.0.
- This implementation: © 2025 Muhammad Huzaifa Karim. Licensed under the MIT License.
For more details, see ATTRIBUTION.md.
Muhammad Huzaifa Karim
GitHub Profile
For ideas, feedback, or collaboration, feel free to reach out via GitHub.
© 2025 Muhammad Huzaifa Karim. All rights reserved.
