finished tutorial 7

This commit is contained in:
h4570
2022-08-23 22:31:07 +02:00
parent 9f831c7a6f
commit 989d2702e8
24 changed files with 439 additions and 25 deletions
+2
View File
@@ -24,6 +24,8 @@ class Tutorial06 : public Game {
private:
Engine* engine;
audsrv_adpcm_t* sample;
};
} // namespace Tyra
+25 -2
View File
@@ -17,8 +17,31 @@ Tutorial06::Tutorial06(Engine* t_engine) : engine(t_engine) {}
Tutorial06::~Tutorial06() {}
void Tutorial06::init() {}
void Tutorial06::init() {
/** 16bit 22kHz wav file */
engine->audio.song.load(FileUtils::fromCwd("kayah-supermenka.wav"));
engine->audio.song.inLoop = true;
engine->audio.song.setVolume(60);
engine->audio.song.play();
void Tutorial06::loop() {}
/** 16bit 22kHz wav file converted to adpcm sample */
sample = engine->audio.adpcm.load(FileUtils::fromCwd("shoot.adpcm"));
/** Set volume for channel 0 */
engine->audio.adpcm.setVolume(30, 0);
}
void Tutorial06::loop() {
engine->renderer.beginFrame();
{
/** Play ADPCM if (X) button is clicked! */
if (engine->pad.getClicked().Cross) {
/** Try to play sample in channel 0 */
if (engine->audio.adpcm.tryPlay(sample, 0) == ADPCM_CHANNEL_USED) {
TYRA_WARN("Channel is busy, please use another channel!");
}
}
}
engine->renderer.endFrame();
}
} // namespace Tyra