home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ISV Strong Games
/
ISV_STRONG_GAMES.iso
/
shootemup
/
hive
/
!Hive
/
c
/
useful
< prev
next >
Wrap
Text File
|
2000-11-27
|
3KB
|
120 lines
#include <stdio.h>
#include <stdlib.h>
#include "DeskLib:h.Error"
#include "Popcorn:h.Popcorn"
#include "h.game"
#include "h.sound"
#define random(limit) (rand() % (limit))
signed char sine_table[360];
int sine_value = 0;
int alien_proto[32], alien_score[32], score_next=0;
void print_message(char *msg, int x, int y, BOOL wiggle)
{
char res_name[128];
int c=0;
void **res;
while (msg[c] >= 32)
{
sprintf(res_name, "<Hive$Dir>.Graphics.alphabet.%d", msg[c]);
res = Popcorn_FindResource(res_name);
if (res != NULL)
if (*res != NULL)
if (wiggle)
{
Popcorn_PlotSprite(*res, x+(c*14), sine_table[((sine_value+(c*20)) % 360)] + y);
}
else
Popcorn_PlotSprite(*res, x+(c*14), y);
c++;
}
}
void make_lots_of_particles_everywhere(int x, int y, int number)
{
struct game_object *particle;
for (; number!=0; number--)
{
particle = Popcorn_NewPrototype(fx_table, 'TRAP', x, y);
if (particle == NULL)
break;
particle->xv = random(16384)-8192; particle->yv = random(16384)-8192;
particle->timer.value = random(100)+100; particle->timer.decrement = 1;
}
}
void make_explosion(int x, int y)
{
struct game_object *explosion;
explosion = Popcorn_NewPrototype(fx_table, 'LPXE', x, y);
if (explosion == NULL)
return;
explosion->timer.value = 20;
explosion->timer.decrement = 1;
make_lots_of_particles_everywhere(x, y, 30);
}
void load_scoring(void)
{
FILE *handle;
handle = fopen("<Hive$Dir>.Data.Scoring", "rb");
if (handle == NULL)
Error_ReportFatal(0, "Cannot find scores file");
while (!feof(handle))
{
fscanf(handle, "%s %d", (int) &alien_proto[score_next], &alien_score[score_next]);
score_next++;
}
fclose(handle);
}
void delete_alien(struct game_object *obj)
{
int c=0;
union object_flags reason;
struct game_object *token;
reason.word = 0;
reason.bits.collide = TRUE;
while (alien_proto[c] != obj->object_id)
c++;
if (obj->user_data == NULL)
score = score + alien_score[c];
else
score = score + (alien_score[c] * 2); /* Got it out of formation */
make_sound("<Hive$Dir>.Sounds.Explode");
make_explosion(obj->x+ (((obj->size.x>>1)-obj->plot_offset.x)<<12),
obj->y+ (((obj->size.y>>1)-obj->plot_offset.y)<<12));
if (obj->handler != NULL)
(obj->handler)( (void*) obj, reason, obj);
aliens_left--;
if (random(4) == 0)
{
token = Popcorn_NewPrototype(token_table, 'NKOT', obj->x, obj->y);
if (token != NULL)
{
token->xv = random(32768)-16384;
token->yv = -(random(16384)+16384);
}
}
Popcorn_DeleteObject(obj);
}