mirror of
https://github.com/NoelFB/tiny_link.git
synced 2025-02-20 13:48:28 +08:00
test out audio branch for blah
This commit is contained in:
parent
f62a60cb3e
commit
7aa6efad1f
BIN
content/sounds/explosion.wav
Normal file
BIN
content/sounds/explosion.wav
Normal file
Binary file not shown.
BIN
content/sounds/hurt.wav
Normal file
BIN
content/sounds/hurt.wav
Normal file
Binary file not shown.
BIN
content/sounds/jump.wav
Normal file
BIN
content/sounds/jump.wav
Normal file
Binary file not shown.
BIN
content/sounds/melody2_forest.ogg
Normal file
BIN
content/sounds/melody2_forest.ogg
Normal file
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
#include "hurtable.h"
|
#include "hurtable.h"
|
||||||
#include "animator.h"
|
#include "animator.h"
|
||||||
|
#include "../content.h"
|
||||||
|
|
||||||
using namespace TL;
|
using namespace TL;
|
||||||
|
|
||||||
@ -15,8 +16,10 @@ void Hurtable::update()
|
|||||||
{
|
{
|
||||||
if (collider && on_hurt && stun_timer <= 0)
|
if (collider && on_hurt && stun_timer <= 0)
|
||||||
{
|
{
|
||||||
if (collider->check(hurt_by))
|
if (collider->check(hurt_by)) {
|
||||||
|
Sound::play(Content::find_audio("hurt.wav"));
|
||||||
hurt();
|
hurt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stun_timer -= Time::delta;
|
stun_timer -= Time::delta;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "collider.h"
|
#include "collider.h"
|
||||||
#include "orb.h"
|
#include "orb.h"
|
||||||
#include "../masks.h"
|
#include "../masks.h"
|
||||||
|
#include "../content.h"
|
||||||
|
|
||||||
using namespace TL;
|
using namespace TL;
|
||||||
|
|
||||||
@ -119,6 +120,9 @@ void Player::update()
|
|||||||
anim->scale = Vec2f(m_facing * 0.65f, 1.4f);
|
anim->scale = Vec2f(m_facing * 0.65f, 1.4f);
|
||||||
mover->speed.x = input * max_air_speed;
|
mover->speed.x = input * max_air_speed;
|
||||||
m_jump_timer = jump_time;
|
m_jump_timer = jump_time;
|
||||||
|
SoundParams params;
|
||||||
|
params.volume = 3.0f;
|
||||||
|
Sound::play(Content::find_audio("jump.wav"), params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ namespace
|
|||||||
Vector<Tileset> tilesets;
|
Vector<Tileset> tilesets;
|
||||||
Vector<Subtexture> subtextures;
|
Vector<Subtexture> subtextures;
|
||||||
Vector<RoomInfo> rooms;
|
Vector<RoomInfo> rooms;
|
||||||
|
Vector<String> audio_names;
|
||||||
|
Vector<AudioRef> audios;
|
||||||
TextureRef sprite_atlas;
|
TextureRef sprite_atlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +200,19 @@ void Content::load()
|
|||||||
|
|
||||||
rooms.push_back(info);
|
rooms.push_back(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load audio
|
||||||
|
for (auto& it : Directory::enumerate(path() + "/sounds", false))
|
||||||
|
{
|
||||||
|
if (!(it.ends_with(".ogg") || it.ends_with(".wav")))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
FilePath path = FilePath(it.cstr());
|
||||||
|
AudioRef audio = Audio::create(path);
|
||||||
|
BLAH_ASSERT(audio->get_backend_handle(), "Unable to load audio.");
|
||||||
|
audios.push_back(audio);
|
||||||
|
audio_names.push_back(Path::get_file_name(path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Content::unload()
|
void Content::unload()
|
||||||
@ -236,3 +251,12 @@ const Image* Content::find_room(const Point& cell)
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AudioRef Content::find_audio(const char* name)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < audio_names.size(); ++i)
|
||||||
|
if (audio_names[i] == name)
|
||||||
|
return audios[i];
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
@ -21,5 +21,6 @@ namespace TL
|
|||||||
static const Sprite* find_sprite(const char* name);
|
static const Sprite* find_sprite(const char* name);
|
||||||
static const Tileset* find_tileset(const char* name);
|
static const Tileset* find_tileset(const char* name);
|
||||||
static const Image* find_room(const Point& cell);
|
static const Image* find_room(const Point& cell);
|
||||||
|
static const AudioRef find_audio(const char* name);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -9,6 +9,7 @@
|
|||||||
#include "components/enemy.h"
|
#include "components/enemy.h"
|
||||||
#include "components/ghost_frog.h"
|
#include "components/ghost_frog.h"
|
||||||
#include "components/orb.h"
|
#include "components/orb.h"
|
||||||
|
#include "content.h"
|
||||||
|
|
||||||
using namespace TL;
|
using namespace TL;
|
||||||
|
|
||||||
@ -60,6 +61,7 @@ Entity* Factory::pop(World* world, Point position)
|
|||||||
auto anim = en->add(Animator("pop"));
|
auto anim = en->add(Animator("pop"));
|
||||||
anim->play("pop");
|
anim->play("pop");
|
||||||
anim->depth = -20;
|
anim->depth = -20;
|
||||||
|
Sound::play(Content::find_audio("explosion.wav"));
|
||||||
|
|
||||||
auto timer = en->add(Timer(anim->animation()->duration(), [](Timer* self)
|
auto timer = en->add(Timer(anim->animation()->duration(), [](Timer* self)
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,8 @@ void Game::startup()
|
|||||||
load_room(Point(0, 0));
|
load_room(Point(0, 0));
|
||||||
camera = Vec2f(room.x * width, room.y * height);
|
camera = Vec2f(room.x * width, room.y * height);
|
||||||
fullscreen = false;
|
fullscreen = false;
|
||||||
|
|
||||||
|
Music::play(Content::find_audio("melody2_forest.ogg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::load_room(Point cell, bool is_reload)
|
void Game::load_room(Point cell, bool is_reload)
|
||||||
@ -180,10 +182,6 @@ void Game::update()
|
|||||||
camera = Vec2f(0, 0);
|
camera = Vec2f(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle Fullscreen
|
|
||||||
if (Input::pressed(Key::F4))
|
|
||||||
App::fullscreen(fullscreen = !fullscreen);
|
|
||||||
|
|
||||||
// Normal Update
|
// Normal Update
|
||||||
if (!m_transition)
|
if (!m_transition)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user