forked from KolibriOS/kolibrios
Heliothryx Game Update
- techdemo becomes playable game; - added demo-level. git-svn-id: svn://kolibrios.org@5291 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
09b127b67d
commit
1043a1aa9f
@ -17,5 +17,5 @@ end
|
|||||||
|
|
||||||
CFLAGS = CFLAGS .. " -DRS_KOS -D" .. C_LANG .. " "
|
CFLAGS = CFLAGS .. " -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/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/rsgame.c", "game/rsgamedraw.c", "game/rsgamelogic.c", "game/rskos.c", "game/rsgametext.c", "game/rsgamemenu.c"}
|
||||||
link_gcc ("heliothryx")
|
link_gcc ("heliothryx")
|
||||||
|
@ -28,6 +28,47 @@
|
|||||||
rs_game_t game;
|
rs_game_t game;
|
||||||
|
|
||||||
|
|
||||||
|
game_obj_t game_obj(int obj_type, int flags, int tag, int radius, float x, float y, int t, float f) {
|
||||||
|
game_obj_t obj;
|
||||||
|
obj.obj_type = obj_type;
|
||||||
|
obj.flags = flags;
|
||||||
|
obj.tag = tag;
|
||||||
|
obj.radius = radius;
|
||||||
|
obj.x = x;
|
||||||
|
obj.y = y;
|
||||||
|
obj.t = t;
|
||||||
|
obj.f = f;
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
int game_obj_add(game_obj_t obj) {
|
||||||
|
if (game.objs_count < GAME_OBJS_MAX_COUNT) {
|
||||||
|
game.objs[game.objs_count++] = obj;
|
||||||
|
return game.objs_count-1;
|
||||||
|
};
|
||||||
|
#ifdef RS_LINUX
|
||||||
|
DEBUG10("Error, max objects count is reached");
|
||||||
|
#endif
|
||||||
|
return 0; // Max objects count is reached
|
||||||
|
};
|
||||||
|
|
||||||
|
void game_obj_remove(int index) {
|
||||||
|
if (index == game.objs_count - 1) {
|
||||||
|
game.objs_count--;
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
game.objs[index] = game.objs[ game.objs_count-1 ];
|
||||||
|
game.objs_count--;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void texture_init(rs_texture_t *tex, int w, int h) {
|
void texture_init(rs_texture_t *tex, int w, int h) {
|
||||||
tex->status = 1;
|
tex->status = 1;
|
||||||
tex->w = w;
|
tex->w = w;
|
||||||
@ -121,6 +162,15 @@ void texture_draw_vline(rs_texture_t *tex, int x, int y, int l, unsigned int col
|
|||||||
if (y+l >= tex->h) {
|
if (y+l >= tex->h) {
|
||||||
l = tex->h - y;
|
l = tex->h - y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (x < 0) {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (x >= tex->w) {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
for (i = 0; i < l; i++) {
|
for (i = 0; i < l; i++) {
|
||||||
*((unsigned int*) &tex->data[ 4 * ( (y+i)*tex->w + (x) ) + 0 ]) = color;
|
*((unsigned int*) &tex->data[ 4 * ( (y+i)*tex->w + (x) ) + 0 ]) = color;
|
||||||
};
|
};
|
||||||
@ -201,16 +251,22 @@ unsigned char clamp_byte(int value) {
|
|||||||
|
|
||||||
|
|
||||||
void game_reg_init() {
|
void game_reg_init() {
|
||||||
game.tx = 0;
|
// game.tx = 0;
|
||||||
game.ty = 0;
|
// game.ty = 0;
|
||||||
|
// game.tz = 0;
|
||||||
|
|
||||||
|
game.player_x = 0;
|
||||||
|
game.player_y = 0;
|
||||||
game.tz = 0;
|
game.tz = 0;
|
||||||
|
|
||||||
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;
|
||||||
game.bullet_y[i] = 0;
|
// game.bullet_y[i] = 0;
|
||||||
};
|
// };
|
||||||
game.bullet_index = 0;
|
// game.bullet_index = 0;
|
||||||
|
|
||||||
|
game.objs = malloc( sizeof(game_obj_t) * GAME_OBJS_MAX_COUNT );
|
||||||
|
|
||||||
game.status = STATUS_MENU;
|
game.status = STATUS_MENU;
|
||||||
|
|
||||||
@ -232,64 +288,19 @@ int is_key_pressed(int mask) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void GameProcess() {
|
int seed = 0;
|
||||||
|
|
||||||
if (game.status == STATUS_PLAYING) {
|
unsigned short rs_rand() {
|
||||||
|
seed += 1000;
|
||||||
|
seed %= 56789;
|
||||||
|
|
||||||
// shoot
|
// from here, http://www.cplusplus.com/forum/general/85758/
|
||||||
|
// koef. changed
|
||||||
if ( (game.shoot_keypressed) || (is_key_pressed(RS_ATTACK_KEY_MASK)) ) {
|
int n = rskos_get_time() + seed * 57 * 5; // no *2
|
||||||
|
n = (n << 13) ^ n;
|
||||||
game.shoot_delay ++;
|
return (n * (n * n * 15731 + 789221) + 1376312589) & 0xFFFF;
|
||||||
|
|
||||||
if (game.shoot_delay > GAME_SHOOT_PERIOD) {
|
|
||||||
|
|
||||||
// if ( (game.tx > 0) && (game.ty > 5) && (game.tx < GAME_WIDTH-20) && (game.ty < GAME_HEIGHT-10) ) {
|
|
||||||
|
|
||||||
soundbuf_play(&game.sound_test1);
|
|
||||||
|
|
||||||
game.bullet_index++;
|
|
||||||
game.bullet_index %= BULLETS_COUNT;
|
|
||||||
game.bullet_x[game.bullet_index] = game.tx + 5;
|
|
||||||
game.bullet_y[game.bullet_index] = game.ty;
|
|
||||||
// };
|
|
||||||
|
|
||||||
game.shoot_delay -= GAME_SHOOT_PERIOD;
|
|
||||||
game.shoot_keypressed = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int speed = 4;
|
|
||||||
int bullet_speed = 11;
|
|
||||||
|
|
||||||
game.tx += speed * ( is_key_pressed(RS_ARROW_RIGHT_MASK) - is_key_pressed(RS_ARROW_LEFT_MASK) );
|
|
||||||
game.ty += speed * ( is_key_pressed(RS_ARROW_DOWN_MASK) - is_key_pressed(RS_ARROW_UP_MASK) );
|
|
||||||
|
|
||||||
game.tx = rs_clamp_i(game.tx, 5, GAME_WIDTH-25);
|
|
||||||
game.ty = rs_clamp_i(game.ty, 5, GAME_HEIGHT - 25);
|
|
||||||
|
|
||||||
game.tz += 1;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < BULLETS_COUNT; i++) {
|
|
||||||
if (game.bullet_y[i]) {
|
|
||||||
game.bullet_x[i] += bullet_speed;
|
|
||||||
if (game.bullet_x[i] > GAME_WIDTH) {
|
|
||||||
game.bullet_y[i] = 0;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
game_draw();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -407,12 +418,8 @@ void GameInit() {
|
|||||||
rs_gen_init(3, rock_size);
|
rs_gen_init(3, rock_size);
|
||||||
for (i = 0; i < ROCKS_COUNT; i++) {
|
for (i = 0; i < ROCKS_COUNT; i++) {
|
||||||
|
|
||||||
DEBUG10f("loading %d ...\n", i);
|
|
||||||
|
|
||||||
texture_init(&(game.tex_rocks[i]), rock_size, rock_size);
|
texture_init(&(game.tex_rocks[i]), rock_size, rock_size);
|
||||||
|
|
||||||
DEBUG10f("loading %d z...\n", i);
|
|
||||||
|
|
||||||
rs_gen_func_set(0, 0.0);
|
rs_gen_func_set(0, 0.0);
|
||||||
rs_gen_func_radial(0, 0.5, 0.5, 0.5, 0.75, 2.5 + i%5);
|
rs_gen_func_radial(0, 0.5, 0.5, 0.5, 0.75, 2.5 + i%5);
|
||||||
|
|
||||||
@ -440,6 +447,62 @@ void GameInit() {
|
|||||||
rs_gen_term();
|
rs_gen_term();
|
||||||
|
|
||||||
|
|
||||||
|
rock_size = 16;
|
||||||
|
rs_gen_init(3, rock_size);
|
||||||
|
for (i = 0; i < MINIROCKS_COUNT; i++) {
|
||||||
|
|
||||||
|
texture_init(&(game.tex_minirocks[i]), rock_size, rock_size);
|
||||||
|
|
||||||
|
rs_gen_func_set(0, 0.0);
|
||||||
|
rs_gen_func_radial(0, 0.5, 0.5, 0.5, 0.75, 2.5 + i%5);
|
||||||
|
|
||||||
|
rs_gen_func_perlin(2, 33, 4, 0.5, 350+i);
|
||||||
|
rs_gen_func_normalize(2, 0.0, 1.0);
|
||||||
|
rs_gen_func_posterize(2, 4);
|
||||||
|
|
||||||
|
rs_gen_func_cell(1, 410+i, 50, NULL, -2.0, 1.0, 1.0, 1.0, 0.0, 1.0);
|
||||||
|
rs_gen_func_posterize(1, 2);
|
||||||
|
rs_gen_func_normalize(1, 0.0, 1.0);
|
||||||
|
rs_gen_func_add(1, 1, 2, 1.0, 0.5);
|
||||||
|
rs_gen_func_normalize(1, 0.0, 1.0);
|
||||||
|
rs_gen_func_posterize(1, 4);
|
||||||
|
|
||||||
|
rs_gen_func_add(1, 0, 1, 1.0, 1.0);
|
||||||
|
rs_gen_func_normalize(1, 0.0, 1.0);
|
||||||
|
rs_gen_func_mult(1, 0, 1);
|
||||||
|
rs_gen_func_normalize(1, 0.0, 1.0);
|
||||||
|
rs_gen_func_posterize(1, 4);
|
||||||
|
rs_gen_tex_out_rgba_set(0.0, 0.0, 0.0, 0.0);
|
||||||
|
rs_gen_tex_out_rgba(1, 1, 1, -1, 0.7+ 0.01*(i%2), 0.7+ 0.01*(i%3) , 0.65, 1.0);
|
||||||
|
|
||||||
|
memcpy(game.tex_minirocks[i].data, rs_gen_reg.tex_out, rock_size*rock_size*4 );
|
||||||
|
};
|
||||||
|
rs_gen_term();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rs_gen_init(3, EXPLOSION_RADIUS*2);
|
||||||
|
for (i = 0; i < EXPLOSIONS_COUNT; i++) {
|
||||||
|
|
||||||
|
texture_init(&(game.tex_explosions[i]), EXPLOSION_RADIUS*2, EXPLOSION_RADIUS*2);
|
||||||
|
|
||||||
|
rs_gen_func_set(0, 1.0);
|
||||||
|
// rs_gen_func_radial(0, 0.5, 0.5, 0.3 + 0.5*i/EXPLOSION_FRAMES_COUNT, 0.975, 4.0);
|
||||||
|
// rs_gen_func_set(0, 1.0);
|
||||||
|
|
||||||
|
rs_gen_func_set(1, 0.0);
|
||||||
|
rs_gen_func_radial(1, 0.5, 0.5, 0.1 + 0.4*i/EXPLOSIONS_COUNT, 1.0 - 1.0*i/EXPLOSIONS_COUNT, 2.5 + i%5);
|
||||||
|
|
||||||
|
rs_gen_tex_out_rgba_set( 0.0, 0.0, 0.0, 0.0);
|
||||||
|
rs_gen_tex_out_rgba(0, 0, 0, 1, 1.0, 1.0, 1.0, 1.0);
|
||||||
|
|
||||||
|
memcpy(game.tex_explosions[i].data, rs_gen_reg.tex_out, EXPLOSION_RADIUS*2*EXPLOSION_RADIUS*2*4 );
|
||||||
|
};
|
||||||
|
rs_gen_term();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef RS_KOS
|
#ifndef RS_KOS
|
||||||
rs_audio_init(RS_AUDIO_FMT_MONO16, RS_AUDIO_FREQ_16000, 0);
|
rs_audio_init(RS_AUDIO_FMT_MONO16, RS_AUDIO_FREQ_16000, 0);
|
||||||
#endif
|
#endif
|
||||||
@ -473,6 +536,8 @@ void GameTerm() {
|
|||||||
|
|
||||||
free(game.scaled_framebuffer);
|
free(game.scaled_framebuffer);
|
||||||
|
|
||||||
|
free(game.objs);
|
||||||
|
|
||||||
texture_free(&game.framebuffer);
|
texture_free(&game.framebuffer);
|
||||||
texture_free(&game.tex);
|
texture_free(&game.tex);
|
||||||
texture_free(&game.tex_clouds);
|
texture_free(&game.tex_clouds);
|
||||||
@ -571,17 +636,16 @@ void GameKeyDown(int key, int first) {
|
|||||||
game.status = STATUS_MENU;
|
game.status = STATUS_MENU;
|
||||||
menu_open(0);
|
menu_open(0);
|
||||||
break;
|
break;
|
||||||
case RS_KEY_A:
|
case RS_KEY_SPACE:
|
||||||
|
|
||||||
// if ( (game.tx > 0) && (game.ty > 5) && (game.tx < GAME_WIDTH-20) && (game.ty < GAME_HEIGHT-10) ) {
|
#ifdef RS_LINUX
|
||||||
//
|
game.stage_timer = 0;
|
||||||
// soundbuf_play(&game.sound_test1);
|
game.stage = 7;
|
||||||
//
|
#endif
|
||||||
// game.bullet_index++;
|
|
||||||
// game.bullet_index %= BULLETS_COUNT;
|
//game_obj_add( game_obj( OBJ_EXPLOSION, 0, 0, 0, game.tx + 80, game.ty - 10, 0, 0.0 ) );
|
||||||
// game.bullet_x[game.bullet_index] = game.tx + 12;
|
|
||||||
// game.bullet_y[game.bullet_index] = game.ty + 3;
|
// game_obj_add( game_obj( OBJ_ROCK, 0, 0, 32, game.tx + 80, game.ty - 10, 0, 0.0 ) );
|
||||||
// };
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -613,8 +677,8 @@ void GameKeyUp(int key) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void GameMouseDown(int x, int y) {
|
void GameMouseDown(int x, int y) {
|
||||||
game.tx = x;
|
// game.tx = x;
|
||||||
game.ty = y;
|
// game.ty = y;
|
||||||
DEBUG10f("Mouse Down %d, %d \n", x, y);
|
DEBUG10f("Mouse Down %d, %d \n", x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,10 +108,54 @@ void soundbuf_sin_fade(rs_soundbuf_t *snd, float freq);
|
|||||||
void soundbuf_play(rs_soundbuf_t *snd);
|
void soundbuf_play(rs_soundbuf_t *snd);
|
||||||
void soundbuf_stop(rs_soundbuf_t *snd);
|
void soundbuf_stop(rs_soundbuf_t *snd);
|
||||||
|
|
||||||
|
// Game Objects
|
||||||
|
|
||||||
|
#define GAME_OBJS_MAX_COUNT 1024
|
||||||
|
|
||||||
|
#define OBJ_PLAYER 0
|
||||||
|
#define OBJ_BULLET 1
|
||||||
|
#define OBJ_EXPLOSION 2
|
||||||
|
#define OBJ_ROCK 3
|
||||||
|
#define OBJ_MINIROCK 4
|
||||||
|
#define OBJ_TURRET 5
|
||||||
|
#define OBJ_RED_BULLET 6
|
||||||
|
|
||||||
|
typedef struct game_obj_t {
|
||||||
|
int obj_type;
|
||||||
|
int flags;
|
||||||
|
int tag;
|
||||||
|
int radius;
|
||||||
|
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
int t;
|
||||||
|
float f;
|
||||||
|
|
||||||
|
// int health;
|
||||||
|
// int reserved0;
|
||||||
|
// int reserved1;
|
||||||
|
// int reserved2;
|
||||||
|
} game_obj_t;
|
||||||
|
|
||||||
|
#define OBJ_FLAG_DESTROYED 0x01
|
||||||
|
#define OBJ_FLAG_ENEMY 0x02
|
||||||
|
#define OBJ_FLAG_SIN 0x04
|
||||||
|
#define OBJ_FLAG_BOSS 0x08 // draw health-bar above
|
||||||
|
|
||||||
|
game_obj_t game_obj(int obj_type, int flags, int tag, int radius, float x, float y, int t, float f);
|
||||||
|
|
||||||
|
int game_obj_add(game_obj_t obj);
|
||||||
|
void game_obj_remove(int index);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Game Registry
|
// Game Registry
|
||||||
|
|
||||||
#define ROCKS_COUNT 3
|
#define ROCKS_COUNT 8
|
||||||
|
#define MINIROCKS_COUNT ROCKS_COUNT // must equal
|
||||||
#define FONTS_COUNT 4
|
#define FONTS_COUNT 4
|
||||||
|
#define EXPLOSIONS_COUNT 8
|
||||||
|
#define EXPLOSION_RADIUS 16
|
||||||
|
|
||||||
#define STATUS_MENU 0
|
#define STATUS_MENU 0
|
||||||
#define STATUS_PLAYING 1
|
#define STATUS_PLAYING 1
|
||||||
@ -124,10 +168,12 @@ void soundbuf_stop(rs_soundbuf_t *snd);
|
|||||||
#define RS_ARROW_RIGHT_MASK 0x08
|
#define RS_ARROW_RIGHT_MASK 0x08
|
||||||
#define RS_ATTACK_KEY_MASK 0x10
|
#define RS_ATTACK_KEY_MASK 0x10
|
||||||
|
|
||||||
#define BULLETS_COUNT 8
|
//#define BULLETS_COUNT 8
|
||||||
|
|
||||||
#define GAME_SHOOT_PERIOD 3
|
#define GAME_SHOOT_PERIOD 3
|
||||||
|
|
||||||
|
#define GAME_FLAG_BOSS_DESTROYED 0x01
|
||||||
|
|
||||||
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
|
||||||
@ -139,6 +185,9 @@ typedef struct rs_game_t {
|
|||||||
|
|
||||||
rs_texture_t tex_ship[4];
|
rs_texture_t tex_ship[4];
|
||||||
rs_texture_t tex_rocks[ROCKS_COUNT];
|
rs_texture_t tex_rocks[ROCKS_COUNT];
|
||||||
|
rs_texture_t tex_minirocks[MINIROCKS_COUNT];
|
||||||
|
|
||||||
|
rs_texture_t tex_explosions[EXPLOSIONS_COUNT];
|
||||||
|
|
||||||
rs_texture_t tex_font[64*FONTS_COUNT];
|
rs_texture_t tex_font[64*FONTS_COUNT];
|
||||||
|
|
||||||
@ -150,6 +199,7 @@ typedef struct rs_game_t {
|
|||||||
rs_soundbuf_t sound_test3;
|
rs_soundbuf_t sound_test3;
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
|
int flags;
|
||||||
|
|
||||||
unsigned int keyboard_state;
|
unsigned int keyboard_state;
|
||||||
|
|
||||||
@ -158,18 +208,38 @@ typedef struct rs_game_t {
|
|||||||
|
|
||||||
int window_scale;
|
int window_scale;
|
||||||
|
|
||||||
int tx;
|
// int tx1;
|
||||||
int ty;
|
// int ty1;
|
||||||
int tz;
|
int tz;
|
||||||
|
|
||||||
int bullet_x[BULLETS_COUNT];
|
int player_x;
|
||||||
int bullet_y[BULLETS_COUNT];
|
int player_y;
|
||||||
int bullet_index;
|
// int player_z;
|
||||||
|
|
||||||
|
// int bullet_x[BULLETS_COUNT];
|
||||||
|
// int bullet_y[BULLETS_COUNT];
|
||||||
|
// int bullet_index;
|
||||||
int shoot_delay;
|
int shoot_delay;
|
||||||
int shoot_keypressed;
|
int shoot_keypressed;
|
||||||
|
int shoot_restore_delay;
|
||||||
|
|
||||||
|
int health;
|
||||||
|
int ammo;
|
||||||
|
int score;
|
||||||
|
|
||||||
|
// int ammo_max;
|
||||||
|
|
||||||
|
int stage;
|
||||||
|
int stage_timer;
|
||||||
|
|
||||||
|
game_obj_t *objs;
|
||||||
|
int objs_count;
|
||||||
|
|
||||||
} rs_game_t;
|
} rs_game_t;
|
||||||
|
|
||||||
|
#define GAME_HEALTH_MAX 8
|
||||||
|
#define GAME_AMMO_MAX 24
|
||||||
|
|
||||||
extern rs_game_t game;
|
extern rs_game_t game;
|
||||||
void game_reg_init();
|
void game_reg_init();
|
||||||
|
|
||||||
@ -180,7 +250,6 @@ void game_reg_init();
|
|||||||
\eeee/
|
\eeee/
|
||||||
------------------------------- */
|
------------------------------- */
|
||||||
|
|
||||||
void GameProcess();
|
|
||||||
|
|
||||||
void game_ding(int i);
|
void game_ding(int i);
|
||||||
|
|
||||||
@ -195,4 +264,7 @@ void GameMouseUp(int x, int y);
|
|||||||
|
|
||||||
void game_change_window_scale(int d);
|
void game_change_window_scale(int d);
|
||||||
|
|
||||||
|
int is_key_pressed(int mask);
|
||||||
|
unsigned short rs_rand();
|
||||||
|
|
||||||
#endif // RSGAME_H_INCLUDED
|
#endif // RSGAME_H_INCLUDED
|
||||||
|
@ -55,8 +55,6 @@ void game_draw() {
|
|||||||
texture_draw_vline(&game.tex_ground, i, 25 + rs_perlin(0,i+game.tz)*25 + 2, 999, 0xFF000000);
|
texture_draw_vline(&game.tex_ground, i, 25 + rs_perlin(0,i+game.tz)*25 + 2, 999, 0xFF000000);
|
||||||
};
|
};
|
||||||
|
|
||||||
texture_draw(&game.tex_ground, &game.tex_clouds, game.tz, 0, /* game.tx, game.ty, */ DRAW_MODE_ADDITIVE | DRAW_TILED_FLAG );
|
|
||||||
texture_draw(&game.framebuffer, &game.tex_ground, 0, GAME_HEIGHT-50, DRAW_MODE_ALPHA);
|
|
||||||
|
|
||||||
|
|
||||||
if (game.status == STATUS_MENU) {
|
if (game.status == STATUS_MENU) {
|
||||||
@ -72,40 +70,138 @@ void game_draw() {
|
|||||||
|
|
||||||
if (game.menu_index == MENU_MAIN) {
|
if (game.menu_index == MENU_MAIN) {
|
||||||
|
|
||||||
for (i = 0; i < ROCKS_COUNT; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
texture_draw(&game.framebuffer, &game.tex_rocks[i], 250+80*rs_noise(i,150), 60+60*rs_noise(i,1110), DRAW_MODE_ADDITIVE );
|
texture_draw(&game.framebuffer, &game.tex_rocks[i], 250+80*rs_noise(i,150), 60+60*rs_noise(i,1110), DRAW_MODE_ADDITIVE );
|
||||||
};
|
};
|
||||||
|
|
||||||
game_textout( GAME_WIDTH/2 - 100, 40, 1, "HELI0THRYX");
|
game_textout( GAME_WIDTH/2 - 100, 40, 1, "HELI0THRYX");
|
||||||
game_textout( GAME_WIDTH/2 - 8, 58, 3, "TECHDEM0");
|
// game_textout( GAME_WIDTH/2 - 8, 58, 3, "TECHDEM0");
|
||||||
game_textout( 2, GAME_HEIGHT-10, 2, L_BOTTOM_LINE_DEVELOPER_INFO);
|
game_textout( 2, GAME_HEIGHT-10, 2, L_BOTTOM_LINE_DEVELOPER_INFO);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
texture_draw(&game.framebuffer, &game.tex_ship[0], game.tx-8, game.ty-4, DRAW_MODE_ALPHA);
|
int i, j;
|
||||||
texture_draw(&game.framebuffer, &game.tex_ship[1], game.tx-8, game.ty-4, DRAW_MODE_ALPHA);
|
game_obj_t *obj;
|
||||||
texture_draw(&game.framebuffer, &game.tex_ship[2], game.tx, game.ty-4, DRAW_MODE_ALPHA);
|
for (i = 0; i < game.objs_count; i++) {
|
||||||
texture_draw(&game.framebuffer, &game.tex_ship[3], game.tx, game.ty-4, DRAW_MODE_ALPHA);
|
obj = &(game.objs[i]);
|
||||||
|
|
||||||
int i;
|
if (obj->obj_type == OBJ_BULLET) {
|
||||||
for (i = 0; i < BULLETS_COUNT; i++) {
|
|
||||||
if (game.bullet_y[i]) {
|
texture_set_pixel(&game.framebuffer, obj->x-4, obj->y, 0xFF00BB00);
|
||||||
texture_set_pixel(&game.framebuffer, game.bullet_x[i]-4, game.bullet_y[i], 0xFF00BB00);
|
texture_set_pixel(&game.framebuffer, obj->x-3, obj->y, 0xFF00CC00);
|
||||||
texture_set_pixel(&game.framebuffer, game.bullet_x[i]-3, game.bullet_y[i], 0xFF00CC00);
|
texture_set_pixel(&game.framebuffer, obj->x-2, obj->y, 0xFF00DD00);
|
||||||
texture_set_pixel(&game.framebuffer, game.bullet_x[i]-2, game.bullet_y[i], 0xFF00DD00);
|
texture_set_pixel(&game.framebuffer, obj->x-1, obj->y, 0xFF00EE00);
|
||||||
texture_set_pixel(&game.framebuffer, game.bullet_x[i]-1, game.bullet_y[i], 0xFF00EE00);
|
texture_set_pixel(&game.framebuffer, obj->x-0, obj->y, 0xFF00FF00);
|
||||||
texture_set_pixel(&game.framebuffer, game.bullet_x[i]-0, game.bullet_y[i], 0xFF00FF00);
|
|
||||||
};
|
}
|
||||||
|
else if (obj->obj_type == OBJ_RED_BULLET) {
|
||||||
|
|
||||||
|
texture_set_pixel(&game.framebuffer, obj->x-1, obj->y-0, 0xFFFF0000);
|
||||||
|
texture_set_pixel(&game.framebuffer, obj->x-1, obj->y-1, 0xFFFF6600);
|
||||||
|
texture_set_pixel(&game.framebuffer, obj->x-1, obj->y-0, 0xFFFF0000);
|
||||||
|
texture_set_pixel(&game.framebuffer, obj->x-0, obj->y-1, 0xFFFF0000);
|
||||||
|
texture_set_pixel(&game.framebuffer, obj->x-0, obj->y-0, 0xFFFF6600);
|
||||||
|
texture_set_pixel(&game.framebuffer, obj->x+1, obj->y-1, 0xFFFF0000);
|
||||||
|
texture_set_pixel(&game.framebuffer, obj->x+1, obj->y-0, 0xFFFF6600);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (obj->obj_type == OBJ_EXPLOSION) {
|
||||||
|
|
||||||
|
// char s[] = "00 ";
|
||||||
|
// s[0] += obj->t / 10;
|
||||||
|
// s[1] += obj->t % 10;
|
||||||
|
// game_textout( obj->x, obj->y, 0, s );
|
||||||
|
|
||||||
|
texture_draw( &game.framebuffer, &game.tex_explosions[ obj->t ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ALPHA );
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (obj->obj_type == OBJ_ROCK) {
|
||||||
|
texture_draw( &game.framebuffer, &game.tex_rocks[ obj->tag ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ALPHA );
|
||||||
|
}
|
||||||
|
else if (obj->obj_type == OBJ_MINIROCK) {
|
||||||
|
texture_draw( &game.framebuffer, &game.tex_minirocks[ obj->tag ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ALPHA );
|
||||||
|
}
|
||||||
|
else if (obj->obj_type == OBJ_TURRET) {
|
||||||
|
texture_draw( &game.framebuffer, &game.tex_rocks[ 0 ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ALPHA );
|
||||||
|
texture_draw( &game.framebuffer, &game.tex_rocks[ 0 ], obj->x - obj->radius, obj->y - obj->radius, DRAW_MODE_ADDITIVE );
|
||||||
|
|
||||||
|
for (j = 0; j < 1 + (obj->tag)/6; j++) {
|
||||||
|
texture_draw_vline(&game.framebuffer, obj->x - obj->radius + j*4 + 0, obj->y - obj->radius - 16, 8, 0xFF993333 );
|
||||||
|
texture_draw_vline(&game.framebuffer, obj->x - obj->radius + j*4 + 1, obj->y - obj->radius - 16, 8, 0xFF993333 );
|
||||||
|
texture_draw_vline(&game.framebuffer, obj->x - obj->radius + j*4 + 2, obj->y - obj->radius - 16, 8, 0xFF993333 );
|
||||||
};
|
};
|
||||||
|
|
||||||
game_textout( 2, 2, 2, L_TECHDEMO_LINE1 );
|
}
|
||||||
game_textout( 2, 12, 2, L_TECHDEMO_LINE2 );
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
texture_draw(&game.framebuffer, &game.tex_ship[0], game.player_x-8, game.player_y-4, DRAW_MODE_ALPHA);
|
||||||
|
texture_draw(&game.framebuffer, &game.tex_ship[1], game.player_x-8, game.player_y-4, DRAW_MODE_ALPHA);
|
||||||
|
texture_draw(&game.framebuffer, &game.tex_ship[2], game.player_x, game.player_y-4, DRAW_MODE_ALPHA);
|
||||||
|
texture_draw(&game.framebuffer, &game.tex_ship[3], game.player_x, game.player_y-4, DRAW_MODE_ALPHA);
|
||||||
|
|
||||||
|
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
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_health[] = "HEALTH: 0 ";
|
||||||
|
char s_ammo[] = "AMM0: 00 ";
|
||||||
|
|
||||||
|
s_health[8] += game.health;
|
||||||
|
s_ammo[6] += game.ammo / 10;
|
||||||
|
s_ammo[7] += game.ammo % 10;
|
||||||
|
|
||||||
|
game_textout(8, 8, 2, s_health);
|
||||||
|
game_textout(GAME_WIDTH - 12 - GAME_AMMO_MAX*2 - 1, 8, 2, s_ammo);
|
||||||
|
|
||||||
|
for (i = 0; i < game.ammo; i++) {
|
||||||
|
texture_draw_vline(&game.framebuffer, GAME_WIDTH - 12 - GAME_AMMO_MAX*2 + i*2, 20, 8, 0xFF3366FF );
|
||||||
|
};
|
||||||
|
|
||||||
|
int health_color = 0xFF339933;
|
||||||
|
if (game.health < 5) {
|
||||||
|
health_color = 0xFF808010;
|
||||||
|
};
|
||||||
|
if (game.health < 3) {
|
||||||
|
health_color = 0xFFFF3300;
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = 0; i < game.health; i++) {
|
||||||
|
texture_draw_vline(&game.framebuffer, 8 + i*4 + 0, 20, 8, health_color );
|
||||||
|
texture_draw_vline(&game.framebuffer, 8 + i*4 + 1, 20, 8, health_color );
|
||||||
|
texture_draw_vline(&game.framebuffer, 8 + i*4 + 2, 20, 8, health_color );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// game_textout( 2, 12, 2, L_TECHDEMO_LINE2 );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
texture_draw(&game.tex_ground, &game.tex_clouds, game.tz, 0, /* game.tx, game.ty, */ DRAW_MODE_ADDITIVE | DRAW_TILED_FLAG );
|
||||||
|
texture_draw(&game.framebuffer, &game.tex_ground, 0, GAME_HEIGHT-50, DRAW_MODE_ALPHA);
|
||||||
|
|
||||||
|
|
||||||
rskos_draw_area(0, 0, w, h, game.window_scale, game.framebuffer.data, game.scaled_framebuffer);
|
rskos_draw_area(0, 0, w, h, game.window_scale, game.framebuffer.data, game.scaled_framebuffer);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -9,10 +9,12 @@
|
|||||||
PRSFUNC0 menu_actions[] = {
|
PRSFUNC0 menu_actions[] = {
|
||||||
/* a */ &menu_action_start,
|
/* a */ &menu_action_start,
|
||||||
/* b */ &menu_action_exit,
|
/* b */ &menu_action_exit,
|
||||||
/* c */ &menu_action_change_window_scale
|
/* c */ &menu_action_change_window_scale,
|
||||||
|
// /* d */ &menu_action_
|
||||||
};
|
};
|
||||||
|
|
||||||
char window_scale_str[] = "c< 2X >";
|
char window_scale_str[] = "c< 2X >";
|
||||||
|
char level_passed_score_str[] = " 000 ";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
First char:
|
First char:
|
||||||
@ -45,14 +47,34 @@ char* menu_about_titles[] = {
|
|||||||
" "L_DEVELOPED_BY,
|
" "L_DEVELOPED_BY,
|
||||||
" "L_ROMAN_SHUVALOV,
|
" "L_ROMAN_SHUVALOV,
|
||||||
" ",
|
" ",
|
||||||
"0"L_DONE,
|
"0"L_BACK,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char* menu_level_passed_titles[] = {
|
||||||
|
" "L_LEVEL_PASSED,
|
||||||
|
" "L_YOUR_SCORE,
|
||||||
|
level_passed_score_str,
|
||||||
|
" ",
|
||||||
|
"0"L_BACK,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
char* menu_game_over_titles[] = {
|
||||||
|
" "L_GAME_OVER,
|
||||||
|
" ",
|
||||||
|
"0"L_BACK,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char **menu_titles[] = {
|
char **menu_titles[] = {
|
||||||
/* 0 */ menu_main_titles,
|
/* 0 */ menu_main_titles,
|
||||||
/* 1 */ menu_settings_titles,
|
/* 1 */ menu_settings_titles,
|
||||||
/* 2 */ menu_about_titles,
|
/* 2 */ menu_about_titles,
|
||||||
|
/* 3 */ menu_level_passed_titles,
|
||||||
|
/* 4 */ menu_game_over_titles,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -120,8 +142,23 @@ void menu_cursor_click() {
|
|||||||
void menu_action_start() {
|
void menu_action_start() {
|
||||||
game.status = STATUS_PLAYING;
|
game.status = STATUS_PLAYING;
|
||||||
|
|
||||||
game.tx = GAME_WIDTH/2 - 50;
|
game.player_x = GAME_WIDTH/2 - 50;
|
||||||
game.ty = GAME_HEIGHT/2 - 10;
|
game.player_y = GAME_HEIGHT/2 - 10;
|
||||||
|
|
||||||
|
game.stage = 0;
|
||||||
|
game.stage_timer = 0;
|
||||||
|
|
||||||
|
game.health = GAME_HEALTH_MAX;
|
||||||
|
game.ammo = GAME_AMMO_MAX;
|
||||||
|
|
||||||
|
game.shoot_delay = 0;
|
||||||
|
game.shoot_keypressed = 0;
|
||||||
|
game.shoot_restore_delay = 0;
|
||||||
|
|
||||||
|
game.score = 0;
|
||||||
|
game.flags = 0;
|
||||||
|
|
||||||
|
game.objs_count = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#define MENU_MAIN 0
|
#define MENU_MAIN 0
|
||||||
#define MENU_SETTINGS 1
|
#define MENU_SETTINGS 1
|
||||||
#define MENU_ABOUT 2
|
#define MENU_ABOUT 2
|
||||||
|
#define MENU_LEVEL_PASSED 3
|
||||||
|
#define MENU_GAME_OVER 4
|
||||||
|
|
||||||
#define MENU_ITEM_WINDOW_SCALE 1
|
#define MENU_ITEM_WINDOW_SCALE 1
|
||||||
|
|
||||||
@ -20,6 +22,7 @@ extern char **menu_titles[];
|
|||||||
extern PRSFUNC0 menu_actions[];
|
extern PRSFUNC0 menu_actions[];
|
||||||
|
|
||||||
extern char window_scale_str[];
|
extern char window_scale_str[];
|
||||||
|
extern char level_passed_score_str[];
|
||||||
|
|
||||||
void menu_cursor_down();
|
void menu_cursor_down();
|
||||||
void menu_cursor_up();
|
void menu_cursor_up();
|
||||||
|
@ -487,12 +487,24 @@ float game_colors[4*7] = {
|
|||||||
0.6, 0.6, 0.6, 0.9,
|
0.6, 0.6, 0.6, 0.9,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void game_textout(int x, int y, int font_index, char* s) {
|
void game_textout(int x, int y, int font_index, char* s) {
|
||||||
|
game_textout_adv(&game.framebuffer, x, y, font_index, DRAW_MODE_ALPHA, s);
|
||||||
|
};
|
||||||
|
|
||||||
|
void game_textout_at_center(int x, int y, int font_index, char *s) {
|
||||||
|
x += (GAME_WIDTH - game.tex_font[font_index*64].w*strlen(s))/2;
|
||||||
|
game_textout_adv(&game.framebuffer, x, y, font_index, DRAW_MODE_ALPHA, s);
|
||||||
|
};
|
||||||
|
|
||||||
|
void game_textout_adv(rs_texture_t *dest, int x, int y, int font_index, int draw_mode, char* s) {
|
||||||
|
//void game_textout(int x, int y, int font_index, char* s) {
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
if (*s != ' ') {
|
if (*s != ' ') {
|
||||||
texture_draw(&game.framebuffer, &game.tex_font[ 64*font_index + ((*s - 48) % 64) ], x+i*game.tex_font[64*font_index+0].w, y, DRAW_MODE_ALPHA);
|
texture_draw(&game.framebuffer, &game.tex_font[ 64*font_index + ((*s - 48) % 64) ], x+i*game.tex_font[64*font_index+0].w, y, draw_mode);
|
||||||
};
|
};
|
||||||
s++;
|
s++;
|
||||||
i++;
|
i++;
|
||||||
|
@ -29,6 +29,8 @@ void game_font_init();
|
|||||||
void game_font_term();
|
void game_font_term();
|
||||||
|
|
||||||
void game_textout(int x, int y, int font_index, char* s);
|
void game_textout(int x, int y, int font_index, char* s);
|
||||||
|
void game_textout_at_center(int x, int y, int font_index, char *s);
|
||||||
|
void game_textout_adv(rs_texture_t *dest, int x, int y, int font_index, int draw_mode, char* s);
|
||||||
//void game_textout_init(int set_to_ortho, int font_index);
|
//void game_textout_init(int set_to_ortho, int font_index);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -147,7 +147,7 @@ void rskos_snd_stop(SNDBUF *hbuf) {
|
|||||||
|
|
||||||
|
|
||||||
unsigned int rskos_get_time() {
|
unsigned int rskos_get_time() {
|
||||||
return 1;
|
return kol_system_time_get() * 10; // (1/0.01 sec) * 10 = (1/0.001 sec) = 1 ms
|
||||||
};
|
};
|
||||||
|
|
||||||
void rskos_draw_area(int x, int y, int w, int h, int k_scale, unsigned char *data, unsigned char *scaled_buffer) {
|
void rskos_draw_area(int x, int y, int w, int h, int k_scale, unsigned char *data, unsigned char *scaled_buffer) {
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
// Settings menu
|
// Settings menu
|
||||||
#define L_WINDOW_SCALE "WIND0W 5CALE:"
|
#define L_WINDOW_SCALE "WIND0W 5CALE:"
|
||||||
#define L_DONE "D0NE"
|
#define L_DONE "D0NE"
|
||||||
|
#define L_BACK "BACK"
|
||||||
|
|
||||||
// About menu
|
// About menu
|
||||||
#define L_DEVELOPED_BY "DEVEL0PED BY"
|
#define L_DEVELOPED_BY "DEVEL0PED BY"
|
||||||
@ -24,7 +25,12 @@
|
|||||||
#define L_BOTTOM_LINE_DEVELOPER_INFO "DEVEL0PER: R0MAN 5HUVAL0V` T0GLIATTI_ 2014"
|
#define L_BOTTOM_LINE_DEVELOPER_INFO "DEVEL0PER: R0MAN 5HUVAL0V` T0GLIATTI_ 2014"
|
||||||
|
|
||||||
// Gameplay
|
// Gameplay
|
||||||
#define L_TECHDEMO_LINE1 "THI5 I5 TECHDEM0` "
|
//#define L_TECHDEMO_LINE1 "THI5 I5 TECHDEM0` "
|
||||||
#define L_TECHDEMO_LINE2 "U5E ARR0W5 T0 M0VE_ <A> T0 5H00T_ <E5C> T0 EXIT` "
|
#define L_TECHDEMO_LINE1 "U5E ARR0W5 T0 M0VE_ <A> T0 5H00T_ <E5C> T0 EXIT` "
|
||||||
|
|
||||||
|
#define L_LEVEL_PASSED "DEM0=LEVEL PA55ED"
|
||||||
|
#define L_YOUR_SCORE "Y0UR 5C0RE:"
|
||||||
|
|
||||||
|
#define L_GAME_OVER "GAME 0VER"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
// Settings menu
|
// Settings menu
|
||||||
#define L_WINDOW_SCALE "MAChTAb 0KHA:"
|
#define L_WINDOW_SCALE "MAChTAb 0KHA:"
|
||||||
#define L_DONE "g0T0B0"
|
#define L_DONE "g0T0B0"
|
||||||
|
#define L_BACK "HA3Ad"
|
||||||
|
|
||||||
// About menu
|
// About menu
|
||||||
#define L_DEVELOPED_BY "PA3PAb0T4iK:"
|
#define L_DEVELOPED_BY "PA3PAb0T4iK:"
|
||||||
@ -24,8 +25,11 @@
|
|||||||
#define L_BOTTOM_LINE_DEVELOPER_INFO "PA3PAb0T4iK: P0MAH hYBAl0B` T0l]aTTi_ 2014"
|
#define L_BOTTOM_LINE_DEVELOPER_INFO "PA3PAb0T4iK: P0MAH hYBAl0B` T0l]aTTi_ 2014"
|
||||||
|
|
||||||
// Gameplay
|
// Gameplay
|
||||||
#define L_TECHDEMO_LINE1 "eT0 TEXH0dEMKA` "
|
//#define L_TECHDEMO_LINE1 "eT0 TEXH0dEMKA` "
|
||||||
#define L_TECHDEMO_LINE2 "CTPElKi = dBijEHiE_ <A> = B\\CTPEl_ <E5C> = B\\X0d` "
|
#define L_TECHDEMO_LINE1 "CTPElKi = dBijEHiE_ <A> = B\\CTPEl_ <E5C> = B\\X0d` "
|
||||||
|
|
||||||
|
#define L_LEVEL_PASSED "dEM0=YP0BEH] nP0^dEH"
|
||||||
|
#define L_YOUR_SCORE "04K0B HAbPAH0:"
|
||||||
|
#define L_GAME_OVER "igPA 0K0H4EHA"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user