Heliothryx game update

- added infinite gameplay stages with increasing difficulty



git-svn-id: svn://kolibrios.org@5315 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
alpine 2014-12-31 03:20:23 +00:00
parent 8c63bdcfea
commit 59876bd86b
8 changed files with 214 additions and 102 deletions

View File

@ -517,12 +517,9 @@ void GameInit() {
rs_audio_init(RS_AUDIO_FMT_MONO16, RS_AUDIO_FREQ_16000, 2);
#endif
soundbuf_init(&game.sound_test1, 1536);
// soundbuf_fill(&game.sound_test1, 2, 50);
// soundbuf_sin_fade(&game.sound_test1, 0.7);
rs_sgen_init(2, game.sound_test1.length_samples);
soundbuf_init(&game.sound_shoot, 1536);
rs_sgen_init(2, game.sound_shoot.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);
@ -530,15 +527,30 @@ void GameInit() {
rs_sgen_wave_out(0);
memcpy(game.sound_test1.data, (unsigned char*) rs_sgen_reg.wave_out, game.sound_test1.length_samples*2 );
memcpy(game.sound_shoot.data, (unsigned char*) rs_sgen_reg.wave_out, game.sound_shoot.length_samples*2 );
rs_sgen_term();
soundbuf_update(&game.sound_test1);
soundbuf_update(&game.sound_shoot);
soundbuf_init(&game.sound_turret_shoot, 4096);
rs_sgen_init(2, game.sound_turret_shoot.length_samples);
rs_sgen_func_pm(1, 227.0, 4.70, 555.0, 150.0, 0.01);
rs_sgen_func_normalize(1, 0.6);
// rs_sgen_func_highpass(0, 1, 1.0, 0.0, 3.0);
rs_sgen_func_lowpass(0, 1, 1.0, 0.0, 3.0);
rs_sgen_wave_out(0);
memcpy(game.sound_turret_shoot.data, (unsigned char*) rs_sgen_reg.wave_out, game.sound_turret_shoot.length_samples*2 );
rs_sgen_term();
soundbuf_update(&game.sound_turret_shoot);
@ -630,42 +642,42 @@ void GameInit() {
int d[4] = { 5, 6, 1, 2 };
// int d[4] = { 5, 6, 1, 2 };
soundbuf_init(&game.sound_music2, soundlen);
for (t = t_shift; t < soundlen+t_shift; t++) {
// y = 1 + (t & 16383);
// x = (t * c[ (t>>13) & 3 ] / 24) & 127;
game.sound_music2.data[t-t_shift] = (0xFF &
(
//( t*5 & t >> 7 ) | ( t*2 & t >> 10 )
// ( ((t*t*t/1000000 + t) % 127) | t>>4 | t>>5 | (t%127) ) + ( (t>>16) | t )
// ((t>>11) | (t>>7) | ( t>>5) | (t))
// //+
// //(( (t*5) >>12) & ( (t*3)>>19))
// (3000 / y) * 35
// + x*y*40000
// + ( ( ((t>>8) & (t>>10)) | (t >> 14) | x) & 63 )
// ( ((6 * t / d[ (t>>13) & 15 ] ) & 127) * 10000 )
//|( ( t>>3 ) )
(t*NOTE( d[ (t>>13) & 3 ] )*10000)
| ((t>>6)*20000)
)
) * amp;
};
soundbuf_update(&game.sound_music2);
// soundbuf_init(&game.sound_music2, soundlen);
//
// for (t = t_shift; t < soundlen+t_shift; t++) {
//
//// y = 1 + (t & 16383);
//// x = (t * c[ (t>>13) & 3 ] / 24) & 127;
//
// game.sound_music2.data[t-t_shift] = (0xFF &
// (
// //( t*5 & t >> 7 ) | ( t*2 & t >> 10 )
//
// // ( ((t*t*t/1000000 + t) % 127) | t>>4 | t>>5 | (t%127) ) + ( (t>>16) | t )
//
//// ((t>>11) | (t>>7) | ( t>>5) | (t))
//// //+
//// //(( (t*5) >>12) & ( (t*3)>>19))
//
//// (3000 / y) * 35
//// + x*y*40000
//// + ( ( ((t>>8) & (t>>10)) | (t >> 14) | x) & 63 )
//
// // ( ((6 * t / d[ (t>>13) & 15 ] ) & 127) * 10000 )
// //|( ( t>>3 ) )
//
// (t*NOTE( d[ (t>>13) & 3 ] )*10000)
// | ((t>>6)*20000)
//
// )
//
// ) * amp;
// };
//
// soundbuf_update(&game.sound_music2);
soundbuf_play( &game.sound_music, SND_MODE_LOOP );
@ -701,7 +713,16 @@ void GameTerm() {
texture_free(&game.tex_rocks[i]);
};
soundbuf_free(&game.sound_test1);
soundbuf_free(&game.sound_hit);
soundbuf_free(&game.sound_music);
for (i = 0; i < SOUND_EXPLOSIONS_COUNT; i++) {
soundbuf_free(&game.sound_explosions[i]);
};
soundbuf_free(&game.sound_shoot);
soundbuf_free(&game.sound_turret_shoot);
soundbuf_free(&game.sound_test2);
soundbuf_free(&game.sound_test3);
@ -741,15 +762,16 @@ void GameKeyDown(int key) {
// case RS_KEY_SPACE:
// soundbuf_play( &game.sound_music, SND_MODE_LOOP );
// break;
case RS_KEY_SPACE:
soundbuf_play( &game.sound_turret_shoot, 0 );
break;
#ifdef RS_LINUX
case RS_KEY_Z:
soundbuf_stop( &game.sound_music );
soundbuf_play( &game.sound_music2, 0 );
// soundbuf_stop( &game.sound_music );
// soundbuf_play( &game.sound_music2, 0 );
game.stage = 7;
break;
#endif

View File

@ -164,6 +164,7 @@ void game_obj_remove(int index);
#define GAME_SHOOT_PERIOD 3
#define GAME_FLAG_BOSS_DESTROYED 0x01
#define GAME_FLAG_INSTRUCTIONS_PASSED 0x02
#define SOUND_EXPLOSIONS_COUNT 8
@ -188,7 +189,9 @@ typedef struct rs_game_t {
int bg_color;
rs_soundbuf_t sound_test1;
rs_soundbuf_t sound_shoot;
rs_soundbuf_t sound_turret_shoot;
rs_soundbuf_t sound_test2;
rs_soundbuf_t sound_test3;
@ -196,7 +199,7 @@ typedef struct rs_game_t {
rs_soundbuf_t sound_hit;
rs_soundbuf_t sound_music;
rs_soundbuf_t sound_music2;
// rs_soundbuf_t sound_music2;
int status;
int flags;
@ -229,9 +232,11 @@ typedef struct rs_game_t {
// int ammo_max;
int stage;
int stage; // (wave)
int stage_timer;
int stage_level; // (stage)
game_obj_t *objs;
int objs_count;

View File

@ -148,20 +148,37 @@ void game_draw() {
if ( game.stage == 0 ) {
game_textout_at_center( 0, GAME_HEIGHT + 50 - game.stage_timer*(GAME_HEIGHT+50)/50, 1, "LEVEL 1" );
game_textout_at_center( 0, GAME_HEIGHT*2/3, 2, L_TECHDEMO_LINE1 );
int stage_label_y = GAME_HEIGHT/3 - (game.stage_timer - 25)*(game.stage_timer - 25)*(game.stage_timer - 25)/100;
//game_textout_at_center( 0, GAME_HEIGHT + 50 - game.stage_timer*(GAME_HEIGHT+50)/50, 1, "LEVEL 1" );
char stage_str[] = "5TAGE xx";
char *stage_num = &stage_str[6];
if ( (game.stage_level+1) > 9 ) {
stage_num[0] = '0' + (game.stage_level+1)/10;
stage_num[1] = '0' + (game.stage_level+1)%10;
}
else {
stage_num[0] = '0' + (game.stage_level+1)%10;
stage_num[1] = 0;
};
game_textout_at_center( -10, stage_label_y, 1, stage_str );
if ( IS_BIT_CLEARED ( game.flags, GAME_FLAG_INSTRUCTIONS_PASSED ) ) {
game_textout_at_center( 0, GAME_HEIGHT*3/4, 2, L_TECHDEMO_LINE1 );
};
}
else {
char s_score[] = "000";
s_score[0] += game.score / 100;
s_score[1] += (game.score / 10) % 10;
s_score[2] += (game.score / 1) % 10;
game_textout_at_center(0, 10, 3, s_score);
};
char s_score[] = "0000";
s_score[0] += (game.score / 1000) % 10;
s_score[1] += (game.score / 100) % 10;
s_score[2] += (game.score / 10) % 10;
s_score[3] += (game.score / 1) % 10;
game_textout_at_center(0, 10, 3, s_score);

View File

@ -96,6 +96,12 @@ void player_hit() {
if (game.health < 1) {
game.status = STATUS_MENU;
menu_open( MENU_GAME_OVER );
level_passed_score_str[1] = '0' + (game.score / 1000) % 10;
level_passed_score_str[2] = '0' + (game.score / 100) % 10;
level_passed_score_str[3] = '0' + (game.score / 10) % 10;
level_passed_score_str[4] = '0' + (game.score / 1) % 10;
};
};
@ -105,6 +111,9 @@ void GameProcess() {
if (game.status == STATUS_PLAYING) {
int c_shoot_restore_delay = (6 + 2*game.stage_level);
int c_shoot_restore_period = (game.stage_level < 2) ? (3 + game.stage_level) : 5;
// shoot
if ( ( (game.shoot_keypressed) || (is_key_pressed(RS_ATTACK_KEY_MASK)) ) && (game.ammo>0) ) {
@ -117,12 +126,15 @@ void GameProcess() {
game.shoot_restore_delay = 0;
game.ammo--;
soundbuf_play(&game.sound_test1, 0);
soundbuf_play(&game.sound_shoot, 0);
game_obj_add( game_obj( OBJ_BULLET, 0, 0, 0, game.player_x+5, game.player_y, 0, 0.0) );
// };
game.shoot_delay -= GAME_SHOOT_PERIOD;
game.shoot_delay = 1; // -= GAME_SHOOT_PERIOD;
game.shoot_keypressed = 0;
};
@ -132,13 +144,13 @@ void GameProcess() {
if (game.ammo < GAME_AMMO_MAX) {
game.shoot_restore_delay++;
if (game.shoot_restore_delay > GAME_SHOOT_PERIOD * 2) {
if (game.shoot_restore_delay > c_shoot_restore_delay) {
game.shoot_delay++;
if (game.shoot_delay > GAME_SHOOT_PERIOD) {
if (game.shoot_delay > c_shoot_restore_period) {
game.ammo++;
game.shoot_delay -= GAME_SHOOT_PERIOD;
game.shoot_delay -= c_shoot_restore_period;
};
};
@ -158,13 +170,15 @@ void GameProcess() {
game.player_x += speed * ( is_key_pressed(RS_ARROW_RIGHT_MASK) - is_key_pressed(RS_ARROW_LEFT_MASK) );
game.player_y += speed * ( is_key_pressed(RS_ARROW_DOWN_MASK) - is_key_pressed(RS_ARROW_UP_MASK) );
game.player_x = rs_clamp_i(game.player_x, 5, GAME_WIDTH-25);
game.player_y = rs_clamp_i(game.player_y, 5, GAME_HEIGHT - 25);
game.player_x = rs_clamp_i(game.player_x, 15, GAME_WIDTH - 45);
game.player_y = rs_clamp_i(game.player_y, 15, GAME_HEIGHT - 45);
game.tz += 1;
int c_rocktimer_const = (game.stage_level < 4) ? (9 - 2*game.stage_level) : 4;
int c_rocktimer_var = (game.stage_level < 6) ? (16 - 2*game.stage_level) : 6;
@ -185,9 +199,17 @@ void GameProcess() {
// rocks
next_rock_timer--;
if (next_rock_timer < 1) {
next_rock_timer = 9 + rs_rand()%16;
next_rock_timer = c_rocktimer_const + rs_rand()%c_rocktimer_var;
//game_obj_add( game_obj( ((rs_rand() % 512) > 256) ? OBJ_ROCK : OBJ_MINIROCK, 0, rs_rand() % ROCKS_COUNT , 32, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-60), 0, 0.0 ) );
game_obj_add( game_obj( OBJ_ROCK, OBJ_FLAG_ENEMY, rs_rand() % ROCKS_COUNT , game.tex_rocks[0].w/2, GAME_WIDTH + 50, 30 + rs_rand()%(GAME_HEIGHT-90), 0, 0.0 ) );
int flagsin = 0;
if ( game.stage_level > 4 ) {
if ( rs_rand()%1024 < (16*game.stage_level) ) {
flagsin = OBJ_FLAG_SIN;
};
};
game_obj_add( game_obj( OBJ_ROCK, OBJ_FLAG_ENEMY | flagsin, rs_rand() % ROCKS_COUNT , game.tex_rocks[0].w/2, GAME_WIDTH + 50, 30 + rs_rand()%(GAME_HEIGHT-90), 0, 0.0 ) );
};
next_stage_after_sec(12);
@ -195,6 +217,8 @@ void GameProcess() {
}
if (game.stage == 2) {
BIT_SET (game.flags, GAME_FLAG_INSTRUCTIONS_PASSED);
next_stage_after_sec(4);
@ -205,9 +229,17 @@ void GameProcess() {
// rocks
next_rock_timer--;
if (next_rock_timer < 1) {
next_rock_timer = 10 + rs_rand()%16;
next_rock_timer = c_rocktimer_const + 1 + rs_rand()%c_rocktimer_var;
//game_obj_add( game_obj( ((rs_rand() % 512) > 256) ? OBJ_ROCK : OBJ_MINIROCK, 0, rs_rand() % ROCKS_COUNT , 32, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-60), 0, 0.0 ) );
game_obj_add( game_obj( OBJ_MINIROCK, OBJ_FLAG_ENEMY, rs_rand() % ROCKS_COUNT , game.tex_minirocks[0].w/2, GAME_WIDTH + 50, 30 + rs_rand()%(GAME_HEIGHT-90), 0, 0.0 ) );
int flagsin = 0;
if ( game.stage_level > 2 ) {
if ( rs_rand()%1024 < (16*game.stage_level) ) {
flagsin = OBJ_FLAG_SIN;
};
};
game_obj_add( game_obj( OBJ_MINIROCK, OBJ_FLAG_ENEMY|flagsin, rs_rand() % ROCKS_COUNT , game.tex_minirocks[0].w/2, GAME_WIDTH + 50, 30 + rs_rand()%(GAME_HEIGHT-90), 0, 0.0 ) );
};
next_stage_after_sec(16);
@ -239,9 +271,17 @@ void GameProcess() {
// mix rocks
next_rock_timer--;
if (next_rock_timer < 1) {
next_rock_timer = 9 + rs_rand()%12;
next_rock_timer = c_rocktimer_const + rs_rand()%(c_rocktimer_var-3);
int flagsin = 0;
if ( game.stage_level > 3 ) {
if ( rs_rand()%1024 < (16*game.stage_level) ) {
flagsin = OBJ_FLAG_SIN;
};
};
//game_obj_add( game_obj( ((rs_rand() % 512) > 256) ? OBJ_ROCK : OBJ_MINIROCK, 0, rs_rand() % ROCKS_COUNT , 32, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-60), 0, 0.0 ) );
game_obj_add( game_obj( rs_rand()%1024 < 768 ? OBJ_MINIROCK : OBJ_ROCK, OBJ_FLAG_ENEMY, rs_rand() % ROCKS_COUNT ,
game_obj_add( game_obj( rs_rand()%1024 < 768 ? OBJ_MINIROCK : OBJ_ROCK, OBJ_FLAG_ENEMY | flagsin, rs_rand() % ROCKS_COUNT ,
rs_rand()%1024 < 768 ? game.tex_minirocks[0].w/2 : game.tex_rocks[0].w/2, GAME_WIDTH + 100, 30 + rs_rand()%(GAME_HEIGHT-90), 0, 0.0 ) );
};
@ -255,6 +295,8 @@ void GameProcess() {
if (game.stage_timer > 3*25) {
next_stage_now();
BIT_CLEAR(game.flags, GAME_FLAG_BOSS_DESTROYED);
game_obj_add( game_obj( OBJ_TURRET, OBJ_FLAG_ENEMY | OBJ_FLAG_BOSS, 60, game.tex_rocks[0].w/2, GAME_WIDTH+60, GAME_HEIGHT/2, 0, 0.0 ) );
};
@ -274,12 +316,19 @@ void GameProcess() {
}
else if (game.stage == 10) {
/*
game.status = STATUS_MENU;
menu_open( MENU_LEVEL_PASSED );
level_passed_score_str[1] = '0' + (game.score / 100) % 10;
level_passed_score_str[2] = '0' + (game.score / 10) % 10;
level_passed_score_str[3] = '0' + (game.score / 1) % 10;
*/
game.stage_level++;
game.stage = 0;
game.stage_timer = 0;
};
@ -389,10 +438,23 @@ void GameProcess() {
obj->y = GAME_HEIGHT * ( 0.5 + 0.3*sin(obj->f) );
};
obj->t--;
if (obj->t < 1) {
game_obj_add( game_obj( OBJ_RED_BULLET, 0, 0, 3, obj->x - 30, obj->y, 0, 0) );
obj->t = 10 + rs_rand() % 20;
if ( obj->x < GAME_WIDTH*4/5 ) {
// turret shoot
obj->t--;
if (obj->t < 1) {
soundbuf_play(&game.sound_turret_shoot, 0);
game_obj_add( game_obj( OBJ_RED_BULLET, 0, 0, 3, obj->x - 30, obj->y, 0, 0) );
int c_const = (game.stage_level < 4) ? (10 - 2*game.stage_level) : 3;
int c_var = (game.stage_level < 6) ? (20 - 3*game.stage_level) : 3;
obj->t = c_const + rs_rand() % c_var;
if ( (rs_rand()%1024) < 80 ) {
obj->t += 18;
};
};
};
};

View File

@ -14,7 +14,7 @@ PRSFUNC0 menu_actions[] = {
};
char window_scale_str[] = "c< 2X >";
char level_passed_score_str[] = " 000 ";
char level_passed_score_str[] = " 0000 ";
/*
First char:
@ -51,8 +51,8 @@ char* menu_about_titles[] = {
0
};
char* menu_level_passed_titles[] = {
" "L_LEVEL_PASSED,
char* menu_game_over_titles[] = {
" "L_GAME_OVER,
" "L_YOUR_SCORE,
level_passed_score_str,
" ",
@ -60,12 +60,12 @@ char* menu_level_passed_titles[] = {
0
};
char* menu_game_over_titles[] = {
" "L_GAME_OVER,
" ",
"0"L_BACK,
0
};
//char* menu_game_over_titles[] = {
// " "L_GAME_OVER,
// " ",
// "0"L_BACK,
// 0
//};
char* menu_pause_titles[] = {
" "L_PAUSE,
@ -80,9 +80,9 @@ char **menu_titles[] = {
/* 0 */ menu_main_titles,
/* 1 */ menu_settings_titles,
/* 2 */ menu_about_titles,
/* 3 */ menu_level_passed_titles,
/* 4 */ menu_game_over_titles,
/* 5 */ menu_pause_titles,
// /* 3 */ menu_level_passed_titles,
/* 3 */ menu_game_over_titles,
/* 4 */ menu_pause_titles,
0
};
@ -113,7 +113,7 @@ void menu_cursor_up() {
void menu_open(int i) {
if ( (game.menu_index == MENU_PAUSE) && (i != MENU_PAUSE) ){
if ( ((game.menu_index == MENU_PAUSE) && (i != MENU_PAUSE)) || (i == MENU_GAME_OVER) ) {
soundbuf_play( &game.sound_music, SND_MODE_LOOP );
};
@ -170,6 +170,8 @@ void menu_action_start() {
game.score = 0;
game.flags = 0;
game.stage_level = 0;
game.objs_count = 0;
game.bg_color = COLOR_BLACK;

View File

@ -5,14 +5,14 @@
#include "rs/rsplatform.h"
#define MENUS_COUNT 6
#define MENUS_COUNT 5
#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_LEVEL_PASSED 3
#define MENU_GAME_OVER 3
#define MENU_PAUSE 4
#define MENU_ITEM_WINDOW_SCALE 1

View File

@ -26,14 +26,16 @@
// Gameplay
//#define L_TECHDEMO_LINE1 "THI5 I5 TECHDEM0` "
#define L_TECHDEMO_LINE1 "U5E ARR0W5 T0 M0VE_ <A> T0 5H00T_ <E5C> T0 EXIT` "
#define L_TECHDEMO_LINE1 "U5E ARR0W5 T0 M0VE_ <A> T0 5H00T_ <E5C> T0 PAU5E "
#define L_GAME_OVER "GAME 0VER"
#define L_LEVEL_PASSED "DEM0=LEVEL PA55ED"
//#define L_LEVEL_PASSED "DEM0=LEVEL PA55ED"
#define L_YOUR_SCORE "Y0UR 5C0RE:"
#define L_PAUSE "PAU5E"
#define L_RESUME "RE5UME PLAYING"
#define L_EXIT_TO_MAIN_MENU "EXIT T0 MAIN MENU"
#define L_STAGE_TITLE "5TAGE xx"
#endif

View File

@ -26,9 +26,9 @@
// Gameplay
//#define L_TECHDEMO_LINE1 "eT0 TEXH0dEMKA` "
#define L_TECHDEMO_LINE1 "CTPElKi = dBijEHiE_ <A> = B\\CTPEl_ <E5C> = B\\X0d` "
#define L_TECHDEMO_LINE1 "CTPElKi = dBijEHiE_ <A> = B\\CTPEl_ <E5C> = nAY3A "
#define L_LEVEL_PASSED "dEM0=YP0BEH] nP0^dEH"
//#define L_LEVEL_PASSED "dEM0=YP0BEH] nP0^dEH"
#define L_YOUR_SCORE "04K0B HAbPAH0:"
#define L_GAME_OVER "igPA 0K0H4EHA"
@ -36,4 +36,6 @@
#define L_RESUME "nP0d0ljiT]"
#define L_EXIT_TO_MAIN_MENU "B\\^Ti B glABH0E MEHk"
#define L_STAGE_TITLE "YP0BEH] xx"
#endif