This project is a basic sample written in C that demonstrates the usage of the SDL2 and SDL2_mixer libraries. It uses CMake as a build system. This program will start playing waves sound that can be paused/resumed by pressing the SPACE key. When one of the arrows keys is pressed a sound effect is played parallelly with the waves sound.
It could be used as a base for any SDL2 project. Just fork it, clone it and
execute the rename_project.sh
script. You will be prompted to enter the new
project name, the new executable name and the new git repository, but you can
keep the autodetected values. Finally, just commit and push the result to your
repository.
- Git
- C Compiler (gcc, ...)
- CMake
- SDL2 library
- SDL2_mixer library
On Debian/Ubuntu based distributions, use the following command:
sudo apt install git build-essential pkg-config cmake cmake-data libsdl2-dev libsdl2-mixer-dev
Optional packages:
- SDL2_image library
- SDL2_ttf library
- SDL2_net library
- SDL2_gfx library
sudo apt install libsdl2-image-dev libsdl2-ttf-dev libsdl2-net-dev libsdl2-gfx-dev
# Clone this repo
git clone https://gitlab.com/aminosbh/sdl2-mixer-sample.git
cd sdl2-mixer-sample
# Create a build folder
mkdir build
cd build
# Build
cmake ..
make
# Run
./sdl2-mixer-sample
Note: To use SDL2_image, SDL2_ttf, SDL2_net or SDL2_gfx, you should
uncomment some instructions in the CMakeLists.txt file and re-execute the
make
command.
See IDE_USAGE.md for details.
Author: Amine B. Hassouna @aminosbh
This project is distributed under the terms of the MIT license <LICENSE>.
Files under the assets/waves-at-baltic-sea-shore
directory are distributed
under the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication license. (For
more details, please see <README.md>).
Files under the assets/claps-and-snares
directory are distributed
under the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication license. (For
more details, please see <README.md>).