// 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.
+#include <config.h>
#include "sound_manager.hpp"
}
void
+SoundManager::preload(const std::string& filename)
+{
+ if(!sound_enabled)
+ return;
+
+ SoundBuffers::iterator i = buffers.find(filename);
+ // already loaded?
+ if(i != buffers.end())
+ return;
+
+ std::auto_ptr<SoundFile> file (load_sound_file(filename));
+ // only keep small files
+ if(file->size >= 100000)
+ return;
+
+ ALuint buffer = load_file_into_buffer(file.get());
+ buffers.insert(std::make_pair(filename, buffer));
+}
+
+void
SoundManager::play(const std::string& filename, const Vector& pos)
{
try {
*/
void play(const std::string& name, const Vector& pos = Vector(-1, -1));
void play_and_delete(SoundSource* source);
+ /// preloads a sound, so that you don't get a lag later when playing it
+ void preload(const std::string& name);
void set_listener_position(const Vector& position);
void set_listener_velocity(const Vector& velocity);
// 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.
-
#include <config.h>
#include "badguy.hpp"
: MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(LEFT), state(STATE_INIT)
{
start_position = bbox.p1;
+
+ sound_manager->preload("sounds/squish.wav");
+ sound_manager->preload("sounds/fall.wav");
}
BadGuy::BadGuy(const lisp::Lisp& reader, const std::string& sprite_name, int layer)
: MovingSprite(reader, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(LEFT), state(STATE_INIT)
{
start_position = bbox.p1;
+
+ sound_manager->preload("sounds/squish.wav");
+ sound_manager->preload("sounds/fall.wav");
}
void
smalltux_star = sprite_manager->create("images/creatures/tux_small/smalltux-star.sprite");
bigtux_star = sprite_manager->create("images/creatures/tux_big/bigtux-star.sprite");
+ sound_manager->preload("sounds/bigjump.wav");
+ sound_manager->preload("sounds/jump.wav");
+ sound_manager->preload("sounds/hurt.wav");
+ sound_manager->preload("sounds/skid.wav");
+
init();
}