Some sound fixes (allow more than one composition) and death screen handling

This commit is contained in:
stevenhowes
2021-03-28 18:27:00 +01:00
parent 5e6601f38c
commit 7b1e9a0a6b
5 changed files with 106 additions and 29 deletions
Binary file not shown.
BIN
View File
Binary file not shown.
+12 -10
View File
@@ -21,6 +21,7 @@ int lasttick = 0;
extern int screen;
extern int game1_tick();
extern void game1_setup();
int game_hitbox_collide(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
{
@@ -35,26 +36,27 @@ int game_hitbox_collide(int x1, int y1, int w1, int h1, int x2, int y2, int w2,
int main(int argc, char *argv[])
{
int lastoutcome = 0;
sound_on();
// Set initial display mode
display_mode(DISPLAY_MODE);
screen_clear();
// Load sprite library
load_sprites("Spr");
// Intro titles + music
intro();
display_mode(DISPLAY_MODE);
screen_clear();
game_setup();
while(game1_tick());
screen_clear();
printf("you ded\n");
screen_flipbuffer();
// Mission 1
game1_setup();
while(!lastoutcome)
{
lastoutcome = game1_tick();
}
free(buffer);
+92 -19
View File
@@ -782,7 +782,7 @@ void game_draw_hud()
draw_sprite("pointer",141+(Player.remainingdistance/7500),DISPLAY_Y - 164 + 4);
}
void game_setup()
void game1_setup()
{
game_setup_input();
game_setup_audio();
@@ -816,6 +816,73 @@ void game_tick_player()
}
}
void game1_death()
{
int currentstart = 0;
int introframe = 0;
sound_voices(4);
sound_set_voice(1,"WaveSynth-Beep");
sound_set_voice(2,"WaveSynth-Beep");
sound_set_voice(3,"WaveSynth-Beep");
sound_set_voice(4,"WaveSynth-Beep");
sound_composition_init();
currentstart += 100;
sound_composition_element_add(currentstart,1,sound_note("D2"),150);
currentstart += 100;
sound_composition_element_add(currentstart,2,sound_note("G2"),200);
currentstart += 200;
sound_composition_element_add(currentstart,3,sound_note("B3"),75);
currentstart += 40;
sound_composition_element_add(currentstart,4,sound_note("G2"),75);
currentstart += 50;
sound_composition_element_add(currentstart,2,sound_note("B3"),200);
currentstart += 200;
sound_composition_element_add(currentstart,1,sound_note("A3"),100);
currentstart += 100;
sound_composition_element_add(currentstart,3,sound_note("G2"),150);
currentstart += 150;
sound_composition_element_add(currentstart,2,sound_note("E2"),100);
currentstart += 100;
sound_composition_element_add(currentstart,1,sound_note("D2"),150);
currentstart += 150;
sound_composition_element_add(currentstart,3,sound_note("D2"),150);
currentstart += 100;
sound_composition_element_add(currentstart,4,sound_note("G2"),150);
currentstart += 150;
sound_composition_element_add(currentstart,1,sound_note("B3"),75);
currentstart += 40;
sound_composition_element_add(currentstart,2,sound_note("G2"),75);
currentstart += 40;
sound_composition_element_add(currentstart,3,sound_note("B3"),150);
currentstart += 150;
sound_composition_element_add(currentstart,4,sound_note("A3"),130);
currentstart += 100;
sound_composition_element_add(currentstart,1,sound_note("G2"),200);
currentstart += 300;
tick = clock();
sound_composition_start(clock());
draw_sprite("spacebar",(DISPLAY_X/2)-106,50);
draw_sprite("kia",(DISPLAY_X/2)-300,500);
screen_flipbuffer();
while(sound_composition_incomplete())
{
sound_composition_tick(clock());
if(clock() > (tick + 200))
{
if(input_readkey(98))
sound_composition_stop();
}
}
}
int game1_tick()
{
lasttick = tick;
@@ -824,24 +891,30 @@ int game1_tick()
screen_flipbuffer();
screen_clear();
PROFILE(game_tick_stars());
PROFILE(game_tick_input());
PROFILE(game_tick_player());
PROFILE(game_tick_npcs());
PROFILE(game_tick_collider());
PROFILE(game_tick_player_targets());
PROFILE(game_tick_npcs());
PROFILE(game_tick_projectiles());
PROFILE(game_draw_stars());
PROFILE(game_draw_player());
PROFILE(game_draw_npcs());
PROFILE(game_draw_projectiles());
PROFILE(game_draw_hud());
PROFILE(game_draw_debugmenu());
if(Player.integrity > 0)
return 1;
else
{
PROFILE(game_tick_stars());
PROFILE(game_tick_input());
PROFILE(game_tick_player());
PROFILE(game_tick_npcs());
PROFILE(game_tick_collider());
PROFILE(game_tick_player_targets());
PROFILE(game_tick_npcs());
PROFILE(game_tick_projectiles());
PROFILE(game_draw_stars());
PROFILE(game_draw_player());
PROFILE(game_draw_npcs());
PROFILE(game_draw_projectiles());
PROFILE(game_draw_hud());
PROFILE(game_draw_debugmenu());
return 0;
}else{
screen_flipbuffer();
screen_clear();
game1_death();
return 1;
}
}
+2
View File
@@ -61,6 +61,7 @@ void sound_composition_init()
{
composition[i].Start = -1;
}
current_element = 0;
}
void sound_composition_element_add(int start, int channel, int note, int length)
@@ -101,6 +102,7 @@ void sound_composition_debug()
void sound_composition_start(int cent)
{
composition_startcent = cent;
current_playback_element = 0;
}
void sound_composition_stop()