forked from KolibriOS/kolibrios
Heliothryx game update
- added some sounds - added visual damage effect on player hit git-svn-id: svn://kolibrios.org@5298 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2f1fab6ff3
commit
a2cfd98d12
@ -15,7 +15,7 @@ then C_LANG = "LANG_SP" -- just for example, other languages are not implemented
|
|||||||
else C_LANG = "LANG_EN" -- default language is English
|
else C_LANG = "LANG_EN" -- default language is English
|
||||||
end
|
end
|
||||||
|
|
||||||
CFLAGS = CFLAGS .. " -DRS_KOS -D" .. C_LANG .. " "
|
CFLAGS = CFLAGS .. " -Werror=implicit -DRS_KOS -D" .. C_LANG .. " "
|
||||||
|
|
||||||
compile_gcc{ "system/kolibri.c", "game/rs/rsmicrolibc.c", "game/rs/rsplatform_kos.c", "game/rs/rsmx.c", "game/rsnoise.c", "game/rsgentex.c", "game/rsgame.c", "game/rsgamedraw.c", "game/rsgamelogic.c", "game/rskos.c", "game/rsgametext.c", "game/rsgamemenu.c"}
|
compile_gcc{ "system/kolibri.c", "game/rs/rsmicrolibc.c", "game/rs/rsplatform_kos.c", "game/rs/rsmx.c", "game/rsnoise.c", "game/rsgentex.c", "game/rssoundgen.c", "game/rsgame.c", "game/rsgamedraw.c", "game/rsgamelogic.c", "game/rskos.c", "game/rsgametext.c", "game/rsgamemenu.c"}
|
||||||
link_gcc ("heliothryx")
|
link_gcc ("heliothryx")
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "rsplatform.h"
|
#include "rsplatform.h"
|
||||||
|
|
||||||
|
#include "../rsgame.h"
|
||||||
|
|
||||||
rs_app_t rs_app;
|
rs_app_t rs_app;
|
||||||
|
|
||||||
|
|
||||||
@ -186,7 +188,7 @@ void kol_main()
|
|||||||
if (!logic_halted) {
|
if (!logic_halted) {
|
||||||
|
|
||||||
if (key_up) {
|
if (key_up) {
|
||||||
GameKeyUp(key, 1);
|
GameKeyUp(key);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GameKeyDown(key);
|
GameKeyDown(key);
|
||||||
|
@ -185,6 +185,10 @@ void soundbuf_init(rs_soundbuf_t *snd, int length_samples) {
|
|||||||
rskos_snd_create_buffer(&snd->hbuf, snd->data, length_samples);
|
rskos_snd_create_buffer(&snd->hbuf, snd->data, length_samples);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void soundbuf_update(rs_soundbuf_t *snd) {
|
||||||
|
rskos_snd_update_buffer(&snd->hbuf, snd->data, snd->length_samples);
|
||||||
|
};
|
||||||
|
|
||||||
void soundbuf_free(rs_soundbuf_t *snd) {
|
void soundbuf_free(rs_soundbuf_t *snd) {
|
||||||
snd->status = 0;
|
snd->status = 0;
|
||||||
free(snd->data);
|
free(snd->data);
|
||||||
@ -259,6 +263,8 @@ void game_reg_init() {
|
|||||||
game.player_y = 0;
|
game.player_y = 0;
|
||||||
game.tz = 0;
|
game.tz = 0;
|
||||||
|
|
||||||
|
game.bg_color = COLOR_BLACK;
|
||||||
|
|
||||||
// int i;
|
// int i;
|
||||||
// for (i = 0; i < BULLETS_COUNT; i++) {
|
// for (i = 0; i < BULLETS_COUNT; i++) {
|
||||||
// game.bullet_x[i] = 0;
|
// game.bullet_x[i] = 0;
|
||||||
@ -520,6 +526,56 @@ void GameInit() {
|
|||||||
soundbuf_sin(&game.sound_test3, 0.24);
|
soundbuf_sin(&game.sound_test3, 0.24);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int soundlen = 55000;
|
||||||
|
|
||||||
|
// int freqs[SOUND_EXPLOSIONS_COUNT] = { 440, 523, 587, 698, 783, 880, 1046, 1174 };
|
||||||
|
|
||||||
|
for (i = 0; i < SOUND_EXPLOSIONS_COUNT; i++) {
|
||||||
|
|
||||||
|
soundbuf_init(&game.sound_explosions[i], soundlen);
|
||||||
|
|
||||||
|
rs_sgen_init(3, soundlen);
|
||||||
|
|
||||||
|
rs_sgen_func_noise(2, 1000);
|
||||||
|
//rs_sgen_func_phaser(0, 2, 0.9, 15.2 + 1.0*i/SOUND_EXPLOSIONS_COUNT, 6.0, 3.0, 2000.0, 1.73);
|
||||||
|
rs_sgen_func_phaser(0, 2, 0.9, 16.2 + 0.5*i/SOUND_EXPLOSIONS_COUNT, 6.0, 3.0, 900.0, 0.93);
|
||||||
|
rs_sgen_func_normalize(0, 1.0);
|
||||||
|
|
||||||
|
rs_sgen_func_lowpass(2, 0, 0.6, 0.0, 20.0);
|
||||||
|
rs_sgen_func_normalize(2, 1.0);
|
||||||
|
|
||||||
|
rs_sgen_wave_out(2);
|
||||||
|
|
||||||
|
memcpy(game.sound_explosions[i].data, (unsigned char*) rs_sgen_reg.wave_out, soundlen*2);
|
||||||
|
soundbuf_update(&game.sound_explosions[i]);
|
||||||
|
|
||||||
|
rs_sgen_term();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
soundlen = 17888;
|
||||||
|
|
||||||
|
soundbuf_init(&game.sound_hit, soundlen);
|
||||||
|
|
||||||
|
rs_sgen_init(3, soundlen);
|
||||||
|
|
||||||
|
rs_sgen_func_noise(2, 1000);
|
||||||
|
rs_sgen_func_phaser(0, 2, 0.9, 11.5, 16.0, 13.0, 1300.0, 1.93);
|
||||||
|
rs_sgen_func_normalize(0, 1.0);
|
||||||
|
|
||||||
|
rs_sgen_func_highpass(2, 0, 1.0, 0.3, 20.0);
|
||||||
|
rs_sgen_func_normalize(2, 1.0);
|
||||||
|
|
||||||
|
rs_sgen_wave_out(2);
|
||||||
|
|
||||||
|
memcpy(game.sound_hit.data, (unsigned char*) rs_sgen_reg.wave_out, soundlen*2);
|
||||||
|
soundbuf_update(&game.sound_hit);
|
||||||
|
|
||||||
|
rs_sgen_term();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -564,7 +620,7 @@ void GameTerm() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GameKeyDown(int key, int first) {
|
void GameKeyDown(int key) {
|
||||||
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@ -639,8 +695,9 @@ void GameKeyDown(int key, int first) {
|
|||||||
case RS_KEY_SPACE:
|
case RS_KEY_SPACE:
|
||||||
|
|
||||||
#ifdef RS_LINUX
|
#ifdef RS_LINUX
|
||||||
game.stage_timer = 0;
|
|
||||||
game.stage = 7;
|
soundbuf_play( &game.sound_hit );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//game_obj_add( game_obj( OBJ_EXPLOSION, 0, 0, 0, game.tx + 80, game.ty - 10, 0, 0.0 ) );
|
//game_obj_add( game_obj( OBJ_EXPLOSION, 0, 0, 0, game.tx + 80, game.ty - 10, 0, 0.0 ) );
|
||||||
|
@ -19,22 +19,12 @@
|
|||||||
|
|
||||||
#include "rskos.h"
|
#include "rskos.h"
|
||||||
#include "rs/rsplatform.h"
|
#include "rs/rsplatform.h"
|
||||||
//#include "rs/rstexture.h"
|
|
||||||
//#include "rs/rsshader.h"
|
|
||||||
//#include "rs/rsgl.h"
|
|
||||||
#include "rs/rsdebug.h"
|
#include "rs/rsdebug.h"
|
||||||
#include "rs/rsbits.h"
|
#include "rs/rsbits.h"
|
||||||
|
|
||||||
//#include "rs/rskeyboard.h"
|
#include "rsgamelogic.h"
|
||||||
|
|
||||||
//#include "rs/rsaudio.h"
|
|
||||||
|
|
||||||
//#include "rs/rsfile.h"
|
|
||||||
|
|
||||||
//#include "rs/rsvbo.h"
|
|
||||||
//#include "rs/rsfbo.h"
|
|
||||||
|
|
||||||
//#include "rs/rsthread.h"
|
|
||||||
|
|
||||||
#include "rs/rsmx.h"
|
#include "rs/rsmx.h"
|
||||||
|
|
||||||
@ -70,7 +60,7 @@ typedef union color_t {
|
|||||||
// for little-endian (ARGB)
|
// for little-endian (ARGB)
|
||||||
#define COLOR_BLACK 0xFF000000
|
#define COLOR_BLACK 0xFF000000
|
||||||
#define COLOR_TRANSPARENT 0x00000000
|
#define COLOR_TRANSPARENT 0x00000000
|
||||||
#define COLOR_DARK_RED 0xFF660000
|
#define COLOR_DARK_RED 0xFF401000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -174,6 +164,8 @@ void game_obj_remove(int index);
|
|||||||
|
|
||||||
#define GAME_FLAG_BOSS_DESTROYED 0x01
|
#define GAME_FLAG_BOSS_DESTROYED 0x01
|
||||||
|
|
||||||
|
#define SOUND_EXPLOSIONS_COUNT 8
|
||||||
|
|
||||||
typedef struct rs_game_t {
|
typedef struct rs_game_t {
|
||||||
rs_texture_t framebuffer;
|
rs_texture_t framebuffer;
|
||||||
unsigned char *scaled_framebuffer; // 24-bit BGRBGRBGR... for direct drawing
|
unsigned char *scaled_framebuffer; // 24-bit BGRBGRBGR... for direct drawing
|
||||||
@ -193,11 +185,15 @@ typedef struct rs_game_t {
|
|||||||
|
|
||||||
rs_texture_t tex_gui_line;
|
rs_texture_t tex_gui_line;
|
||||||
|
|
||||||
|
int bg_color;
|
||||||
|
|
||||||
rs_soundbuf_t sound_test1;
|
rs_soundbuf_t sound_test1;
|
||||||
rs_soundbuf_t sound_test2;
|
rs_soundbuf_t sound_test2;
|
||||||
rs_soundbuf_t sound_test3;
|
rs_soundbuf_t sound_test3;
|
||||||
|
|
||||||
|
rs_soundbuf_t sound_explosions[SOUND_EXPLOSIONS_COUNT];
|
||||||
|
rs_soundbuf_t sound_hit;
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
@ -243,6 +239,14 @@ typedef struct rs_game_t {
|
|||||||
extern rs_game_t game;
|
extern rs_game_t game;
|
||||||
void game_reg_init();
|
void game_reg_init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* __
|
/* __
|
||||||
/cc\
|
/cc\
|
||||||
/aaaa\
|
/aaaa\
|
||||||
@ -251,12 +255,19 @@ void game_reg_init();
|
|||||||
------------------------------- */
|
------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void game_ding(int i);
|
void game_ding(int i);
|
||||||
|
|
||||||
void GameInit();
|
void GameInit();
|
||||||
void GameTerm();
|
void GameTerm();
|
||||||
|
|
||||||
void GameKeyDown(int key, int first);
|
void GameKeyDown(int key);
|
||||||
void GameKeyUp(int key);
|
void GameKeyUp(int key);
|
||||||
|
|
||||||
void GameMouseDown(int x, int y);
|
void GameMouseDown(int x, int y);
|
||||||
|
@ -28,7 +28,10 @@ void game_draw() {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
|
|
||||||
texture_clear(&game.framebuffer, COLOR_BLACK);
|
texture_clear(&game.framebuffer, game.bg_color );
|
||||||
|
|
||||||
|
game.bg_color = COLOR_BLACK;
|
||||||
|
|
||||||
// texture_clear(&game.tex);
|
// texture_clear(&game.tex);
|
||||||
|
|
||||||
// texture_draw(&game.framebuffer, &game.tex, 40, 40, DRAW_MODE_ADDITIVE);
|
// texture_draw(&game.framebuffer, &game.tex, 40, 40, DRAW_MODE_ADDITIVE);
|
||||||
|
@ -88,6 +88,9 @@ int check_collision_with_player(int obj1) {
|
|||||||
void player_hit() {
|
void player_hit() {
|
||||||
|
|
||||||
game.health--;
|
game.health--;
|
||||||
|
game.bg_color = COLOR_DARK_RED;
|
||||||
|
|
||||||
|
soundbuf_play( &game.sound_hit );
|
||||||
|
|
||||||
|
|
||||||
if (game.health < 1) {
|
if (game.health < 1) {
|
||||||
@ -400,6 +403,7 @@ void GameProcess() {
|
|||||||
|
|
||||||
for (i = 0; i < game.objs_count; i++) {
|
for (i = 0; i < game.objs_count; i++) {
|
||||||
if ( IS_BIT_SET( game.objs[i].flags, OBJ_FLAG_DESTROYED ) ) {
|
if ( IS_BIT_SET( game.objs[i].flags, OBJ_FLAG_DESTROYED ) ) {
|
||||||
|
soundbuf_play( &game.sound_explosions[ rs_rand() % SOUND_EXPLOSIONS_COUNT ] );
|
||||||
game_obj_add( game_obj( OBJ_EXPLOSION, 0, 0, EXPLOSION_RADIUS, game.objs[i].x, game.objs[i].y, 0, 0.0 ) );
|
game_obj_add( game_obj( OBJ_EXPLOSION, 0, 0, EXPLOSION_RADIUS, game.objs[i].x, game.objs[i].y, 0, 0.0 ) );
|
||||||
game_obj_remove(i);
|
game_obj_remove(i);
|
||||||
i--;
|
i--;
|
||||||
|
@ -160,6 +160,8 @@ void menu_action_start() {
|
|||||||
|
|
||||||
game.objs_count = 0;
|
game.objs_count = 0;
|
||||||
|
|
||||||
|
game.bg_color = COLOR_BLACK;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void menu_action_exit() {
|
void menu_action_exit() {
|
||||||
|
Loading…
Reference in New Issue
Block a user