Enhanced with Qt6, WebAssembly-ready, and simplified CMake builds.
MIT License
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.
For Ubuntu:
sudo apt-get update
sudo apt-get install build-essential libgtk-3-dev cmake
For macOS:
brew install gtk+3 cmake
The project can be built using the provided Makefile
or CMakeLists.txt
file.
make <flags>
where <flags>
can be:
USE_MIDIFILE=1
: Enable MIDI file supportUSE_OPENCV=1
: Enable OpenCV support - not implemented yetThis project optionally supports using MIDI files to generate the musical notes. To enable this feature:
Install MIDI Library:
Define the USE_MIDIFILE
Macro:
#define USE_MIDIFILE
at the top of game.cpp
or pass it as a compiler flag (-DUSE_MIDIFILE
).Link MIDI Library:
CMakeLists.txt
accordingly.Set MIDI File Path:
generateNotes
function in game.cpp
to use the desired MIDI file path.Here is an example of how to modify game.cpp
to use a MIDI file:
#define USE_MIDIFILE
#include "midifile/include/MidiFile.h"
// Modify generateNotes function
std::vector<std::vector<int>> 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<std::vector<int>> 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;
}
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Feel free to create an issue or submit a pull request if you have any improvements or bug fixes.