@@ -48,23 +48,24 @@ CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Ws | |||||
AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm") | AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm") | ||||
# Use SDL? | # Use SDL? | ||||
ac_cv_my_have_sdl="no" | |||||
ac_cv_my_have_sdl="yes" | |||||
save_CPPFLAGS="${CPPFLAGS}" | save_CPPFLAGS="${CPPFLAGS}" | ||||
AC_PATH_PROG(SDL_CONFIG, sdl-config, no) | AC_PATH_PROG(SDL_CONFIG, sdl-config, no) | ||||
if test "${SDL_CONFIG}" != "no"; then | if test "${SDL_CONFIG}" != "no"; then | ||||
CPPFLAGS="${CPPFLAGS} `sdl-config --cflags`" | CPPFLAGS="${CPPFLAGS} `sdl-config --cflags`" | ||||
fi | fi | ||||
AC_CHECK_HEADERS(SDL_image.h, | AC_CHECK_HEADERS(SDL_image.h, | ||||
[ac_cv_my_have_sdl="yes"], | |||||
[ac_cv_my_have_sdl="no"]) | |||||
[:],[ac_cv_my_have_sdl="no"]) | |||||
AC_CHECK_HEADERS(SDL_mixer.h, | |||||
[:],[ac_cv_my_have_sdl="no"]) | |||||
CPPFLAGS="${save_CPPFLAGS}" | CPPFLAGS="${save_CPPFLAGS}" | ||||
if test "${ac_cv_my_have_sdl}" != "no"; then | if test "${ac_cv_my_have_sdl}" != "no"; then | ||||
AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL_image) | AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL_image) | ||||
fi | fi | ||||
AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes") | AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes") | ||||
if test "${ac_cv_my_have_sdl}" = "no" -a "${ac_cv_my_have_imlib2}" = "no"; then | |||||
AC_MSG_ERROR([[cannot find SDL_Image or GTK+, please install one of them]]) | |||||
if test "${ac_cv_my_have_sdl}" = "no"; then | |||||
AC_MSG_ERROR([[One of SDL, SDL_Image or SDL_Mixer not found]]) | |||||
fi | fi | ||||
@@ -88,7 +89,7 @@ AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no") | |||||
# How to use the Lol Engine inside this tree | # How to use the Lol Engine inside this tree | ||||
LOL_CFLAGS="-I \$(top_srcdir)/src `pkg-config --cflags sdl gl SDL_image`" | LOL_CFLAGS="-I \$(top_srcdir)/src `pkg-config --cflags sdl gl SDL_image`" | ||||
LOL_LIBS="`pkg-config --libs sdl gl SDL_image`" | |||||
LOL_LIBS="`pkg-config --libs sdl gl SDL_image` -lSDL_mixer" | |||||
if test "${enable_release}" = "yes"; then | if test "${enable_release}" = "yes"; then | ||||
AC_DEFINE(FINAL_RELEASE, 1, Define to 1 to activate final release) | AC_DEFINE(FINAL_RELEASE, 1, Define to 1 to activate final release) | ||||
@@ -2,7 +2,7 @@ | |||||
noinst_LIBRARIES = liblol.a | noinst_LIBRARIES = liblol.a | ||||
liblol_a_SOURCES = \ | liblol_a_SOURCES = \ | ||||
core.h matrix.h tiler.cpp tiler.h dict.cpp dict.h \ | |||||
core.h matrix.h tiler.cpp tiler.h dict.cpp dict.h audio.cpp audio.h \ | |||||
scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \ | scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \ | ||||
entity.cpp entity.h ticker.cpp ticker.h tileset.cpp tileset.h \ | entity.cpp entity.h ticker.cpp ticker.h tileset.cpp tileset.h \ | ||||
forge.cpp forge.h video.cpp video.h timer.cpp timer.h bitfield.h \ | forge.cpp forge.h video.cpp video.h timer.cpp timer.h bitfield.h \ | ||||
@@ -0,0 +1,29 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <cmath> | |||||
#include <SDL_mixer.h> | |||||
#include "core.h" | |||||
/* | |||||
* Public Audio class | |||||
*/ | |||||
void Audio::Setup(int channels) | |||||
{ | |||||
Mix_OpenAudio(22050, AUDIO_S16, channels, 4096); | |||||
} | |||||
@@ -0,0 +1,29 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
// | |||||
// The Audio interface | |||||
// ------------------- | |||||
// Helper functions to set up the audio device. | |||||
// | |||||
#if !defined __DH_AUDIO_H__ | |||||
#define __DH_AUDIO_H__ | |||||
#include <stdint.h> | |||||
class Audio | |||||
{ | |||||
public: | |||||
static void Setup(int channels); | |||||
}; | |||||
#endif // __DH_AUDIO_H__ | |||||
@@ -22,6 +22,7 @@ | |||||
// Static classes | // Static classes | ||||
#include "video.h" | #include "video.h" | ||||
#include "audio.h" | |||||
#include "scene.h" | #include "scene.h" | ||||
#include "input.h" | #include "input.h" | ||||
#include "profiler.h" | #include "profiler.h" | ||||
@@ -15,7 +15,7 @@ | |||||
#include <cstdlib> | #include <cstdlib> | ||||
#include <cmath> | #include <cmath> | ||||
#include <SDL.h> | |||||
#include <SDL_mixer.h> | |||||
#include "core.h" | #include "core.h" | ||||
@@ -29,6 +29,7 @@ class SampleData | |||||
private: | private: | ||||
char *name; | char *name; | ||||
Mix_Chunk *chunk; | |||||
}; | }; | ||||
/* | /* | ||||
@@ -39,10 +40,12 @@ Sample::Sample(char const *path) | |||||
{ | { | ||||
data = new SampleData(); | data = new SampleData(); | ||||
data->name = strdup(path); | data->name = strdup(path); | ||||
data->chunk = Mix_LoadWAV(path); | |||||
} | } | ||||
Sample::~Sample() | Sample::~Sample() | ||||
{ | { | ||||
Mix_FreeChunk(data->chunk); | |||||
free(data->name); | free(data->name); | ||||
delete data; | delete data; | ||||
} | } | ||||
@@ -59,5 +62,6 @@ char const *Sample::GetName() | |||||
void Sample::Play() | void Sample::Play() | ||||
{ | { | ||||
Mix_PlayChannel(-1, data->chunk, 0); | |||||
} | } | ||||
@@ -53,7 +53,7 @@ void Sampler::Deregister(int id) | |||||
void Sampler::PlaySample(int id) | void Sampler::PlaySample(int id) | ||||
{ | { | ||||
Sample *sample = (Sample *)data->samples.GetEntity(id); | |||||
Sample *sample = (Sample *)data->samples.GetEntity(id - 1); | |||||
sample->Play(); | sample->Play(); | ||||
} | } | ||||
@@ -13,6 +13,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<ClInclude Include="..\deushax\debugsprite.h" /> | <ClInclude Include="..\deushax\debugsprite.h" /> | ||||
<ClInclude Include="..\deushax\game.h" /> | <ClInclude Include="..\deushax\game.h" /> | ||||
<ClInclude Include="..\src\audio.h" /> | |||||
<ClInclude Include="..\src\bitfield.h" /> | <ClInclude Include="..\src\bitfield.h" /> | ||||
<ClInclude Include="..\src\core.h" /> | <ClInclude Include="..\src\core.h" /> | ||||
<ClInclude Include="..\src\debugfps.h" /> | <ClInclude Include="..\src\debugfps.h" /> | ||||
@@ -43,6 +44,7 @@ | |||||
<ClCompile Include="..\deushax\debugsprite.cpp" /> | <ClCompile Include="..\deushax\debugsprite.cpp" /> | ||||
<ClCompile Include="..\deushax\deushax.cpp" /> | <ClCompile Include="..\deushax\deushax.cpp" /> | ||||
<ClCompile Include="..\deushax\game.cpp" /> | <ClCompile Include="..\deushax\game.cpp" /> | ||||
<ClCompile Include="..\src\audio.cpp" /> | |||||
<ClCompile Include="..\src\debugfps.cpp" /> | <ClCompile Include="..\src\debugfps.cpp" /> | ||||
<ClCompile Include="..\src\debugrecord.cpp" /> | <ClCompile Include="..\src\debugrecord.cpp" /> | ||||
<ClCompile Include="..\src\debugsphere.cpp" /> | <ClCompile Include="..\src\debugsphere.cpp" /> | ||||
@@ -14,6 +14,7 @@ | |||||
<ClInclude Include="..\monsterz\board.h" /> | <ClInclude Include="..\monsterz\board.h" /> | ||||
<ClInclude Include="..\monsterz\game.h" /> | <ClInclude Include="..\monsterz\game.h" /> | ||||
<ClInclude Include="..\monsterz\piece.h" /> | <ClInclude Include="..\monsterz\piece.h" /> | ||||
<ClInclude Include="..\src\audio.h" /> | |||||
<ClInclude Include="..\src\bitfield.h" /> | <ClInclude Include="..\src\bitfield.h" /> | ||||
<ClInclude Include="..\src\core.h" /> | <ClInclude Include="..\src\core.h" /> | ||||
<ClInclude Include="..\src\debugfps.h" /> | <ClInclude Include="..\src\debugfps.h" /> | ||||
@@ -45,6 +46,7 @@ | |||||
<ClCompile Include="..\monsterz\game.cpp" /> | <ClCompile Include="..\monsterz\game.cpp" /> | ||||
<ClCompile Include="..\monsterz\monsterz.cpp" /> | <ClCompile Include="..\monsterz\monsterz.cpp" /> | ||||
<ClCompile Include="..\monsterz\piece.cpp" /> | <ClCompile Include="..\monsterz\piece.cpp" /> | ||||
<ClCompile Include="..\src\audio.cpp" /> | |||||
<ClCompile Include="..\src\debugfps.cpp" /> | <ClCompile Include="..\src\debugfps.cpp" /> | ||||
<ClCompile Include="..\src\debugrecord.cpp" /> | <ClCompile Include="..\src\debugrecord.cpp" /> | ||||
<ClCompile Include="..\src\debugsphere.cpp" /> | <ClCompile Include="..\src\debugsphere.cpp" /> | ||||