Changeset 253


Ignore:
Timestamp:
Jan 21, 2011, 1:05:06 AM (12 years ago)
Author:
sam
Message:

Add preliminary support for sound samples. Implement click.

Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r221 r253  
    4949
    5050# Use SDL?
    51 ac_cv_my_have_sdl="no"
     51ac_cv_my_have_sdl="yes"
    5252save_CPPFLAGS="${CPPFLAGS}"
    5353AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
     
    5656fi
    5757AC_CHECK_HEADERS(SDL_image.h,
    58  [ac_cv_my_have_sdl="yes"],
    59  [ac_cv_my_have_sdl="no"])
     58 [:],[ac_cv_my_have_sdl="no"])
     59AC_CHECK_HEADERS(SDL_mixer.h,
     60 [:],[ac_cv_my_have_sdl="no"])
    6061CPPFLAGS="${save_CPPFLAGS}"
    6162if test "${ac_cv_my_have_sdl}" != "no"; then
     
    6465AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
    6566
    66 if test "${ac_cv_my_have_sdl}" = "no" -a "${ac_cv_my_have_imlib2}" = "no"; then
    67   AC_MSG_ERROR([[cannot find SDL_Image or GTK+, please install one of them]])
     67if test "${ac_cv_my_have_sdl}" = "no"; then
     68  AC_MSG_ERROR([[One of SDL, SDL_Image or SDL_Mixer not found]])
    6869fi
    6970
     
    8990# How to use the Lol Engine inside this tree
    9091LOL_CFLAGS="-I \$(top_srcdir)/src `pkg-config --cflags sdl gl SDL_image`"
    91 LOL_LIBS="`pkg-config --libs sdl gl SDL_image`"
     92LOL_LIBS="`pkg-config --libs sdl gl SDL_image` -lSDL_mixer"
    9293
    9394if test "${enable_release}" = "yes"; then
  • trunk/monsterz/board.cpp

    r248 r253  
    3333    Game *game;
    3434    int screen, board, tiles;
     35    int click;
    3536    Piece *pieces[8][8];
    3637    Piece *grabbed;
     
    6263    data->board = Tiler::Register(PNG_BOARD, 384, 384, 1.0f);
    6364    data->tiles = Tiler::Register(PNG_TILES, 48, 48, 1.0f);
     65    data->click = Sampler::Register(WAV_CLICK);
    6466
    6567    for (int j = 0; j < 8; j++)
     
    101103                if (data->pieces[x / 48][y / 48]->Grab(Int2(0, 0)))
    102104                {
     105                    Sampler::PlaySample(data->click);
    103106                    data->grabbed = data->pieces[x / 48][y / 48];
    104107                    data->src_cell = Int2(x / 48, y / 48);
     
    189192    Tiler::Deregister(data->screen);
    190193    Tiler::Deregister(data->tiles);
     194    Sampler::Deregister(data->click);
    191195    delete data;
    192196}
  • trunk/monsterz/monsterz.cpp

    r234 r253  
    3333{
    3434    /* Initialise SDL */
    35     if (SDL_Init(SDL_INIT_VIDEO) < 0)
     35    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
    3636    {
    3737        fprintf(stderr, "Cannot initialise SDL: %s\n", SDL_GetError());
     
    5454    /* Initialise OpenGL */
    5555    Video::Setup(video->w, video->h);
     56    Audio::Setup(2);
    5657
    5758    /* Create a game */
  • trunk/monsterz/monsterz.h

    r226 r253  
    1313static char const * const PNG_TILES = "monsterz/tiles.png";
    1414
     15static char const * const WAV_CLICK = "monsterz/click.wav";
     16
  • trunk/src/Makefile.am

    r251 r253  
    33
    44liblol_a_SOURCES = \
    5     core.h matrix.h tiler.cpp tiler.h dict.cpp dict.h \
     5    core.h matrix.h tiler.cpp tiler.h dict.cpp dict.h audio.cpp audio.h \
    66    scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \
    77    entity.cpp entity.h ticker.cpp ticker.h tileset.cpp tileset.h \
  • trunk/src/core.h

    r251 r253  
    2323// Static classes
    2424#include "video.h"
     25#include "audio.h"
    2526#include "scene.h"
    2627#include "input.h"
  • trunk/src/sample.cpp

    r251 r253  
    1616#include <cmath>
    1717
    18 #include <SDL.h>
     18#include <SDL_mixer.h>
    1919
    2020#include "core.h"
     
    3030private:
    3131    char *name;
     32    Mix_Chunk *chunk;
    3233};
    3334
     
    4041    data = new SampleData();
    4142    data->name = strdup(path);
     43    data->chunk = Mix_LoadWAV(path);
    4244}
    4345
    4446Sample::~Sample()
    4547{
     48    Mix_FreeChunk(data->chunk);
    4649    free(data->name);
    4750    delete data;
     
    6063void Sample::Play()
    6164{
     65    Mix_PlayChannel(-1, data->chunk, 0);
    6266}
    6367
  • trunk/src/sampler.cpp

    r251 r253  
    5454void Sampler::PlaySample(int id)
    5555{
    56     Sample *sample = (Sample *)data->samples.GetEntity(id);
     56    Sample *sample = (Sample *)data->samples.GetEntity(id - 1);
    5757    sample->Play();
    5858}
  • trunk/win32/deushax.vcxproj

    r251 r253  
    1414    <ClInclude Include="..\deushax\debugsprite.h" />
    1515    <ClInclude Include="..\deushax\game.h" />
     16    <ClInclude Include="..\src\audio.h" />
    1617    <ClInclude Include="..\src\bitfield.h" />
    1718    <ClInclude Include="..\src\core.h" />
     
    4445    <ClCompile Include="..\deushax\deushax.cpp" />
    4546    <ClCompile Include="..\deushax\game.cpp" />
     47    <ClCompile Include="..\src\audio.cpp" />
    4648    <ClCompile Include="..\src\debugfps.cpp" />
    4749    <ClCompile Include="..\src\debugrecord.cpp" />
  • trunk/win32/monsterz.vcxproj

    r251 r253  
    1515    <ClInclude Include="..\monsterz\game.h" />
    1616    <ClInclude Include="..\monsterz\piece.h" />
     17    <ClInclude Include="..\src\audio.h" />
    1718    <ClInclude Include="..\src\bitfield.h" />
    1819    <ClInclude Include="..\src\core.h" />
     
    4647    <ClCompile Include="..\monsterz\monsterz.cpp" />
    4748    <ClCompile Include="..\monsterz\piece.cpp" />
     49    <ClCompile Include="..\src\audio.cpp" />
    4850    <ClCompile Include="..\src\debugfps.cpp" />
    4951    <ClCompile Include="..\src\debugrecord.cpp" />
Note: See TracChangeset for help on using the changeset viewer.