Changeset 253 for trunk/src


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

Add preliminary support for sound samples. Implement click.

Location:
trunk/src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.