Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.lo
*.o
*.obj
Geometry

# Precompiled Headers
*.gch
Expand All @@ -27,5 +28,6 @@
*.out
*.app

.vscode
.idea/
build/
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
2 changes: 1 addition & 1 deletion SDLWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// SDL
//
#include <SDL.h>
#include <SDL/SDL.h>

// STL
//
Expand Down
2 changes: 1 addition & 1 deletion Utility/tSound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <SDL_mixer.h>
#include <SDL/SDL_mixer.h>
#include <list>

class tSound
Expand Down
25 changes: 24 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "SDLWrapper.hpp"
#include <SDL/SDL_mixer.h>
//#include <iostream>

#if EMSCRIPTEN
Expand All @@ -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()
{
Expand All @@ -33,13 +48,21 @@ 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( );
}
#endif

delete game;

Mix_FreeMusic(music);
return 0;
}