Skip to content

noumanic/Dodge-Em

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Dodge 'Em Game

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!

๐ŸŽฎ Game Overview

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.

โœจ Features

  • 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

๐ŸŽฏ Gameplay

Controls

  • 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)

Objective

  • 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

Levels

  • 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

๐Ÿ› ๏ธ Technology Stack

  • Language: C++
  • Graphics Library: SFML 2.x
  • Paradigm: Object-Oriented Programming (OOP)
  • File I/O: High score persistence

๐Ÿ“‹ Prerequisites

  • C++ compiler (GCC, Clang, or MSVC)
  • SFML 2.x library
  • CMake (optional, for building)

Installing SFML

Windows

  1. Download SFML from https://www.sfml-dev.org/download.php
  2. Extract to a directory (e.g., C:\SFML)
  3. Link the library in your project settings

Linux (Ubuntu/Debian)

sudo apt-get install libsfml-dev

macOS

brew install sfml

๐Ÿš€ Building and Running

Compilation

Using g++ (Linux/macOS)

g++ -std=c++11 main.cpp -o dodge_em -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio

Using g++ (Windows with MinGW)

g++ -std=c++11 main.cpp -o dodge_em.exe -IC:\SFML\include -LC:\SFML\lib -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio

Using Visual Studio

  1. Create a new C++ project
  2. Add main.cpp, game.h, and menu.h to the project
  3. 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
  4. Copy SFML DLLs to the output directory

Running

./dodge_em        # Linux/macOS
dodge_em.exe      # Windows

๐Ÿ“ Project Structure

Dodge 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

๐Ÿ—๏ธ Architecture

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.

๐Ÿ‘ฅ Contributors

๐Ÿ“š Course Information

  • Course: Object-Oriented Programming (CS)
  • Semester: Fall 2023
  • Project Type: OOP Semester Project

๐Ÿ“„ License

This project was developed as part of an academic course. All rights reserved.

๐ŸŽ“ Acknowledgments

  • 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

๐Ÿ“ Notes

  • The game requires all asset files (images, fonts, sounds) to be in the correct directories
  • High scores are stored in highscore.txt in the project root
  • The game window is 800x650 pixels for the main game and 960x720 for menus

๐Ÿ› Known Issues

  • Some window event handling may need refinement in future versions
  • Level progression beyond Level 1 may need additional implementation

๐Ÿ”ฎ Future Enhancements

  • 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! ๐Ÿš—๐Ÿ’จ

About

A classic arcade-style driving game built with C++ and SFML. Navigate through mazes, collect food items, avoid enemy cars, and achieve high scores across 4 challenging levels.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors