if (result != 0) {
newAnim->push_anim(std::move(seqAnim));
anims.push_anim(std::move(newAnim));
+ } else {
+ newAnim->set_end_callback(
+ [](void *ud) {
+ auto *sfx = (Sound *)ud;
+ PlaySound(*sfx);
+ },
+ get_random_draw_sfx());
+ anims.push_anim(std::move(newAnim));
}
newAnim = std::make_unique<AnimConcurrent>(nullptr);
rock_sfx.at(1) = LoadSound("resources/sfx_rock1.ogg");
rock_sfx.at(2) = LoadSound("resources/sfx_rock2.ogg");
rock_sfx.at(3) = LoadSound("resources/sfx_rock3.ogg");
+
+ draw_sfx.at(0) = LoadSound("resources/sfx_draw0.ogg");
+ draw_sfx.at(1) = LoadSound("resources/sfx_draw1.ogg");
+ draw_sfx.at(2) = LoadSound("resources/sfx_draw2.ogg");
}
}
#endif
}
+Sound *Renderer3D::get_random_draw_sfx() {
+#ifdef __EMSCRIPTEN__
+ return &draw_sfx.at(call_js_get_random() * draw_sfx.size());
+#else
+ return &draw_sfx.at(GetRandomValue(0, draw_sfx.size() - 1));
+#endif
+}
+
Sound *Renderer3D::type_to_sfx(char type) {
switch (type) {
case 'r':
Sound *get_random_rock_sfx();
Sound *get_random_paper_sfx();
Sound *get_random_scissors_sfx();
+ Sound *get_random_draw_sfx();
Sound *type_to_sfx(char type);
std::array<Sound, 5> paper_sfx;
std::array<Sound, 5> scissors_sfx;
std::array<Sound, 4> rock_sfx;
+ std::array<Sound, 3> draw_sfx;
AnimSequence anims;