Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dor-sketch/snakes_ladders
Enhanced with Qt6, WebAssembly-ready, and simplified CMake builds.
https://github.com/dor-sketch/snakes_ladders
cairo cairo-drawing cmake cpp game-development gtk3 qt6
Last synced: 4 months ago
JSON representation
Enhanced with Qt6, WebAssembly-ready, and simplified CMake builds.
- Host: GitHub
- URL: https://github.com/dor-sketch/snakes_ladders
- Owner: Dor-sketch
- License: mit
- Created: 2024-04-12T15:15:10.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-06-18T11:59:51.000Z (8 months ago)
- Last Synced: 2024-10-10T22:01:48.967Z (4 months ago)
- Topics: cairo, cairo-drawing, cmake, cpp, game-development, gtk3, qt6
- Language: C++
- Homepage:
- Size: 4.21 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License
Awesome Lists containing this project
README
![]()
Snakes and Ladders Game
Enhanced with Qt6, WebAssembly-ready, and simplified CMake builds
This project is an implementation of the classic Snakes and Ladders game with a twist - it incorporates musical notes that are played as the players move across the board. The game uses GTK for the GUI and optionally supports MIDI files to generate the notes.
![]()
![]()
![]()
![]()
## Table of Contents
- [Table of Contents](#table-of-contents)
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Step 1: Install Dependencies](#step-1-install-dependencies)
- [Step 2: Build the Project](#step-2-build-the-project)
- [Using Makefile](#using-makefile)
- [Playing the Game](#playing-the-game)
- [MIDI Support](#midi-support)
- [Example](#example)
- [License](#license)
- [Contributing](#contributing)## Features
- Classic Snakes and Ladders gameplay
- Musical notes played based on player positions
- Graphical user interface using GTK
- Optional MIDI file support for generating notes## Prerequisites
- C++ compiler (e.g., g++)
- GTK development libraries
- CMake (optional, for building)
- MIDI library (optional, if using MIDI files)
- OpenCV (optional, for image processing)## Installation
### Step 1: Install Dependencies
For Ubuntu:
```bash
sudo apt-get update
sudo apt-get install build-essential libgtk-3-dev cmake
```For macOS:
```bash
brew install gtk+3 cmake
```### Step 2: Build the Project
The project can be built using the provided `Makefile` or `CMakeLists.txt` file.
#### Using Makefile
```bash
make
```where `` can be:
- `USE_MIDIFILE=1`: Enable MIDI file support
- `USE_OPENCV=1`: Enable OpenCV support - not implemented yet### Playing the Game
1. **Rolling the Dice**: Click the "Roll" button to roll the dice and move your player.
2. **Winning the Game**: The first player to reach the last cell wins the game.
3. **Musical Notes**: Notes are played based on the player's position on the board.## MIDI Support
This project optionally supports using MIDI files to generate the musical notes. To enable this feature:
1. **Install MIDI Library**:
- Follow the instructions in the MIDI library's documentation to install it.2. **Define the `USE_MIDIFILE` Macro**:
- Add `#define USE_MIDIFILE` at the top of `game.cpp` or pass it as a compiler flag (`-DUSE_MIDIFILE`).3. **Link MIDI Library**:
- Ensure that the MIDI library is linked during the build process. Modify the build commands or `CMakeLists.txt` accordingly.4. **Set MIDI File Path**:
- Modify the `generateNotes` function in `game.cpp` to use the desired MIDI file path.## Example
Here is an example of how to modify `game.cpp` to use a MIDI file:
```cpp
#define USE_MIDIFILE
#include "midifile/include/MidiFile.h"// Modify generateNotes function
std::vector> Game::generateNotes(const std::string &midi_file_path) {
std::cout << "MIDI file path: " << midi_file_path << std::endl;
if (midi_file_path.empty()) {
std::cerr << "MIDI file path is empty" << std::endl;
return generateNotes(10);
}// Open the MIDI file
smf::MidiFile midi_file;
if (!midi_file.read(midi_file_path)) {
std::cerr << "Failed to open MIDI file" << std::endl;
return generateNotes(10);
}// Create a 2D vector to hold the notes
std::vector> notes;// Read the MIDI messages
for (int track = 0; track < midi_file.getTrackCount(); ++track) {
for (int event = 0; event < midi_file[track].getEventCount(); ++event) {
if (midi_file[track][event].isNoteOn()) {
int note = midi_file[track][event][1];
notes.push_back({note});
}
}
}return notes;
}
```## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contributing
Contributions are welcome! Feel free to create an issue or submit a pull request if you have any improvements or bug fixes.