diff --git a/.gitignore b/.gitignore index ce6bade..0da8765 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.lo *.o *.obj +Geometry # Precompiled Headers *.gch @@ -27,5 +28,6 @@ *.out *.app +.vscode .idea/ build/ diff --git a/Makefile b/Makefile index fdb2e31..c33f0de 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC=clang++ CFLAGS=-c -Wall -LDFLAGS=-lGL -lGLEW -lSDL -SOURCES=$(wildcard *.c *.cpp) +LDFLAGS=-lGL -lGLEW -lSDL -lSDL_mixer +SOURCES=$(wildcard *.c *.cpp Utility/*.cpp) OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=Geometry diff --git a/README.md b/README.md new file mode 100644 index 0000000..71d6d8e --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +## Geometry Wars Clone + +This is a Geometry Wars clone by Raul Roa. + +If you want to build this code on linux you first need to install the following libraries: +* OpenGL +* GLU +* SDL +* SDL Mixer (for playing audio) + +If you are using Ubuntu you can install these libraries by typing the following command: +``` +sudo apt-get install build-essential libgl1-mesa-dev libsdl-mixer1.2-dev + +``` + +Then , finally , build the code by running the following command +``` +make linux +``` diff --git a/SDLWrapper.hpp b/SDLWrapper.hpp index 56c0eb9..8fe017a 100644 --- a/SDLWrapper.hpp +++ b/SDLWrapper.hpp @@ -9,7 +9,7 @@ // SDL // -#include +#include // STL // diff --git a/Utility/tSound.hpp b/Utility/tSound.hpp index 7b17039..fd71033 100644 --- a/Utility/tSound.hpp +++ b/Utility/tSound.hpp @@ -4,7 +4,7 @@ // Written by Terence J. Grant - tjgrant [at] tatewake [dot] com // Find the full tutorial at: http://gamedev.tutsplus.com/series/ //---------------------------------------------------------------------------------- -#include +#include #include class tSound diff --git a/main.cpp b/main.cpp index 0e5f610..54c8003 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,5 @@ #include "SDLWrapper.hpp" +#include //#include #if EMSCRIPTEN @@ -23,6 +24,20 @@ void channelDone(int channel) { printf("channel %d finished playback.\n",channel); } +bool initAudio() +{ + int audio_rate = 44100; + Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */ + int audio_channels = 2; + int audio_buffers = 4096; + + if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) + { + printf("Unable to open audio!\n"); + return false; + } + return true; +} int main() { @@ -33,6 +48,14 @@ int main() #if EMSCRIPTEN emscripten_set_main_loop( step, 0, 0 ); #else + Mix_Music* music = nullptr; + if(initAudio()) + { + music = Mix_LoadMUS("./Resources/Sounds/music.wav"); + if(music) + Mix_PlayMusic(music, -1); + } + while( game->IsRunning( )) { step( ); @@ -40,6 +63,6 @@ int main() #endif delete game; - + Mix_FreeMusic(music); return 0; } \ No newline at end of file