1) Applied Stehen's patch to give each kart separate sound effects objects,
and add engine sounds. 2) Added sfx manager so that the buffers for the sfx are shared between all sfx objects. 3) Moved all audio related files into audio subdirectory. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2275 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
5343635562
commit
c0eae662f2
@ -59,7 +59,7 @@
|
||||
;; allows for tighter turns at lower speeds
|
||||
(min-speed-angle 0 19)
|
||||
(max-speed-angle 12 6.4)
|
||||
(engine-power 400 )
|
||||
(engine-power 400 )
|
||||
(mass 225 )
|
||||
(suspension-stiffness 48.0 )
|
||||
(wheel-damping-relaxation 2.3 )
|
||||
@ -76,7 +76,7 @@
|
||||
(front-wheel-connection 0.38 0.6 0)
|
||||
(rear-wheel-connection 0.38 -0.6 0)
|
||||
(suspension-rest 0.2 )
|
||||
(suspension-travel-cm 500 )
|
||||
(suspension-travel-cm 500 )
|
||||
|
||||
;; The z-axis velocity set when a jump is initiated. This will cause the
|
||||
;; kart to start rising, till it is pulled back by gravity. A higher value
|
||||
@ -89,8 +89,9 @@
|
||||
;; 0.5 means: if speed <=0.5 *maxSpeed --> gear 2
|
||||
;; The next vector contains the increase in max power (to simulate different
|
||||
;; gears), e.g. 2.5 as first entry means: 2.5*maxPower in gear 1
|
||||
(gear-switch-ratio 0.25 0.5 0.75)
|
||||
(gear-power-increase 2.5 1.8 1.4 )
|
||||
;; | first | second | third |
|
||||
(gear-switch-ratio 0.25 0.7 1.0)
|
||||
(gear-power-increase 2.2 1.7 1.3)
|
||||
(upright-tolerance 0.2)
|
||||
(upright-max-force 30)
|
||||
(camera-max-accel 10)
|
||||
|
@ -43,6 +43,13 @@ supertuxkart_SOURCES = main.cpp \
|
||||
network/kart_control_message.hpp network/kart_control_message.cpp \
|
||||
network/flyable_info.hpp network/herring_info.hpp \
|
||||
network/race_state.hpp network/race_state.cpp \
|
||||
audio/music.hpp \
|
||||
audio/music_information.cpp audio/music_information.hpp \
|
||||
audio/music_ogg.cpp audio/music_ogg.hpp \
|
||||
audio/sfx_base.hpp \
|
||||
audio/sfx_manager.cpp audio/sfx_manager.hpp \
|
||||
audio/sfx_openal.cpp audio/sfx_openal.hpp \
|
||||
audio/sound_manager.cpp audio/sound_manager.hpp \
|
||||
utils/random_generator.hpp utils/random_generator.cpp \
|
||||
material_manager.cpp material_manager.hpp \
|
||||
grand_prix_manager.cpp grand_prix_manager.hpp \
|
||||
@ -50,10 +57,6 @@ supertuxkart_SOURCES = main.cpp \
|
||||
attachment_manager.cpp attachment_manager.hpp \
|
||||
collectable.cpp collectable.hpp \
|
||||
collectable_manager.cpp collectable_manager.hpp \
|
||||
sound_manager.cpp sound_manager.hpp \
|
||||
music_ogg.cpp music_ogg.hpp \
|
||||
music_information.cpp music_information.hpp \
|
||||
sfx_openal.cpp sfx_openal.hpp \
|
||||
smoke.cpp smoke.hpp \
|
||||
input.hpp kart_control.hpp \
|
||||
isect.cpp isect.hpp \
|
||||
@ -76,8 +79,7 @@ supertuxkart_SOURCES = main.cpp \
|
||||
string_utils.cpp string_utils.hpp \
|
||||
track_manager.cpp track_manager.hpp \
|
||||
world.cpp world.hpp \
|
||||
callback.hpp music.hpp \
|
||||
sfx.hpp \
|
||||
callback.hpp \
|
||||
moving_physics.hpp moving_physics.cpp \
|
||||
moving_texture.hpp moving_texture.cpp \
|
||||
callback_manager.cpp callback_manager.hpp \
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "kart.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "world.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "stk_config.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "network/race_state.hpp"
|
||||
|
@ -17,8 +17,8 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_MUSIC_H
|
||||
#define HEADER_MUSIC_H
|
||||
#ifndef HEADER_MUSIC_HPP
|
||||
#define HEADER_MUSIC_HPP
|
||||
|
||||
#include <string>
|
||||
|
@ -17,18 +17,18 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "audio/music_information.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "music_information.hpp"
|
||||
#include "audio/music_ogg.hpp"
|
||||
#include "lisp/lisp.hpp"
|
||||
#include "lisp/parser.hpp"
|
||||
#include "string_utils.hpp"
|
||||
#include "track_manager.hpp"
|
||||
#include "track.hpp"
|
||||
#include "translation.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "music_ogg.hpp"
|
||||
#include "track.hpp"
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define snprintf _snprintf
|
@ -17,12 +17,13 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_MUSIC_INFORMATION
|
||||
#define HEADER_MUSIC_INFORMATION
|
||||
#ifndef HEADER_MUSIC_INFORMATION_HPP
|
||||
#define HEADER_MUSIC_INFORMATION_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "music.hpp"
|
||||
|
||||
class Music;
|
||||
|
||||
class MusicInformation
|
||||
{
|
@ -19,35 +19,34 @@
|
||||
|
||||
#if HAVE_OGGVORBIS
|
||||
|
||||
#include "audio/music_ogg.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#ifdef __APPLE__
|
||||
# include <OpenAL/al.h>
|
||||
#else
|
||||
# include <AL/al.h>
|
||||
#endif
|
||||
|
||||
// This include is important, otherwise SDL_BYTEORDER is undefined, and as a
|
||||
// result big endian will be used!
|
||||
#include <SDL/SDL_endian.h>
|
||||
#include "music_ogg.hpp"
|
||||
#include "file_manager.hpp"
|
||||
|
||||
#include "user_config.hpp"
|
||||
|
||||
#define BUFFER_SIZE (4096 * 8)
|
||||
|
||||
|
||||
MusicOggStream::MusicOggStream()
|
||||
{
|
||||
//m_oggStream= NULL;
|
||||
m_soundBuffers[0]= m_soundBuffers[1]= 0;
|
||||
m_soundSource= 0;
|
||||
m_pausedMusic= true;
|
||||
}
|
||||
} // MusicOggStream
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
MusicOggStream::~MusicOggStream()
|
||||
{
|
||||
if(stopMusic() == false)
|
||||
fprintf(stderr, "WARNING: problems while stopping music.\n");
|
||||
}
|
||||
fprintf(stderr, "WARNING: problems while stopping music.\n");
|
||||
} // ~MusicOggStream
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::load(const std::string& filename)
|
||||
@ -106,7 +105,7 @@ bool MusicOggStream::load(const std::string& filename)
|
||||
|
||||
m_error=false;
|
||||
return true;
|
||||
}
|
||||
} // load
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::empty()
|
||||
@ -124,7 +123,7 @@ bool MusicOggStream::empty()
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // empty
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::release()
|
||||
@ -148,7 +147,7 @@ bool MusicOggStream::release()
|
||||
if(!m_error) ov_clear(&m_oggStream);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // release
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::playMusic()
|
||||
@ -168,7 +167,7 @@ bool MusicOggStream::playMusic()
|
||||
m_pausedMusic= false;
|
||||
|
||||
return true;
|
||||
}
|
||||
} // playMusic
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::isPlaying()
|
||||
@ -177,13 +176,13 @@ bool MusicOggStream::isPlaying()
|
||||
alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state);
|
||||
|
||||
return (state == AL_PLAYING);
|
||||
}
|
||||
} // isPlaying
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::stopMusic()
|
||||
{
|
||||
return (release());
|
||||
}
|
||||
} // stopMusic
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::pauseMusic()
|
||||
@ -197,7 +196,7 @@ bool MusicOggStream::pauseMusic()
|
||||
alSourceStop(m_soundSource);
|
||||
m_pausedMusic= true;
|
||||
return true;
|
||||
}
|
||||
} // pauseMusic
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::resumeMusic()
|
||||
@ -211,7 +210,7 @@ bool MusicOggStream::resumeMusic()
|
||||
alSourcePlay(m_soundSource);
|
||||
m_pausedMusic= false;
|
||||
return true;
|
||||
}
|
||||
} // resumeMusic
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void MusicOggStream::updateFading(float percent)
|
||||
@ -247,14 +246,12 @@ void MusicOggStream::update()
|
||||
ALuint buffer;
|
||||
|
||||
alSourceUnqueueBuffers(m_soundSource, 1, &buffer);
|
||||
if(check() == false)
|
||||
return;
|
||||
if(!check()) return;
|
||||
|
||||
active = streamIntoBuffer(buffer);
|
||||
alSourceQueueBuffers(m_soundSource, 1, &buffer);
|
||||
|
||||
if(check() == false)
|
||||
return;
|
||||
if(!check()) return;
|
||||
}
|
||||
|
||||
// check for underrun
|
||||
@ -275,13 +272,13 @@ void MusicOggStream::update()
|
||||
// no more data. Seek to beginning -> loop
|
||||
ov_time_seek(&m_oggStream, 0);
|
||||
}
|
||||
}
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::streamIntoBuffer(ALuint buffer)
|
||||
{
|
||||
char pcm[BUFFER_SIZE];
|
||||
#if defined(WORDS_BIGENDIAN) || SDL_BYTEORDER==SDL_BIG_ENDIAN
|
||||
char pcm[m_buffer_size];
|
||||
#if defined(WORDS_BIGENDIAN) || SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
int isBigEndian = 1;
|
||||
#else
|
||||
int isBigEndian = 0;
|
||||
@ -290,9 +287,10 @@ bool MusicOggStream::streamIntoBuffer(ALuint buffer)
|
||||
int portion;
|
||||
int result;
|
||||
|
||||
while(size < BUFFER_SIZE)
|
||||
while(size < m_buffer_size)
|
||||
{
|
||||
result = ov_read(&m_oggStream, pcm + size, BUFFER_SIZE - size, isBigEndian, 2, 1, &portion);
|
||||
result = ov_read(&m_oggStream, pcm + size, m_buffer_size - size,
|
||||
isBigEndian, 2, 1, &portion);
|
||||
|
||||
if(result > 0)
|
||||
size += result;
|
||||
@ -303,15 +301,13 @@ bool MusicOggStream::streamIntoBuffer(ALuint buffer)
|
||||
break;
|
||||
}
|
||||
|
||||
if(size == 0)
|
||||
return false;
|
||||
|
||||
if(size == 0) return false;
|
||||
|
||||
alBufferData(buffer, nb_channels, pcm, size, m_vorbisInfo->rate);
|
||||
check();
|
||||
|
||||
return true;
|
||||
}
|
||||
} // streamIntoBuffer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MusicOggStream::check()
|
||||
@ -325,26 +321,26 @@ bool MusicOggStream::check()
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // check
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
string MusicOggStream::errorString(int code)
|
||||
std::string MusicOggStream::errorString(int code)
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
case OV_EREAD:
|
||||
return string("Read error from media.");
|
||||
return std::string("Read error from media.");
|
||||
case OV_ENOTVORBIS:
|
||||
return string("It is not Vorbis data.");
|
||||
return std::string("It is not Vorbis data.");
|
||||
case OV_EVERSION:
|
||||
return string("Vorbis version mismatch.");
|
||||
return std::string("Vorbis version mismatch.");
|
||||
case OV_EBADHEADER:
|
||||
return string("Invalid Vorbis bitstream header.");
|
||||
return std::string("Invalid Vorbis bitstream header.");
|
||||
case OV_EFAULT:
|
||||
return string("Internal logic fault (bug or heap/stack corruption).");
|
||||
return std::string("Internal logic fault (bug or heap/stack corruption).");
|
||||
default:
|
||||
return string("Unknown Vorbis error.");
|
||||
return std::string("Unknown Vorbis error.");
|
||||
}
|
||||
}
|
||||
} // errorString
|
||||
|
||||
#endif // HAVE_OGGVORBIS
|
@ -22,16 +22,18 @@
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#include <ogg/ogg.h>
|
||||
#include <vorbis/vorbisfile.h>
|
||||
// Disable warning about potential loss of precision in vorbisfile.h
|
||||
#pragma warning(disable:4244)
|
||||
# include <vorbis/vorbisfile.h>
|
||||
#pragma warning(default:4244)
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <OpenAL/al.h>
|
||||
#else
|
||||
# include <AL/al.h>
|
||||
#endif
|
||||
#include "music.hpp"
|
||||
#include "audio/music.hpp"
|
||||
|
||||
class MusicOggStream : public Music
|
||||
{
|
||||
@ -54,14 +56,14 @@ public:
|
||||
protected:
|
||||
bool empty();
|
||||
bool check();
|
||||
string errorString(int code);
|
||||
std::string errorString(int code);
|
||||
|
||||
private:
|
||||
bool release();
|
||||
bool isPlaying();
|
||||
bool streamIntoBuffer(ALuint buffer);
|
||||
|
||||
string m_fileName;
|
||||
std::string m_fileName;
|
||||
FILE* m_oggFile;
|
||||
OggVorbis_File m_oggStream;
|
||||
vorbis_info* m_vorbisInfo;
|
||||
@ -72,6 +74,7 @@ private:
|
||||
ALenum nb_channels;
|
||||
|
||||
bool m_pausedMusic;
|
||||
static const int m_buffer_size = 4096*8;
|
||||
};
|
||||
|
||||
#endif // HEADER_MUSICOGG_H
|
@ -17,16 +17,23 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_SFX_H
|
||||
#define HEADER_SFX_H
|
||||
#ifndef HEADER_SFX_HPP
|
||||
#define HEADER_SFX_HPP
|
||||
|
||||
class SFX
|
||||
class Vec3;
|
||||
|
||||
class SFXBase
|
||||
{
|
||||
public:
|
||||
virtual void play()= 0;
|
||||
|
||||
virtual ~SFX() {}
|
||||
};
|
||||
virtual void play() = 0;
|
||||
virtual void loop() = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual void speed(float factor) = 0;
|
||||
void position(const Vec3 &position) {};
|
||||
virtual int getStatus() = 0;
|
||||
}; // SfxBase
|
||||
|
||||
#endif // HEADER_SFX_H
|
||||
|
||||
#endif // HEADER_SFX_HPP
|
||||
|
145
src/audio/sfx_openal.cpp
Normal file
145
src/audio/sfx_openal.cpp
Normal file
@ -0,0 +1,145 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2006 Patrick Ammann <pammann@aro.ch>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#if HAVE_OGGVORBIS
|
||||
|
||||
#include "audio/sfx_openal.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <OpenAL/al.h>
|
||||
#else
|
||||
# include <AL/al.h>
|
||||
#endif
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_endian.h>
|
||||
|
||||
#include "file_manager.hpp"
|
||||
#include "user_config.hpp"
|
||||
|
||||
SFXOpenAL::SFXOpenAL(ALuint buffer)
|
||||
{
|
||||
m_soundBuffer = buffer;
|
||||
m_soundSource = 0;
|
||||
m_loaded = 0;
|
||||
|
||||
alGenSources(1, &m_soundSource );
|
||||
if(!SFXManager::checkError("generating a source")) return;
|
||||
|
||||
// not 3D yet
|
||||
alSourcei (m_soundSource, AL_BUFFER, m_soundBuffer);
|
||||
alSource3f(m_soundSource, AL_POSITION, 0.0, 0.0, 5.0);
|
||||
alSource3f(m_soundSource, AL_VELOCITY, 0.0, 0.0, 0.0);
|
||||
alSource3f(m_soundSource, AL_DIRECTION, 0.0, 0.0, 0.0);
|
||||
alSourcef (m_soundSource, AL_ROLLOFF_FACTOR, 0.2f );
|
||||
alSourcei (m_soundSource, AL_SOURCE_RELATIVE, AL_TRUE );
|
||||
|
||||
m_loaded = SFXManager::checkError("setting up the source");
|
||||
} // SFXOpenAL
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
SFXOpenAL::~SFXOpenAL()
|
||||
{
|
||||
alDeleteBuffers(1, &m_soundBuffer);
|
||||
alDeleteSources(1, &m_soundSource);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFXOpenAL::speed(float factor)
|
||||
{
|
||||
if(!m_loaded)
|
||||
return;
|
||||
|
||||
//OpenAL only accepts pitches in the range of 0.5 to 2.0
|
||||
if(factor > 2.0f)
|
||||
{
|
||||
factor = 2.0f;
|
||||
}
|
||||
if(factor < 0.5f)
|
||||
{
|
||||
factor = 0.5f;
|
||||
}
|
||||
alSourcef(m_soundSource,AL_PITCH,factor);
|
||||
SFXManager::checkError("changing the speed");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFXOpenAL::loop()
|
||||
{
|
||||
if(!m_loaded)
|
||||
return;
|
||||
|
||||
alSourcei(m_soundSource, AL_LOOPING, AL_TRUE);
|
||||
SFXManager::checkError("looping");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFXOpenAL::stop()
|
||||
{
|
||||
if(!m_loaded)
|
||||
return;
|
||||
|
||||
alSourcei(m_soundSource, AL_LOOPING, AL_FALSE);
|
||||
alSourceStop(m_soundSource);
|
||||
SFXManager::checkError("stoping");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFXOpenAL::play()
|
||||
{
|
||||
if(!m_loaded)
|
||||
return;
|
||||
|
||||
alSourcef(m_soundSource,AL_GAIN,user_config->m_sfx_volume);
|
||||
alSourcePlay(m_soundSource);
|
||||
SFXManager::checkError("playing");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFXOpenAL::position(Vec3 position)
|
||||
{
|
||||
if(!m_loaded)
|
||||
return;
|
||||
|
||||
alSource3f(m_soundSource, AL_POSITION, position.getX(), position.getY(), position.getZ());
|
||||
SFXManager::checkError("positioning");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int SFXOpenAL::getStatus()
|
||||
{
|
||||
if(!m_loaded)
|
||||
return SFXManager::SFX_UNKNOWN;
|
||||
|
||||
int state = 0;
|
||||
alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state);
|
||||
switch(state)
|
||||
{
|
||||
case AL_STOPPED: return SFXManager::SFX_STOPED;
|
||||
case AL_PLAYING: return SFXManager::SFX_PLAYING;
|
||||
case AL_PAUSED: return SFXManager::SFX_PAUSED;
|
||||
default: return SFXManager::SFX_UNKNOWN;
|
||||
}
|
||||
} // getStatus
|
||||
|
||||
#endif //if HAVE_OGGVORBIS
|
@ -17,8 +17,8 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_SFX_OPENAL_H
|
||||
#define HEADER_SFX_OPENAL_H
|
||||
#ifndef HEADER_SFX_OPENAL_HPP
|
||||
#define HEADER_SFX_OPENAL_HPP
|
||||
|
||||
#include <assert.h>
|
||||
#ifdef __APPLE__
|
||||
@ -26,24 +26,27 @@
|
||||
#else
|
||||
# include <AL/al.h>
|
||||
#endif
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
|
||||
#include "sfx.hpp"
|
||||
|
||||
|
||||
class SFXImpl : public SFX
|
||||
class SFXOpenAL : public SFXBase
|
||||
{
|
||||
public:
|
||||
SFXImpl(const char* filename);
|
||||
virtual ~SFXImpl();
|
||||
|
||||
virtual void play();
|
||||
|
||||
private:
|
||||
bool load(const char* filename);
|
||||
unsigned int m_loaded;
|
||||
ALuint m_soundBuffer; // Buffers hold sound data.
|
||||
ALuint m_soundSource; // Sources are points emitting sound.
|
||||
|
||||
ALuint m_soundBuffer; // Buffers hold sound data.
|
||||
ALuint m_soundSource; // Sources are points emitting sound.
|
||||
};
|
||||
public:
|
||||
SFXOpenAL(ALuint buffer);
|
||||
~SFXOpenAL();
|
||||
virtual void play();
|
||||
virtual void loop();
|
||||
virtual void stop();
|
||||
virtual void speed(float factor);
|
||||
virtual void position(Vec3 position);
|
||||
virtual int getStatus();
|
||||
|
||||
#endif // HEADER_SFX_OPENAL_H
|
||||
}; // SFXOpenAL
|
||||
|
||||
#endif // HEADER_SFX_OPENAL_HPP
|
||||
|
@ -18,14 +18,14 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "audio/sound_manager.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "sound_manager.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "string_utils.hpp"
|
||||
#include "gui/font.hpp"
|
||||
#include "file_manager.hpp"
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define strcasecmp _strcmpi
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <OpenAL/al.h>
|
||||
@ -35,16 +35,16 @@
|
||||
# include <AL/alc.h>
|
||||
#endif
|
||||
|
||||
#include "music_ogg.hpp"
|
||||
#include "sfx_openal.hpp"
|
||||
|
||||
#include "user_config.hpp"
|
||||
#include "string_utils.hpp"
|
||||
#include "file_manager.hpp"
|
||||
#include "translation.hpp"
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define strcasecmp _strcmpi
|
||||
#endif
|
||||
#include "audio/music_ogg.hpp"
|
||||
#include "audio/sfx_openal.hpp"
|
||||
|
||||
SoundManager* sound_manager= NULL;
|
||||
|
||||
SoundManager::SoundManager() : m_sfxs(NUM_SOUNDS)
|
||||
SoundManager::SoundManager()
|
||||
{
|
||||
m_current_music= NULL;
|
||||
|
||||
@ -73,42 +73,12 @@ SoundManager::SoundManager() : m_sfxs(NUM_SOUNDS)
|
||||
|
||||
alGetError(); //Called here to clear any non-important errors found
|
||||
|
||||
if (m_initialized)
|
||||
{
|
||||
// must be in sync with enumSoundSFX
|
||||
m_sfxs[SOUND_UGH ] = new SFXImpl("ugh.wav");
|
||||
m_sfxs[SOUND_WINNER ] = new SFXImpl("radio/grandprix_winner.wav");
|
||||
m_sfxs[SOUND_GRAB ] = new SFXImpl("tintagel/grab_collectable.wav");
|
||||
m_sfxs[SOUND_CRASH ] = new SFXImpl("tintagel/crash.wav");
|
||||
m_sfxs[SOUND_SHOT ] = new SFXImpl("radio/shot.wav");
|
||||
m_sfxs[SOUND_EXPLOSION ] = new SFXImpl("explosion.wav");
|
||||
m_sfxs[SOUND_BZZT ] = new SFXImpl("bzzt.wav");
|
||||
m_sfxs[SOUND_BEEP ] = new SFXImpl("radio/horn.wav");
|
||||
m_sfxs[SOUND_USE_ANVIL ] = new SFXImpl("radio/slap.wav");
|
||||
m_sfxs[SOUND_USE_PARACHUTE] = new SFXImpl("radio/squeaky.wav");
|
||||
m_sfxs[SOUND_WEE ] = new SFXImpl("wee.wav");
|
||||
m_sfxs[SOUND_BACK_MENU ] = new SFXImpl("tintagel/deselect_option.wav");
|
||||
m_sfxs[SOUND_SELECT_MENU ] = new SFXImpl("tintagel/select_option.wav");
|
||||
m_sfxs[SOUND_MOVE_MENU ] = new SFXImpl("tintagel/move_option.wav");
|
||||
m_sfxs[SOUND_FULL ] = new SFXImpl("tintagel/energy_bar_full.wav");
|
||||
m_sfxs[SOUND_PRESTART ] = new SFXImpl("tintagel/pre_start_race.wav");
|
||||
m_sfxs[SOUND_START ] = new SFXImpl("tintagel/start_race.wav");
|
||||
m_sfxs[SOUND_MISSILE_LOCK ] = new SFXImpl("radio/radarping.wav");
|
||||
}
|
||||
|
||||
loadMusicInformation();
|
||||
} // SoundManager
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
SoundManager::~SoundManager()
|
||||
{
|
||||
// SFX cleanup
|
||||
for(SFXsType::iterator it= m_sfxs.begin(); it != m_sfxs.end(); it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
m_sfxs.empty();
|
||||
|
||||
if(m_initialized)
|
||||
{
|
||||
ALCcontext* context = alcGetCurrentContext();
|
||||
@ -162,32 +132,6 @@ void SoundManager::addMusicToTracks()
|
||||
}
|
||||
} // addMusicToTracks
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
MusicInformation* SoundManager::getMusicInformation(const std::string& filename)
|
||||
{
|
||||
if(filename=="")
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
const std::string basename = StringUtils::basename(filename);
|
||||
MusicInformation* mi = m_allMusic[basename];
|
||||
if(!mi)
|
||||
{
|
||||
mi = new MusicInformation(filename);
|
||||
m_allMusic[basename] = mi;
|
||||
}
|
||||
return mi;
|
||||
} // SoundManager
|
||||
//-----------------------------------------------------------------------------
|
||||
void SoundManager::playSfx(unsigned int id)
|
||||
{
|
||||
if(!user_config->doSFX() || !m_initialized) return;
|
||||
|
||||
assert(id>=0 && id<m_sfxs.size() && m_sfxs[id]);
|
||||
m_sfxs[id]->play();
|
||||
|
||||
} // playSfx
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SoundManager::startMusic(MusicInformation* mi)
|
||||
{
|
||||
@ -205,3 +149,32 @@ void SoundManager::stopMusic()
|
||||
} // stopMusic
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
MusicInformation* SoundManager::getMusicInformation(const std::string& filename)
|
||||
{
|
||||
if(filename=="")
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
const std::string basename = StringUtils::basename(filename);
|
||||
MusicInformation* mi = m_allMusic[basename];
|
||||
if(!mi)
|
||||
{
|
||||
mi = new MusicInformation(filename);
|
||||
m_allMusic[basename] = mi;
|
||||
}
|
||||
return mi;
|
||||
} // SoundManager
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void SoundManager::positionListener(Vec3 position)
|
||||
{
|
||||
if(!user_config->doSFX() || !m_initialized) return;
|
||||
|
||||
alListener3f(AL_POSITION, position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool SoundManager::sfxAllowed()
|
||||
{
|
||||
return user_config->doSFX() && m_initialized;
|
||||
} // sfxAllowed
|
@ -25,39 +25,31 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "music.hpp"
|
||||
#include "music_information.hpp"
|
||||
#include "sfx.hpp"
|
||||
|
||||
enum enumSFX {SOUND_UGH, SOUND_WINNER, SOUND_CRASH, SOUND_GRAB,
|
||||
SOUND_SHOT, SOUND_WEE, SOUND_EXPLOSION,
|
||||
SOUND_BZZT, SOUND_BEEP,
|
||||
SOUND_BACK_MENU, SOUND_USE_ANVIL, SOUND_USE_PARACHUTE,
|
||||
SOUND_SELECT_MENU, SOUND_MOVE_MENU, SOUND_FULL,
|
||||
SOUND_PRESTART, SOUND_START, SOUND_MISSILE_LOCK,
|
||||
NUM_SOUNDS};
|
||||
#include "lisp/lisp.hpp"
|
||||
#include "audio/music.hpp"
|
||||
#include "audio/music_information.hpp"
|
||||
#include "vec3.hpp"
|
||||
|
||||
class SoundManager
|
||||
{
|
||||
private:
|
||||
MusicInformation *m_current_music;
|
||||
|
||||
typedef std::vector<SFX*> SFXsType;
|
||||
|
||||
SFXsType m_sfxs;
|
||||
MusicInformation *m_current_music;
|
||||
|
||||
bool m_initialized; //If the sound could not be initialized, e.g.
|
||||
//if the player doesn't has a sound card, we want
|
||||
//to avoid anything sound related so we crash the game.
|
||||
std::map<std::string, MusicInformation*>
|
||||
m_allMusic;
|
||||
void loadMusicInformation();
|
||||
/** If the sound could not be initialized, e.g. if the player doesn't has
|
||||
* a sound card, we want to avoid anything sound related so we crash the
|
||||
* game. */
|
||||
bool m_initialized;
|
||||
std::map<std::string, MusicInformation*>
|
||||
m_allMusic;
|
||||
|
||||
void loadMusicInformation();
|
||||
public:
|
||||
SoundManager();
|
||||
virtual ~SoundManager();
|
||||
|
||||
void playSfx(unsigned int id);
|
||||
void positionListener(Vec3 position);
|
||||
bool sfxAllowed();
|
||||
|
||||
void startMusic(MusicInformation* mi);
|
||||
void stopMusic();
|
||||
void update(float dt) {if(m_current_music)
|
@ -199,6 +199,7 @@ void Camera::update (float dt)
|
||||
m_xyz = c.getXYZ();
|
||||
m_hpr = c.getHPR();
|
||||
m_context -> setCamera(&c.toSgCoord());
|
||||
//sound_manager->positionListener(kart->getXYZ());
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -17,24 +17,40 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "collectable.hpp"
|
||||
|
||||
#include "network/network_manager.hpp"
|
||||
#include "network/race_state.hpp"
|
||||
#include "collectable.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "race_manager.hpp"
|
||||
#include "projectile_manager.hpp"
|
||||
#include "kart.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "world.hpp"
|
||||
#include "stk_config.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Collectable::Collectable(Kart* kart_)
|
||||
{
|
||||
m_owner = kart_;
|
||||
m_owner = kart_;
|
||||
m_sound_shot = sfx_manager->getSfx(SFXManager::SOUND_SHOT);
|
||||
m_sound_use_anvil = sfx_manager->getSfx(SFXManager::SOUND_USE_ANVIL);
|
||||
m_sound_use_parachute = sfx_manager->getSfx(SFXManager::SOUND_USE_PARACHUTE);
|
||||
reset();
|
||||
} // Collectable
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Frees the memory for the sound effects.
|
||||
*/
|
||||
Collectable::~Collectable()
|
||||
{
|
||||
delete m_sound_shot;
|
||||
delete m_sound_use_anvil;
|
||||
delete m_sound_use_parachute;
|
||||
|
||||
} // ~Collectable
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Collectable::reset()
|
||||
{
|
||||
@ -82,7 +98,9 @@ void Collectable::use()
|
||||
case COLLECT_BOWLING:
|
||||
case COLLECT_MISSILE:
|
||||
if(m_owner->isPlayerKart())
|
||||
sound_manager->playSfx(SOUND_SHOT);
|
||||
{
|
||||
m_sound_shot->play();
|
||||
}
|
||||
projectile_manager->newProjectile(m_owner, m_type);
|
||||
break ;
|
||||
|
||||
@ -100,7 +118,9 @@ void Collectable::use()
|
||||
kart->adjustSpeedWeight(stk_config->m_anvil_speed_factor*0.5f);
|
||||
|
||||
if(kart->isPlayerKart())
|
||||
sound_manager->playSfx(SOUND_USE_ANVIL);
|
||||
{
|
||||
m_sound_use_anvil->play();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -128,7 +148,9 @@ void Collectable::use()
|
||||
}
|
||||
|
||||
if(player_affected)
|
||||
sound_manager->playSfx(SOUND_USE_PARACHUTE);
|
||||
{
|
||||
m_sound_use_parachute->play();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -22,16 +22,21 @@
|
||||
|
||||
#define MAX_COLLECTABLES 5
|
||||
|
||||
#include "collectable_manager.hpp"
|
||||
#include "collectable_manager.hpp" // needed for collectable_type
|
||||
#include "utils/random_generator.hpp"
|
||||
|
||||
class Kart;
|
||||
class Herring;
|
||||
class SFXBase;
|
||||
|
||||
class Collectable
|
||||
{
|
||||
private:
|
||||
RandomGenerator m_random;
|
||||
SFXBase *m_sound_shot;
|
||||
SFXBase *m_sound_use_anvil;
|
||||
SFXBase *m_sound_use_parachute;
|
||||
|
||||
protected:
|
||||
Kart* m_owner;
|
||||
CollectableType m_type;
|
||||
@ -39,6 +44,7 @@ protected:
|
||||
|
||||
public:
|
||||
Collectable (Kart* kart_);
|
||||
~Collectable ();
|
||||
void set (CollectableType _type, int n=1);
|
||||
void reset ();
|
||||
int getNum () const {return m_number;}
|
||||
|
@ -20,9 +20,9 @@
|
||||
#include <plib/ssg.h>
|
||||
#include "explosion.hpp"
|
||||
#include "projectile_manager.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "scene.hpp"
|
||||
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
|
||||
Explosion::Explosion(const Vec3& coord) : ssgTransform()
|
||||
{
|
||||
@ -31,13 +31,20 @@ Explosion::Explosion(const Vec3& coord) : ssgTransform()
|
||||
addKid(cut); // derefing the explosion will free the cutout
|
||||
m_seq = projectile_manager->getExplosionModel();
|
||||
cut->addKid(m_seq);
|
||||
m_explode_sound = sfx_manager->getSfx(SFXManager::SOUND_EXPLOSION);
|
||||
init(coord);
|
||||
} // Explosion
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Explosion::~Explosion()
|
||||
{
|
||||
delete m_explode_sound;
|
||||
// cut will be cleaned up when the explosion is rerefed by plib
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Explosion::init(const Vec3& coord)
|
||||
{
|
||||
sound_manager->playSfx( SOUND_EXPLOSION );
|
||||
m_explode_sound->play();
|
||||
|
||||
sgCoord c;
|
||||
c.xyz[0]=coord[0];c.xyz[1]=coord[1];c.xyz[2]=coord[2];
|
||||
|
@ -23,14 +23,18 @@
|
||||
#include <plib/sg.h>
|
||||
#include "vec3.hpp"
|
||||
|
||||
class SFXBase;
|
||||
|
||||
class Explosion : public ssgTransform
|
||||
{
|
||||
private:
|
||||
SFXBase* m_explode_sound;
|
||||
public:
|
||||
int m_step ;
|
||||
ssgSelector *m_seq ;
|
||||
public:
|
||||
|
||||
Explosion(const Vec3& coord);
|
||||
~Explosion();
|
||||
void init (const Vec3& coord);
|
||||
void update (float delta_t);
|
||||
int inUse () {return (m_step >= 0); }
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "kart.hpp"
|
||||
#include "projectile_manager.hpp"
|
||||
#include "callback_manager.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "scene.hpp"
|
||||
#include "ssg_help.hpp"
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "user_config.hpp"
|
||||
#include "menu_manager.hpp"
|
||||
#include "translation.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "audio/sound_manager.hpp"
|
||||
|
||||
enum WidgetTokens
|
||||
{
|
||||
|
@ -17,14 +17,16 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "grand_prix_ending.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "loader.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "grand_prix_ending.hpp"
|
||||
#include "kart_properties_manager.hpp"
|
||||
#include "unlock_manager.hpp"
|
||||
#include "widget_manager.hpp"
|
||||
@ -48,10 +50,11 @@ enum WidgetTokens
|
||||
WTOK_FIRSTKART
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
GrandPrixEnd::GrandPrixEnd()
|
||||
: m_kart(0)
|
||||
{
|
||||
m_winner_sound = sfx_manager->getSfx(SFXManager::SOUND_WINNER);
|
||||
// for some strange reasons plib calls makeCurrent() in ssgContext
|
||||
// constructor, so we have to save the old one here and restore it
|
||||
ssgContext* oldContext = ssgGetCurrentContext();
|
||||
@ -157,7 +160,7 @@ GrandPrixEnd::GrandPrixEnd()
|
||||
ssgEntity* kartentity = WINNING_KART->getModel();
|
||||
m_kart->addKid(kartentity);
|
||||
|
||||
sound_manager->playSfx(SOUND_WINNER);
|
||||
m_winner_sound->play();
|
||||
|
||||
m_clock = 0;
|
||||
|
||||
@ -173,6 +176,7 @@ GrandPrixEnd::GrandPrixEnd()
|
||||
//-----------------------------------------------------------------------------
|
||||
GrandPrixEnd::~GrandPrixEnd()
|
||||
{
|
||||
delete m_winner_sound;
|
||||
widget_manager->reset();
|
||||
ssgDeRefDelete(m_kart);
|
||||
|
||||
|
@ -25,21 +25,23 @@
|
||||
class ssgBranch;
|
||||
class ssgTransform;
|
||||
class ssgContext;
|
||||
class SFXBase;
|
||||
|
||||
class GrandPrixEnd: public BaseGUI
|
||||
{
|
||||
private:
|
||||
ssgContext* m_context;
|
||||
ssgTransform* m_kart;
|
||||
int m_current_kart;
|
||||
int m_kart_name_label;
|
||||
char* m_score;
|
||||
float m_clock;
|
||||
ssgContext *m_context;
|
||||
ssgTransform *m_kart;
|
||||
int m_current_kart;
|
||||
int m_kart_name_label;
|
||||
char *m_score;
|
||||
float m_clock;
|
||||
SFXBase *m_winner_sound;
|
||||
|
||||
|
||||
public:
|
||||
GrandPrixEnd();
|
||||
~GrandPrixEnd();
|
||||
|
||||
GrandPrixEnd();
|
||||
~GrandPrixEnd();
|
||||
void update(float dt);
|
||||
void select();
|
||||
};
|
||||
|
@ -22,57 +22,67 @@
|
||||
//This is needed in various platforms, but not all
|
||||
# include <algorithm>
|
||||
|
||||
#include "menu_manager.hpp"
|
||||
#include "main_menu.hpp"
|
||||
#include "char_sel.hpp"
|
||||
#include "game_mode.hpp"
|
||||
#include "race_options.hpp"
|
||||
#include "options.hpp"
|
||||
#include "track_sel.hpp"
|
||||
#include "num_players.hpp"
|
||||
#include "config_controls.hpp"
|
||||
#include "config_display.hpp"
|
||||
#include "display_res_confirm.hpp"
|
||||
#include "config_sound.hpp"
|
||||
#include "player_controls.hpp"
|
||||
#include "race_gui.hpp"
|
||||
#include "race_results_gui.hpp"
|
||||
#include "grand_prix_ending.hpp"
|
||||
#include "gui/menu_manager.hpp"
|
||||
#include "gui/main_menu.hpp"
|
||||
#include "gui/char_sel.hpp"
|
||||
#include "gui/game_mode.hpp"
|
||||
#include "gui/race_options.hpp"
|
||||
#include "gui/options.hpp"
|
||||
#include "gui/track_sel.hpp"
|
||||
#include "gui/num_players.hpp"
|
||||
#include "gui/config_controls.hpp"
|
||||
#include "gui/config_display.hpp"
|
||||
#include "gui/display_res_confirm.hpp"
|
||||
#include "gui/config_sound.hpp"
|
||||
#include "gui/player_controls.hpp"
|
||||
#include "gui/race_gui.hpp"
|
||||
#include "gui/race_results_gui.hpp"
|
||||
#include "gui/grand_prix_ending.hpp"
|
||||
#include "gui/race_menu.hpp"
|
||||
#include "gui/help_page_one.hpp"
|
||||
#include "gui/help_page_two.hpp"
|
||||
#include "gui/help_page_three.hpp"
|
||||
#include "gui/credits_menu.hpp"
|
||||
#include "gui/grand_prix_select.hpp"
|
||||
#include "gui/widget_manager.hpp"
|
||||
#include "gui/challenges_menu.hpp"
|
||||
#include "gui/feature_unlocked.hpp"
|
||||
#include "gui/start_race_feedback.hpp"
|
||||
#include "gui/network_gui.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "race_manager.hpp"
|
||||
#include "main_loop.hpp"
|
||||
#include "race_menu.hpp"
|
||||
#include "help_page_one.hpp"
|
||||
#include "help_page_two.hpp"
|
||||
#include "help_page_three.hpp"
|
||||
#include "credits_menu.hpp"
|
||||
#include "grand_prix_select.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "sdldrv.hpp"
|
||||
#include "main_loop.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "widget_manager.hpp"
|
||||
#include "challenges_menu.hpp"
|
||||
#include "feature_unlocked.hpp"
|
||||
#include "start_race_feedback.hpp"
|
||||
#include "network_gui.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
MenuManager* menu_manager= new MenuManager();
|
||||
MenuManager* menu_manager = 0;
|
||||
|
||||
/** Initialises the menu manager and creates the SFX objects.
|
||||
*/
|
||||
MenuManager::MenuManager()
|
||||
{
|
||||
m_current_menu = NULL;
|
||||
m_RaceGUI = NULL;
|
||||
m_change_menu = false;
|
||||
}
|
||||
m_change_menu = false;
|
||||
m_select_sound = sfx_manager->getSfx(SFXManager::SOUND_SELECT_MENU);
|
||||
m_back_sound = sfx_manager->getSfx(SFXManager::SOUND_BACK_MENU);
|
||||
} // MenuManager
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Destroys the menu manager and frees any allocated memory.
|
||||
*/
|
||||
MenuManager::~MenuManager()
|
||||
{
|
||||
delete m_current_menu;
|
||||
delete m_back_sound;
|
||||
delete m_select_sound;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Puts the given menu into the menu stack and saves the widgetToken of
|
||||
* the last selected widget for later reactivation.
|
||||
*/
|
||||
@ -91,11 +101,11 @@ void MenuManager::pushMenu(MenuManagerIDs id)
|
||||
|
||||
if( MENUID_EXITGAME == id )
|
||||
{
|
||||
sound_manager->playSfx(SOUND_BACK_MENU);
|
||||
m_back_sound->play();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !is_startup ) sound_manager->playSfx(SOUND_SELECT_MENU);
|
||||
if(!is_startup) m_select_sound->play();
|
||||
else is_startup = false;
|
||||
}
|
||||
|
||||
@ -113,9 +123,9 @@ void MenuManager::pushMenu(MenuManagerIDs id)
|
||||
//-----------------------------------------------------------------------------
|
||||
void MenuManager::popMenu()
|
||||
{
|
||||
sound_manager->playSfx(SOUND_BACK_MENU);
|
||||
m_back_sound->play();
|
||||
|
||||
m_menu_stack.pop_back();
|
||||
m_menu_stack.pop_back();
|
||||
if( m_current_menu ) m_current_menu->lockInput();
|
||||
m_change_menu = true;
|
||||
}
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "gui/race_gui.hpp"
|
||||
#include "gui/base_gui.hpp"
|
||||
|
||||
class SFXBase;
|
||||
|
||||
enum MenuManagerIDs
|
||||
{
|
||||
// menu
|
||||
@ -72,32 +74,33 @@ enum MenuManagerIDs
|
||||
class MenuManager
|
||||
{
|
||||
public:
|
||||
MenuManager();
|
||||
MenuManager();
|
||||
virtual ~MenuManager();
|
||||
|
||||
// general functions
|
||||
void switchToGrandPrixEnding();
|
||||
void switchToRace();
|
||||
void switchToMainMenu();
|
||||
void switchToGrandPrixEnding();
|
||||
void switchToRace();
|
||||
void switchToMainMenu();
|
||||
|
||||
// use this function within menu classes
|
||||
void pushMenu(MenuManagerIDs);
|
||||
void popMenu();
|
||||
|
||||
int getMenuStackSize() {return (int)m_menu_stack.size();}
|
||||
|
||||
bool isCurrentMenu(MenuManagerIDs id) {return (m_menu_stack.back().first == id);}
|
||||
bool isSomewhereOnStack(MenuManagerIDs id);
|
||||
void pushMenu(MenuManagerIDs);
|
||||
void popMenu();
|
||||
int getMenuStackSize() {return (int)m_menu_stack.size();}
|
||||
bool isSomewhereOnStack(MenuManagerIDs id);
|
||||
bool isCurrentMenu(MenuManagerIDs id)
|
||||
{return (m_menu_stack.back().first == id);}
|
||||
BaseGUI* getCurrentMenu() const {return m_current_menu;}
|
||||
RaceGUI* getRaceMenu () const {return (RaceGUI*)m_RaceGUI;}
|
||||
|
||||
void update();
|
||||
void update();
|
||||
|
||||
private:
|
||||
std::vector< std::pair<MenuManagerIDs, int> > m_menu_stack;
|
||||
std::vector< std::pair<MenuManagerIDs, int> >
|
||||
m_menu_stack;
|
||||
BaseGUI* m_current_menu;
|
||||
BaseGUI* m_RaceGUI;
|
||||
bool m_change_menu;
|
||||
bool m_change_menu;
|
||||
SFXBase *m_back_sound;
|
||||
SFXBase *m_select_sound;
|
||||
};
|
||||
|
||||
extern MenuManager* menu_manager;
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "track.hpp"
|
||||
#include "material_manager.hpp"
|
||||
#include "menu_manager.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "race_manager.hpp"
|
||||
|
||||
#undef USE_WIDGET_MANAGER
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include "menu_manager.hpp"
|
||||
#include "race_manager.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "translation.hpp"
|
||||
|
||||
enum WidgetTokens
|
||||
|
@ -517,7 +517,7 @@
|
||||
Optimization="0"
|
||||
WholeProgramOptimization="false"
|
||||
AdditionalIncludeDirectories="../../../src;../../../src/bullet/src;"$(STK_INCLUDE)";../../../src/enet/include"
|
||||
PreprocessorDefinitions="BT_NO_PROFILE;HAVE_OPENAL;HAVE_OGGVORBIS;_DEBUG;_CONSOLE;WIN32;NOMINMAX;VERSION=\"SVN\";_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;DEBUG;PACKAGE=\"supertuxkart\";HAS_GETTEXT;HAVE_ENET"
|
||||
PreprocessorDefinitions="BT_NO_PROFILE;HAVE_OPENAL;HAVE_OGGVORBIS;_DEBUG;_CONSOLE;WIN32;NOMINMAX;VERSION=\"SVN\";_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;DEBUG;PACKAGE=\"supertuxkart\";HAS_GETTEXT"
|
||||
GeneratePreprocessedFile="0"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -795,14 +795,6 @@
|
||||
RelativePath="../../../src\moving_texture.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\music_information.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\music_ogg.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\particle_system.cpp"
|
||||
>
|
||||
@ -847,10 +839,6 @@
|
||||
RelativePath="../../../src\sdldrv.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\sfx_openal.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\shadow.cpp"
|
||||
>
|
||||
@ -863,10 +851,6 @@
|
||||
RelativePath="..\..\smoke.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\sound_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\ssg_help.cpp"
|
||||
>
|
||||
@ -1127,6 +1111,30 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="audio"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\audio\music_information.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\music_ogg.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\sfx_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\sfx_openal.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\sound_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Headerdateien"
|
||||
@ -1289,18 +1297,6 @@
|
||||
RelativePath="../../../src\moving_texture.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\music.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\music_information.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\music_ogg.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\no_copy.hpp"
|
||||
>
|
||||
@ -1361,14 +1357,6 @@
|
||||
RelativePath="../../../src\sdldrv.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\sfx.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\sfx_openal.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\shadow.hpp"
|
||||
>
|
||||
@ -1381,10 +1369,6 @@
|
||||
RelativePath="..\..\smoke.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\sound_manager.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\ssg_help.hpp"
|
||||
>
|
||||
@ -1685,6 +1669,38 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="audio"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\audio\music.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\music_information.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\music_ogg.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\sfx_base.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\sfx_manager.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\sfx_openal.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\audio\sound_manager.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Ressourcendateien"
|
||||
|
67
src/kart.cpp
67
src/kart.cpp
@ -20,6 +20,10 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#define _WINSOCKAPI_
|
||||
#include <plib/ssg.h>
|
||||
|
||||
@ -27,7 +31,6 @@
|
||||
#include "loader.hpp"
|
||||
#include "coord.hpp"
|
||||
#include "herring_manager.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "file_manager.hpp"
|
||||
#include "skid_mark.hpp"
|
||||
#include "user_config.hpp"
|
||||
@ -44,15 +47,12 @@
|
||||
#include "translation.hpp"
|
||||
#include "smoke.hpp"
|
||||
#include "material_manager.hpp"
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "network/race_state.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
// num_players triggers 'already defined' messages without the WINSOCKAPI define. Don't ask me :(
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
Kart::Kart (const std::string& kart_name, int position,
|
||||
const btTransform& init_transform)
|
||||
@ -104,6 +104,14 @@ Kart::Kart (const std::string& kart_name, int position,
|
||||
m_wheel_rear_l = NULL;
|
||||
m_wheel_rear_r = NULL;
|
||||
m_lap_start_time = -1.0f;
|
||||
|
||||
m_engine_sound = sfx_manager->getSfx(SFXManager::SOUND_ENGINE);
|
||||
|
||||
if(!m_engine_sound)
|
||||
{
|
||||
fprintf(stdout, "Error: Could not allocate a sfx object for the kart. Further errors may ensue!\n");
|
||||
}
|
||||
|
||||
loadData();
|
||||
reset();
|
||||
} // Kart
|
||||
@ -243,11 +251,26 @@ void Kart::createPhysics(ssgEntity *obj)
|
||||
m_uprightConstraint->setLimitSoftness(1.0f);
|
||||
m_uprightConstraint->setDamping(0.0f);
|
||||
world->getPhysics()->addKart(this, m_vehicle);
|
||||
|
||||
//create the engine sound
|
||||
if(m_engine_sound)
|
||||
{
|
||||
m_engine_sound->speed(0.5f);
|
||||
m_engine_sound->loop();
|
||||
m_engine_sound->play();
|
||||
}
|
||||
} // createPhysics
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
Kart::~Kart()
|
||||
{
|
||||
//stop the engine sound
|
||||
if(m_engine_sound)
|
||||
{
|
||||
m_engine_sound->stop();
|
||||
}
|
||||
delete m_engine_sound;
|
||||
|
||||
if(m_smokepuff) delete m_smokepuff;
|
||||
if(m_smoke_system != NULL) delete m_smoke_system;
|
||||
|
||||
@ -473,8 +496,7 @@ void Kart::raceFinished(float time)
|
||||
//-----------------------------------------------------------------------------
|
||||
void Kart::collectedHerring(const Herring &herring, int add_info)
|
||||
{
|
||||
const herringType type = herring.getType();
|
||||
const int OLD_HERRING_GOBBLED = m_num_herrings_gobbled;
|
||||
const herringType type = herring.getType();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@ -497,10 +519,7 @@ void Kart::collectedHerring(const Herring &herring, int add_info)
|
||||
if ( m_num_herrings_gobbled > MAX_HERRING_EATEN )
|
||||
m_num_herrings_gobbled = MAX_HERRING_EATEN;
|
||||
|
||||
if(OLD_HERRING_GOBBLED < m_num_herrings_gobbled &&
|
||||
m_num_herrings_gobbled == MAX_HERRING_EATEN)
|
||||
sound_manager->playSfx(SOUND_FULL);
|
||||
} // hitHerring
|
||||
} // collectedHerring
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Simulates gears
|
||||
@ -511,7 +530,10 @@ float Kart::getActualWheelForce()
|
||||
for(unsigned int i=0; i<gear_ratio.size(); i++)
|
||||
{
|
||||
if(m_speed <= m_max_speed*gear_ratio[i])
|
||||
{
|
||||
m_current_gear_ratio = gear_ratio[i];
|
||||
return getMaxPower()*m_kart_properties->getGearPowerIncrease()[i]+zipperF;
|
||||
}
|
||||
}
|
||||
return getMaxPower()+zipperF;
|
||||
|
||||
@ -596,7 +618,6 @@ void Kart::update(float dt)
|
||||
const float rescue_height = 2.0f;
|
||||
if(m_attachment.getType() != ATTACH_TINYTUX)
|
||||
{
|
||||
if(isPlayerKart()) sound_manager -> playSfx ( SOUND_BZZT );
|
||||
m_attachment.set( ATTACH_TINYTUX, rescue_time ) ;
|
||||
m_rescue_pitch = getHPR().getPitch();
|
||||
m_rescue_roll = getHPR().getRoll();
|
||||
@ -920,8 +941,24 @@ void Kart::updatePhysics (float dt)
|
||||
//at low velocity, forces on kart push it back and forth so we ignore this
|
||||
if(fabsf(m_speed) < 0.2f) // quick'n'dirty workaround for bug 1776883
|
||||
m_speed = 0;
|
||||
} // updatePhysics
|
||||
|
||||
//Change the engine sound based on kart RPM.
|
||||
//The equation here is:
|
||||
// speed * gear_ratio
|
||||
// RPM = --------------------
|
||||
// tire_diameter
|
||||
//the magic number 1.7 is used to bring the computed gear ratio into a sensible range
|
||||
float gear_ratio = 1.7f + (1 - m_current_gear_ratio);
|
||||
float tire_diameter = 2;//can this be determined for each kart? Smaller tires make for higher rpm's.
|
||||
|
||||
m_max_gear_rpm = m_current_gear_ratio * max_speed;
|
||||
m_rpm = ((m_speed * gear_ratio) / tire_diameter);
|
||||
if(m_engine_sound)
|
||||
{
|
||||
m_engine_sound->speed((float)((m_rpm * 2) / m_max_gear_rpm));
|
||||
//m_engine_sound->position(m_curr_track_coords);
|
||||
}
|
||||
} // updatePhysics
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Kart::forceRescue(bool is_shortcut)
|
||||
|
@ -35,6 +35,7 @@
|
||||
class SkidMark;
|
||||
class Herring;
|
||||
class Smoke;
|
||||
class SFXBase;
|
||||
|
||||
class Kart : public TerrainInfo, public Moveable
|
||||
{
|
||||
@ -57,6 +58,7 @@ protected:
|
||||
int m_track_sector; // index in driveline, special values
|
||||
// e.g. UNKNOWN_SECTOR can be negative!
|
||||
float m_max_speed; // maximum speed of the kart, computed from
|
||||
float m_max_gear_rpm; //maximum engine rpm's for the current gear
|
||||
float m_max_speed_reverse_ratio;
|
||||
float m_wheelie_angle;
|
||||
float m_zipper_time_left; // zipper time left
|
||||
@ -96,11 +98,15 @@ private:
|
||||
bool m_finished_race;
|
||||
|
||||
float m_speed;
|
||||
float m_rpm;
|
||||
float m_current_gear_ratio;
|
||||
bool m_rescue;
|
||||
bool m_eliminated;
|
||||
|
||||
SFXBase *m_engine_sound;
|
||||
|
||||
protected:
|
||||
float m_rescue_pitch, m_rescue_roll;
|
||||
float m_rescue_pitch, m_rescue_roll;
|
||||
const KartProperties *m_kart_properties;
|
||||
|
||||
/** Search the given branch of objects that match the wheel names
|
||||
|
@ -62,7 +62,8 @@
|
||||
#include "history.hpp"
|
||||
#include "herring_manager.hpp"
|
||||
#include "attachment_manager.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "stk_config.hpp"
|
||||
#include "translation.hpp"
|
||||
#include "highscore_manager.hpp"
|
||||
@ -70,6 +71,7 @@
|
||||
#include "network/network_manager.hpp"
|
||||
#include "gui/menu_manager.hpp"
|
||||
#include "scene.hpp"
|
||||
#include "gui/menu_manager.hpp"
|
||||
|
||||
// Only needed for bullet debug!
|
||||
#ifdef __APPLE__
|
||||
@ -425,7 +427,7 @@ void InitTuxkart()
|
||||
unlock_manager = new UnlockManager();
|
||||
user_config = new UserConfig();
|
||||
sound_manager = new SoundManager();
|
||||
|
||||
sfx_manager = new SFXManager();
|
||||
// The order here can be important, e.g. KartPropertiesManager needs
|
||||
// defaultKartProperties.
|
||||
history = new History ();
|
||||
@ -453,6 +455,8 @@ void InitTuxkart()
|
||||
race_manager->setMinorMode (RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
|
||||
menu_manager= new MenuManager();
|
||||
|
||||
// Consistency check for challenges, and enable all challenges
|
||||
// that have all prerequisites fulfilled
|
||||
grand_prix_manager->checkConsistency();
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <assert.h>
|
||||
#include "sdldrv.hpp"
|
||||
#include "gui/menu_manager.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "material_manager.hpp"
|
||||
#include "race_manager.hpp"
|
||||
#include "world.hpp"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "flyable.hpp"
|
||||
#include "moving_physics.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "material_manager.hpp"
|
||||
#include "network/race_state.hpp"
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "player_kart.hpp"
|
||||
#include "player.hpp"
|
||||
#include "sdldrv.hpp"
|
||||
@ -39,9 +40,30 @@ PlayerKart::PlayerKart(const std::string& kart_name, int position, Player *playe
|
||||
m_penalty_time = 0.0f;
|
||||
m_camera = scene->createCamera(player_index, this);
|
||||
m_camera->setMode(Camera::CM_NORMAL);
|
||||
|
||||
m_bzzt_sound = sfx_manager->getSfx(SFXManager::SOUND_BZZT );
|
||||
m_beep_sound = sfx_manager->getSfx(SFXManager::SOUND_BEEP );
|
||||
m_crash_sound = sfx_manager->getSfx(SFXManager::SOUND_CRASH);
|
||||
m_wee_sound = sfx_manager->getSfx(SFXManager::SOUND_WEE );
|
||||
m_ugh_sound = sfx_manager->getSfx(SFXManager::SOUND_UGH );
|
||||
m_grab_sound = sfx_manager->getSfx(SFXManager::SOUND_GRAB );
|
||||
m_full_sound = sfx_manager->getSfx(SFXManager::SOUND_FULL );
|
||||
|
||||
reset();
|
||||
} // PlayerKart
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
PlayerKart::~PlayerKart()
|
||||
{
|
||||
delete m_bzzt_sound;
|
||||
delete m_beep_sound;
|
||||
delete m_crash_sound;
|
||||
delete m_wee_sound;
|
||||
delete m_ugh_sound;
|
||||
delete m_grab_sound;
|
||||
delete m_full_sound;
|
||||
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void PlayerKart::reset()
|
||||
{
|
||||
@ -154,8 +176,11 @@ void PlayerKart::update(float dt)
|
||||
if(m_controls.accel!=0.0 || m_controls.brake!=false ||
|
||||
m_controls.fire|m_controls.wheelie|m_controls.jump)
|
||||
{
|
||||
//JH Some sound here?
|
||||
m_penalty_time=1.0;
|
||||
if(m_penalty_time == 0.0)//eliminates machine-gun-effect for SOUND_BZZT
|
||||
{
|
||||
m_penalty_time=1.0;
|
||||
m_bzzt_sound->play();
|
||||
}
|
||||
// A warning gets displayed in RaceGUI
|
||||
}
|
||||
else
|
||||
@ -176,7 +201,8 @@ void PlayerKart::update(float dt)
|
||||
|
||||
if ( m_controls.fire && !isRescue())
|
||||
{
|
||||
if (m_collectable.getType()==COLLECT_NOTHING) sound_manager->playSfx(SOUND_BEEP);
|
||||
if (m_collectable.getType()==COLLECT_NOTHING)
|
||||
m_beep_sound->play();
|
||||
}
|
||||
|
||||
// We can't restrict rescue to fulfil isOnGround() (which would be more like
|
||||
@ -184,11 +210,17 @@ void PlayerKart::update(float dt)
|
||||
// up sitting on a brick wall, with all wheels in the air :((
|
||||
if ( m_controls.rescue )
|
||||
{
|
||||
sound_manager -> playSfx ( SOUND_BEEP ) ;
|
||||
m_beep_sound->play();
|
||||
forceRescue();
|
||||
m_controls.rescue=false;
|
||||
}
|
||||
|
||||
// FIXME: This is the code previously done in Kart::update (for player
|
||||
// karts). Does this mean that there are actually two sounds played
|
||||
// when rescue? beep above and bzzt her???
|
||||
if (isRescue() && m_attachment.getType() != ATTACH_TINYTUX)
|
||||
{
|
||||
m_bzzt_sound->play();
|
||||
}
|
||||
Kart::update(dt);
|
||||
} // update
|
||||
|
||||
@ -204,7 +236,7 @@ void PlayerKart::crashed(Kart *kart)
|
||||
|
||||
if(world->getTime() - m_time_last_crash_sound > 0.5f)
|
||||
{
|
||||
sound_manager->playSfx( SOUND_CRASH );
|
||||
m_crash_sound->play();
|
||||
m_time_last_crash_sound = world->getTime();
|
||||
}
|
||||
} // crashed
|
||||
@ -216,12 +248,15 @@ void PlayerKart::setPosition(int p)
|
||||
{
|
||||
if(getPosition()<p)
|
||||
{
|
||||
sound_manager->playSfx(SOUND_BEEP);
|
||||
m_beep_sound->play();
|
||||
}
|
||||
Kart::setPosition(p);
|
||||
} // setPosition
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called when a kart finishes race.
|
||||
* /param time Finishing time for this kart.
|
||||
*/
|
||||
void PlayerKart::raceFinished(float time)
|
||||
{
|
||||
Kart::raceFinished(time);
|
||||
@ -235,17 +270,41 @@ void PlayerKart::raceFinished(float time)
|
||||
} // raceFinished
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called when a kart hits or uses a zipper.
|
||||
*/
|
||||
void PlayerKart::handleZipper()
|
||||
{
|
||||
Kart::handleZipper();
|
||||
sound_manager->playSfx ( SOUND_WEE );
|
||||
m_wee_sound->play();
|
||||
} // handleZipper
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called when a kart hits a herring.
|
||||
* \param herring Herring that was collected.
|
||||
* \param add_info Additional info to be used then handling the herring. If
|
||||
* this is -1 (default), the herring type is selected
|
||||
* randomly. Otherwise it contains the collectable or
|
||||
* attachment for the kart. This is used in network mode to
|
||||
* let the server determine the collectable/attachment for
|
||||
* the clients.
|
||||
*/
|
||||
void PlayerKart::collectedHerring(const Herring &herring, int add_info)
|
||||
{
|
||||
const int old_herring_gobbled = getNumHerring();
|
||||
Kart::collectedHerring(herring, add_info);
|
||||
sound_manager->playSfx ( ( herring.getType()==HE_GREEN ) ? SOUND_UGH:SOUND_GRAB);
|
||||
|
||||
if(old_herring_gobbled < MAX_HERRING_EATEN &&
|
||||
getNumHerring() == MAX_HERRING_EATEN)
|
||||
{
|
||||
m_full_sound->play();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(herring.getType() == HE_GREEN)
|
||||
m_ugh_sound->play();
|
||||
else
|
||||
m_grab_sound->play();
|
||||
}
|
||||
} // collectedHerring
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "kart.hpp"
|
||||
#include "player.hpp"
|
||||
|
||||
class SFXBase;
|
||||
class Player;
|
||||
class Camera;
|
||||
|
||||
@ -40,12 +41,20 @@ private:
|
||||
float m_time_last_crash_sound;
|
||||
Camera *m_camera;
|
||||
|
||||
SFXBase *m_bzzt_sound;
|
||||
SFXBase *m_beep_sound;
|
||||
SFXBase *m_crash_sound;
|
||||
SFXBase *m_wee_sound;
|
||||
SFXBase *m_ugh_sound;
|
||||
SFXBase *m_grab_sound;
|
||||
SFXBase *m_full_sound;
|
||||
|
||||
void steer(float, int);
|
||||
public:
|
||||
PlayerKart(const std::string& kart_name,
|
||||
int position, Player *_player,
|
||||
const btTransform& init_pos, int player_index);
|
||||
|
||||
~PlayerKart ();
|
||||
int earlyStartPenalty () {return m_penalty_time>0; }
|
||||
Player *getPlayer () {return m_player; }
|
||||
void update (float);
|
||||
|
@ -1,147 +0,0 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2006 Patrick Ammann <pammann@aro.ch>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#if HAVE_OGGVORBIS
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <OpenAL/al.h>
|
||||
#else
|
||||
# include <AL/al.h>
|
||||
#endif
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_endian.h>
|
||||
|
||||
#include "sfx_openal.hpp"
|
||||
#include "file_manager.hpp"
|
||||
#include "user_config.hpp"
|
||||
|
||||
SFXImpl::SFXImpl(const char* filename)
|
||||
{
|
||||
m_soundBuffer= 0;
|
||||
m_soundSource= 0;
|
||||
const bool LOADED = load(filename);
|
||||
assert( LOADED );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
SFXImpl::~SFXImpl()
|
||||
{
|
||||
alDeleteBuffers(1, &m_soundBuffer);
|
||||
alDeleteSources(1, &m_soundSource);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFXImpl::play()
|
||||
{
|
||||
alSourcef(m_soundSource,AL_GAIN,user_config->m_sfx_volume);
|
||||
alSourcePlay(m_soundSource);
|
||||
|
||||
// Check (and clear) the error flag
|
||||
int error = alGetError();
|
||||
|
||||
if(error != AL_NO_ERROR)
|
||||
{
|
||||
fprintf(stderr, "SFX OpenAL error: %d\n", error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SFXImpl::load(const char* filename)
|
||||
{
|
||||
std::string path = file_manager->getSFXFile(filename);
|
||||
|
||||
alGenBuffers(1, &m_soundBuffer);
|
||||
if (alGetError() != AL_NO_ERROR)
|
||||
{
|
||||
fprintf(stderr, "Loading '%s' failed\n",filename);
|
||||
return false;
|
||||
}
|
||||
ALenum format = 0;
|
||||
Uint32 size = 0;
|
||||
Uint8* data = NULL;
|
||||
SDL_AudioSpec spec;
|
||||
|
||||
if( SDL_LoadWAV( path.c_str(), &spec, &data, &size ) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error 1 loading SFX: with file %s, SDL_LoadWAV() failed\n", path.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
switch( spec.format )
|
||||
{
|
||||
case AUDIO_U8:
|
||||
case AUDIO_S8:
|
||||
if( spec.channels == 2 ) format = AL_FORMAT_STEREO8;
|
||||
else format = AL_FORMAT_MONO8;
|
||||
break;
|
||||
case AUDIO_U16LSB:
|
||||
case AUDIO_S16LSB:
|
||||
case AUDIO_U16MSB:
|
||||
case AUDIO_S16MSB:
|
||||
if( spec.channels == 2 ) format = AL_FORMAT_STEREO16;
|
||||
else format = AL_FORMAT_MONO16;
|
||||
|
||||
#if defined(WORDS_BIGENDIAN) || SDL_BYTEORDER==SDL_BIG_ENDIAN
|
||||
// swap bytes around for big-endian systems
|
||||
for(unsigned int n=0; n<size-1; n+=2)
|
||||
{
|
||||
Uint8 temp = data[n+1];
|
||||
data[n+1] = data[n];
|
||||
data[n] = temp;
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
alBufferData(m_soundBuffer, format, data, size, spec.freq);
|
||||
if (alGetError() != AL_NO_ERROR)
|
||||
{
|
||||
fprintf(stderr, "Error 2 loading SFX: %s failed\n", path.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_FreeWAV(data);
|
||||
|
||||
alGenSources(1, &m_soundSource );
|
||||
if (alGetError() != AL_NO_ERROR)
|
||||
{
|
||||
fprintf(stderr, "Error 3 loading SFX: %s failed\n", path.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// not 3D yet
|
||||
alSourcei (m_soundSource, AL_BUFFER, m_soundBuffer);
|
||||
alSource3f(m_soundSource, AL_POSITION, 0.0, 0.0, 0.0);
|
||||
alSource3f(m_soundSource, AL_VELOCITY, 0.0, 0.0, 0.0);
|
||||
alSource3f(m_soundSource, AL_DIRECTION, 0.0, 0.0, 0.0);
|
||||
alSourcef (m_soundSource, AL_ROLLOFF_FACTOR, 0.0 );
|
||||
alSourcei (m_soundSource, AL_SOURCE_RELATIVE, AL_TRUE );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif //if HAVE_OGGVORBIS
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "stk_config.hpp"
|
||||
#include "file_manager.hpp"
|
||||
#include "music_information.hpp"
|
||||
#include "audio/music_information.hpp"
|
||||
|
||||
STKConfig* stk_config=0;
|
||||
float STKConfig::UNDEFINED = -99.9f;
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "user_config.hpp"
|
||||
#include "herring.hpp"
|
||||
#include "herring_manager.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "race_manager.hpp"
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
@ -433,8 +433,9 @@ btTransform Track::getStartTransform(unsigned int pos) const {
|
||||
btTransform start;
|
||||
start.setOrigin(orig);
|
||||
start.setRotation(btQuaternion(btVector3(0, 0, 1),
|
||||
pos<m_start_heading.size()
|
||||
? DEGREE_TO_RAD(m_start_heading[pos]) : 0.0f ));
|
||||
pos<m_start_heading.size()
|
||||
? DEGREE_TO_RAD(m_start_heading[pos])
|
||||
: 0.0f ));
|
||||
return start;
|
||||
} // getStartTransform
|
||||
|
||||
|
@ -31,11 +31,11 @@
|
||||
#include <plib/ssg.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "LinearMath/btTransform.h"
|
||||
#include "vec3.hpp"
|
||||
#include "material.hpp"
|
||||
#include "triangle_mesh.hpp"
|
||||
#include "music_information.hpp"
|
||||
#include "audio/music_information.hpp"
|
||||
|
||||
class Track
|
||||
{
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "string_utils.hpp"
|
||||
#include "track_manager.hpp"
|
||||
#include "track.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "translation.hpp"
|
||||
|
||||
TrackManager* track_manager = 0;
|
||||
|
@ -38,7 +38,9 @@
|
||||
#include "callback_manager.hpp"
|
||||
#include "history.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "translation.hpp"
|
||||
#include "highscore_manager.hpp"
|
||||
#include "scene.hpp"
|
||||
@ -173,6 +175,9 @@ World::World()
|
||||
callback_manager->initAll();
|
||||
menu_manager->switchToRace();
|
||||
|
||||
m_prestart_sound = sfx_manager->getSfx(SFXManager::SOUND_PRESTART);
|
||||
m_start_sound = sfx_manager->getSfx(SFXManager::SOUND_START);
|
||||
|
||||
m_track->startMusic();
|
||||
|
||||
m_phase = user_config->m_profile ? RACE_PHASE : SETUP_PHASE;
|
||||
@ -210,6 +215,8 @@ World::~World()
|
||||
delete m_physics;
|
||||
|
||||
sound_manager -> stopMusic();
|
||||
delete m_prestart_sound;
|
||||
delete m_start_sound;
|
||||
|
||||
sgVec3 sun_pos;
|
||||
sgVec4 ambient_col, specular_col, diffuse_col;
|
||||
@ -473,13 +480,13 @@ void World::updateRaceStatus(float dt)
|
||||
// simplifies this handling
|
||||
case SETUP_PHASE: m_clock = 0.0f;
|
||||
m_phase = READY_PHASE;
|
||||
sound_manager->playSfx(SOUND_PRESTART);
|
||||
m_prestart_sound->play();
|
||||
dt = 0.0f; // solves the problem of adding track loading time
|
||||
return; // loading time, don't play sound yet
|
||||
case READY_PHASE: if(m_clock>1.0)
|
||||
{
|
||||
m_phase=SET_PHASE;
|
||||
sound_manager->playSfx(SOUND_PRESTART);
|
||||
m_prestart_sound->play();
|
||||
}
|
||||
m_clock += dt;
|
||||
return;
|
||||
@ -490,7 +497,7 @@ void World::updateRaceStatus(float dt)
|
||||
m_clock=m_leader_intervals[0];
|
||||
else
|
||||
m_clock=0.0f;
|
||||
sound_manager->playSfx(SOUND_START);
|
||||
m_start_sound->play();
|
||||
// Reset the brakes now that the prestart
|
||||
// phase is over (braking prevents the karts
|
||||
// from sliding downhill)
|
||||
|
@ -17,12 +17,13 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_WORLD_H
|
||||
#define HEADER_WORLD_H
|
||||
#ifndef HEADER_WORLD_HPP
|
||||
#define HEADER_WORLD_HPP
|
||||
|
||||
#include <vector>
|
||||
#define _WINSOCKAPI_
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#include "track.hpp"
|
||||
#include "player_kart.hpp"
|
||||
#include "physics.hpp"
|
||||
@ -36,6 +37,8 @@
|
||||
class ReplayPlayer;
|
||||
#endif
|
||||
|
||||
class SFXBase;
|
||||
|
||||
/** This class is responsible for running the actual race. A world is created
|
||||
* by the race manager on the start of each race (so a new world is created
|
||||
* for each race of a Grand Prix). It creates the
|
||||
@ -75,7 +78,6 @@
|
||||
* would be done in the mode specific world (instead of in the
|
||||
* RaceManager).
|
||||
*/
|
||||
|
||||
class World
|
||||
{
|
||||
public:
|
||||
@ -165,6 +167,8 @@ private:
|
||||
std::vector<float>
|
||||
m_leader_intervals; // time till elimination in follow leader
|
||||
bool m_faster_music_active; // true if faster music was activated
|
||||
SFXBase *m_prestart_sound;
|
||||
SFXBase *m_start_sound;
|
||||
|
||||
void updateRacePosition(int k);
|
||||
void updateHighscores ();
|
||||
|
Loading…
Reference in New Issue
Block a user