Welcome to Magical Pets Kingdom, a second-semester OOP game project built with C++ and SFML! In this fantasy game, players raise mythical pets, train them, and engage in epic battles. This project highlights OOP principles and SFML graphics magic. Let's dive in!
- Choose Your Pet: Dragon, Phoenix, Unicorn, or Griffin – each with unique stats and animations.
- Train: Level up your pet in the Training Camp to boost their stats.
- Shop: Purchase items like Healing Potions, Mana Potions, and Shields to aid your journey.
- Battle: Challenge enemy pets in battles and prove your kingdom's might.
- Guild System: Join a guild to unlock new missions and collective power.
- Animated Graphics & Background Music: Smooth animations and immersive music using SFML.
The game's code is neatly split into these OOP-based classes:
- Pet: Base class for pets (Dragon, Phoenix, Unicorn, Griffin) with stats and attack/defense logic.
- Player: Manages the player's name, chosen pet, and inventory.
- Battle: Handles combat mechanics and outcomes.
- Guild: Guild joining logic and related bonuses.
- TrainingCamp: Stat-boosting training sessions.
- Shop: Buy items to boost your pet's performance.
- Item: Base class for items (HealingPotion, ManaPotion, Shield).
- PetAnimation: Loads and animates pet spritesheets.
- MusicPlayer: Plays background music tracks and manages volume.
- ParallaxBackground: Dynamic background visuals for depth.
The game loop and main menu system are orchestrated in main.cpp with real-time rendering and user input handling.
Here's how to get the game running:
git clone https://github.com/abdullah-netiz/Magical-Pets-Kingdom_Game.git
cd Magical-Pets-Kingdom_GameFollow the SFML download and setup guide for your platform.
g++ main.cpp -o MagicalPetsKingdom -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audioFor Windows with Visual Studio, set up the SFML include and lib paths in project settings.
./MagicalPetsKingdom- Launch the game and choose your pet.
- Navigate using keyboard inputs (like arrow keys or number keys depending on your setup).
- Train in the Training Camp to level up your pet's attack and defense.
- Shop for items that boost your performance.
- Battle enemies to earn rewards and prove your worth.
- Enjoy the animated graphics and dynamic music!
✅ Fully OOP: Encapsulation, inheritance, polymorphism in action.
✅ Interactive Menus: Guilds, training, shop, and battle scenes.
✅ Pet Animations: Each pet has unique animation frames loaded from spritesheets.
✅ Audio Integration: Background music and sound effects powered by SFML.
✅ Dynamic Background: Parallax scrolling for an immersive feel.
✅ File Handling: Save and load pet stats and game progress (via files).
- Assets Folder: Contains pet spritesheets and music tracks.
- Spritesheets: Preloaded animations for each pet (
assets/Dragon/sheet.png, etc.). - Music: In-game music to boost the fantasy vibe.
- Inheritance for pets and items
- Composition for player and pet relationships
- Clear class responsibilities
- Graphics rendering: Sprites, textures, scaling
- Audio playback with volume control
- Event handling for real-time user input
- Stat-based combat
- Shop economy and item effects
- Training system for progression
- main.cpp: Core game loop and all class implementations in one file (can be split for bigger projects).
- assets/: All images and sounds needed for the game.
- README.md: (You're reading it!).
💡 Modularize the code (split classes into .cpp and .h files).
💡 Add more pets, items, and battle scenarios.
💡 Enhance AI for enemy pets.
💡 Implement save/load feature with JSON or XML.
💡 Add visual feedback for battles (damage numbers, health bars).
This project is a learning-based solo endeavor. Feel free to fork it and experiment! If you want to tweak gameplay, add new features, or clean up the code structure, go for it! Contributions are welcome.
This project is released for educational and non-commercial use. All assets are either placeholders or self-created. If you reuse the code, please credit the original creator (Abdullah).
Thanks for checking out Magical Pets Kingdom! It's been a fun and challenging project, combining OOP principles with real-time graphics and gameplay mechanics. Feel free to fork, play around, or simply enjoy battling mythical creatures!
🔥 Happy coding!