From cd3b533c6b1ec6581a2bad7c1b9daf980c6854a7 Mon Sep 17 00:00:00 2001 From: alpine Date: Wed, 31 Dec 2014 00:32:03 +0000 Subject: [PATCH] Heliothryx game update - added pause menu (Esc) - lowest frame rate limit decreased downto 5 fps git-svn-id: svn://kolibrios.org@5310 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../games/heliothryx/game/rs/rsplatform_kos.c | 2 +- programs/games/heliothryx/game/rsgame.c | 60 ++++++++++++++----- programs/games/heliothryx/game/rsgamelogic.c | 4 +- programs/games/heliothryx/game/rsgamemenu.c | 20 ++++++- programs/games/heliothryx/game/rsgamemenu.h | 4 +- programs/games/heliothryx/game/strings.h | 2 +- programs/games/heliothryx/game/strings_en.h | 5 +- programs/games/heliothryx/game/strings_ru.h | 4 ++ 8 files changed, 78 insertions(+), 23 deletions(-) diff --git a/programs/games/heliothryx/game/rs/rsplatform_kos.c b/programs/games/heliothryx/game/rs/rsplatform_kos.c index 4bd57960dc..621ed75893 100644 --- a/programs/games/heliothryx/game/rs/rsplatform_kos.c +++ b/programs/games/heliothryx/game/rs/rsplatform_kos.c @@ -250,7 +250,7 @@ void kol_main() }; kol_sleep(wait_time); - if (draw_dt > 10) { + if (draw_dt > 19) { low_performance_counter++; } else { diff --git a/programs/games/heliothryx/game/rsgame.c b/programs/games/heliothryx/game/rsgame.c index 73caff60dd..541a3d71f7 100755 --- a/programs/games/heliothryx/game/rsgame.c +++ b/programs/games/heliothryx/game/rsgame.c @@ -204,7 +204,7 @@ void soundbuf_fill(rs_soundbuf_t *snd, int amp, int freq_div) { void soundbuf_sin(rs_soundbuf_t *snd, float freq) { int i; - int amp = 29000; + int amp = 19000; for (i = 0; i < snd->length_samples; i++) { snd->data[i] = ( 1.0 - 1.0*i/snd->length_samples ) * sin(freq*i) * amp; }; @@ -213,7 +213,7 @@ void soundbuf_sin(rs_soundbuf_t *snd, float freq) { void soundbuf_sin_fade(rs_soundbuf_t *snd, float freq) { int i; - int amp = 29000; + int amp = 19000; for (i = 0; i < snd->length_samples; i++) { snd->data[i] = ( 1.0 - 1.0*i/snd->length_samples ) * sin( ( (1.0 - 0.48*i/snd->length_samples) * freq ) *i) * amp; }; @@ -517,9 +517,32 @@ void GameInit() { rs_audio_init(RS_AUDIO_FMT_MONO16, RS_AUDIO_FREQ_16000, 2); #endif - soundbuf_init(&game.sound_test1, 2048); + soundbuf_init(&game.sound_test1, 1536); // soundbuf_fill(&game.sound_test1, 2, 50); - soundbuf_sin_fade(&game.sound_test1, 0.7); +// soundbuf_sin_fade(&game.sound_test1, 0.7); + + + rs_sgen_init(2, game.sound_test1.length_samples); + rs_sgen_func_pm(1, 2900.0, 1.70, 65.0, 17.0, 1.0); + rs_sgen_func_normalize(1, 0.6); +// rs_sgen_func_lowpass(0, 1, 1.0, 0.0, 4.0); + rs_sgen_func_highpass(0, 1, 1.0, 0.0, 3.0); + + rs_sgen_wave_out(0); + + memcpy(game.sound_test1.data, (unsigned char*) rs_sgen_reg.wave_out, game.sound_test1.length_samples*2 ); + + rs_sgen_term(); + soundbuf_update(&game.sound_test1); + + + + + + + + + soundbuf_init(&game.sound_test2, 1024); //soundbuf_fill(&game.sound_test2, 8, 40); @@ -549,7 +572,7 @@ void GameInit() { rs_sgen_func_normalize(0, 1.0); rs_sgen_func_lowpass(2, 0, 0.6, 0.0, 20.0); - rs_sgen_func_normalize(2, 0.7); + rs_sgen_func_normalize(2, 0.5); rs_sgen_wave_out(2); @@ -571,7 +594,7 @@ void GameInit() { rs_sgen_func_normalize(0, 1.0); rs_sgen_func_highpass(2, 0, 1.0, 0.3, 20.0); - rs_sgen_func_normalize(2, 0.6); + rs_sgen_func_normalize(2, 0.5); rs_sgen_wave_out(2); @@ -722,13 +745,14 @@ void GameKeyDown(int key) { // soundbuf_play( &game.sound_music, SND_MODE_LOOP ); // break; -// #ifdef RS_LINUX -// -// case RS_KEY_Z: -// soundbuf_play( &game.sound_music2, 0 ); -// break; -// -// #endif + #ifdef RS_LINUX + + case RS_KEY_Z: + soundbuf_stop( &game.sound_music ); + soundbuf_play( &game.sound_music2, 0 ); + break; + + #endif @@ -771,7 +795,13 @@ void GameKeyDown(int key) { menu_cursor_click(); break; case RS_KEY_ESCAPE: - menu_open(0); + if (game.menu_index != MENU_PAUSE) { + menu_open(0); + } + else { + game.status = STATUS_PLAYING; + return; + }; break; }; @@ -782,7 +812,7 @@ void GameKeyDown(int key) { case RS_KEY_ESCAPE: game.status = STATUS_MENU; - menu_open(0); + menu_open(MENU_PAUSE); break; case RS_KEY_SPACE: diff --git a/programs/games/heliothryx/game/rsgamelogic.c b/programs/games/heliothryx/game/rsgamelogic.c index 0f7cbc18eb..ed991e1dd7 100644 --- a/programs/games/heliothryx/game/rsgamelogic.c +++ b/programs/games/heliothryx/game/rsgamelogic.c @@ -95,7 +95,6 @@ void player_hit() { if (game.health < 1) { game.status = STATUS_MENU; - soundbuf_play( &game.sound_music, SND_MODE_LOOP ); menu_open( MENU_GAME_OVER ); }; @@ -276,7 +275,6 @@ void GameProcess() { else if (game.stage == 10) { game.status = STATUS_MENU; - soundbuf_play( &game.sound_music, SND_MODE_LOOP ); menu_open( MENU_LEVEL_PASSED ); level_passed_score_str[1] = '0' + (game.score / 100) % 10; @@ -419,7 +417,7 @@ void GameProcess() { game_draw(); - if (game.status == STATUS_MENU) { + if ( (game.status == STATUS_MENU) && (game.menu_index != MENU_PAUSE) ) { soundbuf_loop_check( &game.sound_music ); }; diff --git a/programs/games/heliothryx/game/rsgamemenu.c b/programs/games/heliothryx/game/rsgamemenu.c index 3ecee4b2e6..c53f6df9d3 100644 --- a/programs/games/heliothryx/game/rsgamemenu.c +++ b/programs/games/heliothryx/game/rsgamemenu.c @@ -10,7 +10,7 @@ PRSFUNC0 menu_actions[] = { /* a */ &menu_action_start, /* b */ &menu_action_exit, /* c */ &menu_action_change_window_scale, -// /* d */ &menu_action_ + /* d */ &menu_action_resume }; char window_scale_str[] = "c< 2X >"; @@ -67,6 +67,13 @@ char* menu_game_over_titles[] = { 0 }; +char* menu_pause_titles[] = { + " "L_PAUSE, + " ", + "d"L_RESUME, + "0"L_EXIT_TO_MAIN_MENU, + 0 +}; char **menu_titles[] = { @@ -75,6 +82,7 @@ char **menu_titles[] = { /* 2 */ menu_about_titles, /* 3 */ menu_level_passed_titles, /* 4 */ menu_game_over_titles, + /* 5 */ menu_pause_titles, 0 }; @@ -104,6 +112,10 @@ void menu_cursor_up() { }; void menu_open(int i) { + + if ( (game.menu_index == MENU_PAUSE) && (i != MENU_PAUSE) ){ + soundbuf_play( &game.sound_music, SND_MODE_LOOP ); + }; game.menu_index = i; @@ -176,3 +188,9 @@ void menu_action_exit() { void menu_action_change_window_scale() { game_change_window_scale(1); }; + +void menu_action_resume() { + + game.status = STATUS_PLAYING; + +}; diff --git a/programs/games/heliothryx/game/rsgamemenu.h b/programs/games/heliothryx/game/rsgamemenu.h index 918da2cd76..7451181b21 100644 --- a/programs/games/heliothryx/game/rsgamemenu.h +++ b/programs/games/heliothryx/game/rsgamemenu.h @@ -5,13 +5,14 @@ #include "rs/rsplatform.h" -#define MENUS_COUNT 5 +#define MENUS_COUNT 6 #define MENU_MAIN 0 #define MENU_SETTINGS 1 #define MENU_ABOUT 2 #define MENU_LEVEL_PASSED 3 #define MENU_GAME_OVER 4 +#define MENU_PAUSE 5 #define MENU_ITEM_WINDOW_SCALE 1 @@ -32,5 +33,6 @@ void menu_cursor_click(); void menu_action_start(); void menu_action_exit(); void menu_action_change_window_scale(); +void menu_action_resume(); #endif diff --git a/programs/games/heliothryx/game/strings.h b/programs/games/heliothryx/game/strings.h index a7d966ffa3..46fadea45f 100644 --- a/programs/games/heliothryx/game/strings.h +++ b/programs/games/heliothryx/game/strings.h @@ -2,7 +2,7 @@ #define RS_STRINGS_H #ifndef RS_KOS - #include "strings_en.h" + #include "strings_ru.h" #else //#include "../lang.h" diff --git a/programs/games/heliothryx/game/strings_en.h b/programs/games/heliothryx/game/strings_en.h index 1da774cad0..863cfad3d4 100644 --- a/programs/games/heliothryx/game/strings_en.h +++ b/programs/games/heliothryx/game/strings_en.h @@ -28,9 +28,12 @@ //#define L_TECHDEMO_LINE1 "THI5 I5 TECHDEM0` " #define L_TECHDEMO_LINE1 "U5E ARR0W5 T0 M0VE_ T0 5H00T_ T0 EXIT` " +#define L_GAME_OVER "GAME 0VER" #define L_LEVEL_PASSED "DEM0=LEVEL PA55ED" #define L_YOUR_SCORE "Y0UR 5C0RE:" -#define L_GAME_OVER "GAME 0VER" +#define L_PAUSE "PAU5E" +#define L_RESUME "RE5UME PLAYING" +#define L_EXIT_TO_MAIN_MENU "EXIT T0 MAIN MENU" #endif diff --git a/programs/games/heliothryx/game/strings_ru.h b/programs/games/heliothryx/game/strings_ru.h index 2391e1d9b9..be6e2b2e52 100644 --- a/programs/games/heliothryx/game/strings_ru.h +++ b/programs/games/heliothryx/game/strings_ru.h @@ -32,4 +32,8 @@ #define L_YOUR_SCORE "04K0B HAbPAH0:" #define L_GAME_OVER "igPA 0K0H4EHA" +#define L_PAUSE "nAY3A" +#define L_RESUME "nP0d0ljiT]" +#define L_EXIT_TO_MAIN_MENU "B\\^Ti B glABH0E MEHk" + #endif