mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 11:06:44 +01:00
implement voice reading intro
This commit is contained in:
parent
4b8bd024d7
commit
e5a9f12358
3 changed files with 21 additions and 1 deletions
16
src/intro.c
16
src/intro.c
|
@ -24,6 +24,14 @@
|
|||
#include "map.h"
|
||||
|
||||
void FillPage(struct Game *game, int page) {
|
||||
char filename[30] = { };
|
||||
sprintf(filename, "data/intro/%d.flac", page);
|
||||
|
||||
//if (game->intro.audiostream) al_destroy_audio_stream(game->intro.audiostream);
|
||||
game->intro.audiostream = al_load_audio_stream(filename, 4, 1024);
|
||||
al_attach_audio_stream_to_mixer(game->intro.audiostream, al_get_default_mixer());
|
||||
al_set_audio_stream_playing(game->intro.audiostream, false);
|
||||
al_set_audio_stream_gain(game->intro.audiostream, 1.75);
|
||||
|
||||
al_set_target_bitmap(game->intro.table);
|
||||
float y = 0.2;
|
||||
|
@ -114,6 +122,7 @@ void Intro_Draw(struct Game *game) {
|
|||
game->intro.in_animation = false;
|
||||
FillPage(game, game->intro.page+1);
|
||||
PrintConsole(game, "Animation finished.");
|
||||
al_set_audio_stream_playing(game->intro.audiostream, true);
|
||||
}
|
||||
else if (game->intro.position<=-4*al_get_display_width(game->display)) {
|
||||
PrintConsole(game, "This was the last page.");
|
||||
|
@ -135,6 +144,7 @@ void Intro_Load(struct Game *game) {
|
|||
DrawConsole(game);
|
||||
al_flip_display();
|
||||
}
|
||||
al_set_audio_stream_playing(game->intro.audiostream, true);
|
||||
Intro_Draw(game);
|
||||
}
|
||||
|
||||
|
@ -147,6 +157,10 @@ int Intro_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
|||
return 0;
|
||||
}
|
||||
if (!game->intro.in_animation) {
|
||||
if (game->intro.audiostream) {
|
||||
al_destroy_audio_stream(game->intro.audiostream);
|
||||
game->intro.audiostream=NULL;
|
||||
}
|
||||
PrintConsole(game, "Animate page (was on %d)...", ++game->intro.page);
|
||||
game->intro.in_animation = true;
|
||||
}
|
||||
|
@ -154,6 +168,7 @@ int Intro_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
|||
}
|
||||
|
||||
void Intro_Preload(struct Game *game) {
|
||||
game->intro.audiostream = NULL;
|
||||
game->intro.position = 0;
|
||||
game->intro.page = 0;
|
||||
game->intro.in_animation = false;
|
||||
|
@ -177,6 +192,7 @@ void Intro_Preload(struct Game *game) {
|
|||
}
|
||||
|
||||
void Intro_Unload(struct Game *game) {
|
||||
if (game->intro.audiostream) al_destroy_audio_stream(game->intro.audiostream);
|
||||
ALLEGRO_EVENT ev;
|
||||
int fadeloop;
|
||||
for(fadeloop=255; fadeloop>=0; fadeloop-=tps(game, 600)){
|
||||
|
|
|
@ -337,6 +337,9 @@ int main(int argc, char **argv){
|
|||
return -1;
|
||||
}
|
||||
|
||||
//game->voice = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, 48 ALLEGRO_CHANNEL_CONF_2);
|
||||
//game->fxmixer = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, 57 ALLEGRO_CHANNEL_CONF_2);
|
||||
|
||||
al_register_event_source(game.event_queue, al_get_display_event_source(game.display));
|
||||
al_register_event_source(game.event_queue, al_get_timer_event_source(game.timer));
|
||||
al_register_event_source(game.event_queue, al_get_keyboard_event_source());
|
||||
|
|
|
@ -133,6 +133,7 @@ struct Intro {
|
|||
ALLEGRO_BITMAP *table_bitmap;
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_SAMPLE *sample;
|
||||
ALLEGRO_AUDIO_STREAM *audiostream;
|
||||
};
|
||||
|
||||
/*! \brief Resources used by Game state. */
|
||||
|
|
Loading…
Reference in a new issue