A classic arcade-style driving game implemented in C++ using SFML (Simple and Fast Multimedia Library). Navigate through a maze, collect food items, avoid enemy cars, and achieve the highest score!
Dodge 'Em is a single-screen driving game where the player controls a car in a maze-like arena. The objective is to collect food items while avoiding collisions with enemy cars controlled by the computer. The game features multiple levels with increasing difficulty, various food types with different rewards, and a high-score tracking system.
- Multiple Game Levels: 4 progressively challenging levels
- Various Food Types:
- Red Rectangle Food (10 points)
- Green Circle Food (20 points + extra life)
- White Triangle Food (10 points + makes enemies disappear for 10 seconds)
- Orange Rhombus Food (40 points)
- Enemy AI: Computer-controlled enemy cars with intelligent player tracking - enemies actively chase the player car while respecting maze boundaries
- Lives System: Start with 3 lives, lose one on collision with enemies
- High Score Tracking: Persistent high score system using file I/O
- Pause/Resume: Press 'P' to pause, 'R' to resume
- Menu System:
- Start New Game
- View High Scores
- Help/Instructions
- About
- Exit
- Arrow Keys: Move the player car (Up, Down, Left, Right)
- P Key: Pause the game
- R Key: Resume the game
- Escape Key: Return to main menu (in sub-menus)
- Collect all food items in the arena to progress to the next level
- Avoid collisions with enemy cars (blue) to preserve lives
- Achieve the highest score possible
- Level 1: Enemy cars actively track and chase the player, respecting maze boundaries
- Level 2: Enemy cars are fully active with improved tracking, can navigate around obstacles
- Level 3: Enemy cars track with increased speed and more aggressive pursuit
- Level 4: Multiple enemy cars simultaneously track and chase the player with enhanced AI
- Language: C++
- Graphics Library: SFML 2.x
- Paradigm: Object-Oriented Programming (OOP)
- File I/O: High score persistence
- C++ compiler (GCC, Clang, or MSVC)
- SFML 2.x library
- CMake (optional, for building)
- Download SFML from https://www.sfml-dev.org/download.php
- Extract to a directory (e.g.,
C:\SFML) - Link the library in your project settings
sudo apt-get install libsfml-devbrew install sfmlg++ -std=c++11 main.cpp -o dodge_em -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audiog++ -std=c++11 main.cpp -o dodge_em.exe -IC:\SFML\include -LC:\SFML\lib -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio- Create a new C++ project
- Add
main.cpp,game.h, andmenu.hto the project - Configure project properties:
- Add SFML include directory to Additional Include Directories
- Add SFML lib directory to Additional Library Directories
- Link against:
sfml-graphics.lib,sfml-window.lib,sfml-system.lib,sfml-audio.lib
- Copy SFML DLLs to the output directory
./dodge_em # Linux/macOS
dodge_em.exe # WindowsDodge Em/
โโโ main.cpp # Main entry point and menu system
โโโ game.h # Game logic, classes, and game loop
โโโ menu.h # Menu system implementation
โโโ highscore.txt # High score data file
โโโ font/
โ โโโ arial.ttf # Font file for text rendering
โโโ img/ # Image assets (backgrounds, sprites)
โโโ sound/ # Audio files
โโโ pauseResume.wav
โโโ relax.wav
The game follows Object-Oriented Programming principles with the following main classes:
- Game: Main game controller managing game state, rendering, and game loop
- Player: Player car with movement, collision detection, and scoring
- Enemy: Enemy cars with player tracking AI, collision-aware movement, and boundary detection
- Maze: Maze boundaries and collision detection
- Food: Base food class with derived classes:
- Food (Rectangle)
- Circle_Food
- Triangle_Food
- Rhombus_Food
- Menu: Menu system with navigation and sub-menus
See the Class Diagram for detailed relationships.
-
Nouman Hafeez (@noumanic)
- Email: [email protected]
- Roll Number: 21I-0416
- Section: A
-
Muhammad Asim (@Dot-Asim)
- Email: [email protected]
- Roll Number: 21I-0852
- Section: A
- Course: Object-Oriented Programming (CS)
- Semester: Fall 2023
- Project Type: OOP Semester Project
This project was developed as part of an academic course. All rights reserved.
- Based on the classic Atari 2600 game "Dodge 'Em" by Carla Meninsky
- Built using SFML (Simple and Fast Multimedia Library)
- Developed as part of OOP course requirements
- The game requires all asset files (images, fonts, sounds) to be in the correct directories
- High scores are stored in
highscore.txtin the project root - The game window is 800x650 pixels for the main game and 960x720 for menus
- Some window event handling may need refinement in future versions
- Level progression beyond Level 1 may need additional implementation
- Additional levels beyond Level 4
- Power-up system expansion
- Sound effects for collisions and food collection
- Advanced pathfinding algorithms (A*, Dijkstra) for smarter enemy navigation
- Predictive enemy AI that anticipates player movement
- Multiplayer support
- Leaderboard with online integration
Enjoy playing Dodge 'Em! ๐๐จ