home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ISV Strong Games
/
ISV_STRONG_GAMES.iso
/
shootemup
/
hive
/
!Hive
/
c
/
main_hnd
< prev
next >
Wrap
Text File
|
2000-11-27
|
5KB
|
201 lines
#include <stdlib.h>
#include "DeskLib:h.Kbd"
#include "DeskLib:h.SWI"
#include "Popcorn:h.Popcorn"
#include "h.game"
#include "h.sound"
#include "h.useful"
#define random(n) (rand() % (n))
void explode_handler(struct game_object *obj, union object_flags reason, void *data)
{
Popcorn_DeleteObject(obj);
}
void token_handler(struct game_object *obj, union object_flags reason, void *data)
{
if (reason.bits.collide)
{
Popcorn_DeleteObject(obj)
make_sound("<Hive$Dir>.Sounds.Token");
score = score + 200;
switch (random(4))
{
case 0 :
invulnerable = invulnerable + 500; break;
case 1 :
special = 1; break;
case 2 :
special = 2; break;
case 3 :
fire_freq = 20; break;
}
}
if (reason.bits.attn_gameout)
{
if (obj->x > (319>>12) || obj->x < 0)
obj->xv = -obj->xv;
}
}
void missile_handler(struct game_object *obj, union object_flags reason, void *data)
{
struct game_object *obj2;
obj2 = (struct game_object*) data;
if (reason.bits.collide && obj2->object_id != 0)
{
delete_alien(obj2);
return;
}
}
void firework_handler(struct game_object *obj, union object_flags reason, void *data)
{
struct game_object *t_obj;
int c;
if (reason.bits.collide)
{
for(c=0; c!=10; c++)
{
t_obj = Popcorn_NewPrototype(missile_table, 'BMBR', obj->x, obj->y);
t_obj->xv = random(32768)-16384;
if ( (t_obj->xv & 1) == 1 )
t_obj->xv = -t_obj->xv;
t_obj->yv = random(32768)-16384;
if ( (t_obj->yv & 1) == 1 )
t_obj->yv = -t_obj->yv;
t_obj->timer.value = 300; t_obj->timer.decrement = 1;
}
make_lots_of_particles_everywhere(obj->x, obj->y, 100);
Popcorn_DeleteObject(obj);
}
}
void bullet_handler(struct game_object *obj, union object_flags reason, void *data)
{
struct game_object *obj2;
obj2 = (struct game_object*) data;
if (reason.bits.collide && obj2->object_id != 0)
{
Popcorn_DeleteObject(obj);
delete_alien(obj2);
fired--;
return;
}
if (reason.bits.attn_gameout)
{
Popcorn_DeleteObject(obj);
fired--;
}
}
void ship_handler(struct game_object *obj, union object_flags reason, void *data)
{
struct game_object *missile;
int c;
if (reason.bits.attn_every)
{
ship_x = obj->x;
if (Kbd_KeyDown(-98) && obj->x > 0)
{
ship_pos = ship_pos - 4; if (ship_pos < 0) ship_pos = 0;
obj->x = obj->x - 8192;
}
if (Kbd_KeyDown(-67) && obj->x < 320<<12)
{
ship_pos = ship_pos + 4; if (ship_pos > 64) ship_pos = 64;
obj->x = obj->x + 8192;
}
if (ship_pos > 28) ship_pos = ship_pos - 2;
if (ship_pos < 28) ship_pos = ship_pos + 2;
obj->plot_id.sprite_anchor = ship_sprite[ship_pos>>3];
if (Kbd_KeyDown(-74) && fired != max_fired && fire_again == 0)
{
make_sound("<Hive$Dir>.Sounds.Shoot");
missile = Popcorn_NewPrototype(missile_table, 'TLLB', obj->x, obj->y);
missile->yv = -(4<<12);
fired++;
fire_again = fire_freq;
}
if (Kbd_KeyDown(-99) && special != 0)
{
switch (special)
{
case 1 :
make_sound("<Hive$Dir>.Sounds.Missile");
missile = Popcorn_NewPrototype(missile_table, 'RIPS', obj->x, obj->y);
missile->yv = -(2<<12);
special = 0; break;
case 2 :
make_sound("<Hive$Dir>.Sounds.Missile");
missile = Popcorn_NewPrototype(missile_table, 'LSIM', obj->x, obj->y);
missile->yv = -(6<<12);
special = 0; break;
}
}
if (invulnerable != 0)
{
invulnerable--;
if ( (invulnerable & 3) == 0)
obj->flags.bits.std_plot = TRUE;
else
obj->flags.bits.std_plot = FALSE;
if (invulnerable == 0)
obj->flags.bits.std_plot = TRUE;
}
if (fire_again != 0) fire_again--;
}
if ( (reason.bits.collide && invulnerable == 0) || Kbd_KeyDown(-113) )
{
if (Kbd_KeyDown(-113))
lives = 1;
make_sound("<Hive$Dir>.Sounds.Explode");
make_explosion(obj->x, obj->y);
Popcorn_DeleteObject(obj);
lives--;
if (lives == 0)
{
SWI(0, 1, SWI_OS_ReadMonotonicTime, &last_killed_at);
for (c=0; c!=alien_table->max_objects; c++)
Popcorn_DeleteObject(&alien_table->object[c]);
for (c=0; c!=alien_swoop_table->max_objects; c++)
Popcorn_DeleteObject(&alien_swoop_table->object[c]);
for (c=0; c!=alien_missile_table->max_objects; c++)
Popcorn_DeleteObject(&alien_missile_table->object[c]);
game_finish();
aliens_left = 0;
wave = -1;
}
else
{
SWI(0, 1, SWI_OS_ReadMonotonicTime, &next_life_time);
invulnerable = 100;
}
}
}
void bang_handler(struct game_object *obj, union object_flags reason, void *data)
{
make_lots_of_particles_everywhere(obj->x, obj->y, 40);
Popcorn_DeleteObject(obj);
}