mirror of
https://github.com/deater/tb1.git
synced 2024-09-29 11:54:35 +00:00
v2.9.15c
This commit is contained in:
parent
74e547cb6e
commit
44d2c4d961
7
CHANGES
7
CHANGES
@ -1,3 +1,10 @@
|
|||||||
|
29 Septemer 2004
|
||||||
|
+ Backed out the half-baked "generalized level 2" changes. They made
|
||||||
|
things 10 times as complicated for no good reason. Pre-mature
|
||||||
|
optimization is the root of all evil, etc.
|
||||||
|
+ Got rid of most of the warnings.
|
||||||
|
+ Have level_2 almost working. Have to get collision detection working.
|
||||||
|
|
||||||
25 September 2004
|
25 September 2004
|
||||||
+ Started working on level3 of the game again
|
+ Started working on level3 of the game again
|
||||||
+ Updated title screen to reflect current girlfriend.
|
+ Updated title screen to reflect current girlfriend.
|
||||||
|
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
|||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
|
|
||||||
INCLUDE= $(INCLUDE_GLOBAL)
|
INCLUDE= $(INCLUDE_GLOBAL) -g
|
||||||
LIBS= $(LIBS_GLOBAL)
|
LIBS= $(LIBS_GLOBAL)
|
||||||
|
|
||||||
all: tb1
|
all: tb1
|
||||||
|
6
TODO
6
TODO
@ -1,3 +1,9 @@
|
|||||||
|
FIX LEVEL2, BULLETS PASSING THROUGH
|
||||||
|
|
||||||
|
problem is we only check top of bullet, not bottom, by just matching
|
||||||
|
the row not an actual collision detection.
|
||||||
|
|
||||||
|
|
||||||
Finish the game:
|
Finish the game:
|
||||||
Requires:
|
Requires:
|
||||||
Levels3-10. Level 3 is semi-done in pascal.
|
Levels3-10. Level 3 is semi-done in pascal.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h> /* strlen() */
|
||||||
|
|
||||||
#include "svmwgraph/svmwgraph.h"
|
#include "svmwgraph/svmwgraph.h"
|
||||||
#include "tb1_state.h"
|
#include "tb1_state.h"
|
||||||
|
@ -100,8 +100,8 @@ void write_hs_list(tb1_state *game_state,int score,char *hiname,int wipe)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wipe) {
|
if (wipe) {
|
||||||
fprintf(hilist,"Vince\nChipper\nMarie\nHairold\nKevin\n"
|
fprintf(hilist,"Vince\nChipper\nHairold\nLeonard\n"
|
||||||
"Leonard\nLizann\nPete\nJim\nBrigid\n"
|
"Susie\nJim\nPete\nBrigid\nLizann\nMarie\n"
|
||||||
"5000\n4500\n4000\n3500\n3000\n"
|
"5000\n4500\n4000\n3500\n3000\n"
|
||||||
"2500\n2000\n1500\n1000\n500\n");
|
"2500\n2000\n1500\n1000\n500\n");
|
||||||
}
|
}
|
||||||
|
491
level2_engine.c
491
level2_engine.c
@ -240,95 +240,54 @@ int free_level2_data(struct level2_data *data) {
|
|||||||
#define SND_OW 6
|
#define SND_OW 6
|
||||||
#define SND_ZRRP 7
|
#define SND_ZRRP 7
|
||||||
|
|
||||||
struct enemyinfo {
|
struct enemy_info_type {
|
||||||
|
int out;
|
||||||
int x,y;
|
int x,y;
|
||||||
int kind;
|
int yspeed;
|
||||||
int out,exploding,boundarycheck,dead;
|
int type;
|
||||||
int explodeprogress;
|
|
||||||
int minx,maxx,xspeed,yspeed;
|
|
||||||
int hitsneeded;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bullet_info_type {
|
struct bullet_info_type {
|
||||||
int out,type,x,y;
|
int out,x,y;
|
||||||
struct bullet_info_type *next,*prev;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct bullet_root_type {
|
|
||||||
int howmany,allowed;
|
|
||||||
struct bullet_info_type *head,*tail;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct obstruction_type {
|
struct obstruction_type {
|
||||||
int x,y;
|
int valid;
|
||||||
int type;
|
int type,shoots;
|
||||||
int exploding;
|
int exploding;
|
||||||
int explodeprogress;
|
int explodeprogress;
|
||||||
int howmanyhits;
|
int howmanyhits;
|
||||||
int lastshot;
|
int lastshot;
|
||||||
struct obstruction_type *next;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define BULLETS_MAX 3
|
#define BULLETS_MAX 3
|
||||||
|
#define ENEMIES_MAX 25
|
||||||
|
|
||||||
struct bullet_root_type *bullet_root;
|
struct enemy_info_type *enemies;
|
||||||
struct bullet_info_type **bullet_info;
|
|
||||||
struct bullet_info_type *temp_bullet=NULL;
|
|
||||||
|
|
||||||
|
|
||||||
void remove_bullet() {
|
|
||||||
|
|
||||||
temp_bullet->out=0;
|
|
||||||
bullet_root->howmany--;
|
|
||||||
|
|
||||||
/* Remove bullet from linked list */
|
|
||||||
if (bullet_root->head==temp_bullet) {
|
|
||||||
bullet_root->head=temp_bullet->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bullet_root->tail==temp_bullet) {
|
|
||||||
bullet_root->tail=temp_bullet->prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (temp_bullet->prev!=NULL) {
|
|
||||||
if (temp_bullet->next!=NULL)
|
|
||||||
temp_bullet->prev->next=temp_bullet->next;
|
|
||||||
else temp_bullet->prev->next=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (temp_bullet->next!=NULL) {
|
|
||||||
if (temp_bullet->prev!=NULL)
|
|
||||||
temp_bullet->next->prev=temp_bullet->prev;
|
|
||||||
else temp_bullet->next->prev=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
struct bullet_info_type *bullets;
|
||||||
|
int bullets_out=0;
|
||||||
|
|
||||||
void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
||||||
char *spritefile,char *level_num, char *level_desc,
|
char *spritefile,char *level_num, char *level_desc,
|
||||||
void *close_function)
|
void *close_function)
|
||||||
{
|
{
|
||||||
int ch,i;
|
int ch,i,temp_y;
|
||||||
char tempst[BUFSIZ];
|
char tempst[BUFSIZ];
|
||||||
int k,game_paused=0,speed_factor=1;
|
int game_paused=0;
|
||||||
int shipx=36,shipy;
|
int shipx=36,shipy;
|
||||||
int whatdelay=1;
|
int whatdelay=1;
|
||||||
int levelover=0,j,offscreen_row=0;
|
int levelover=0,j,offscreen_row=0;
|
||||||
// struct enemyinfo *enemy;
|
|
||||||
struct timeval timing_info;
|
struct timeval timing_info;
|
||||||
struct timezone dontcare;
|
struct timezone dontcare;
|
||||||
|
|
||||||
long oldsec,oldusec,time_spent;
|
long oldsec,oldusec,time_spent;
|
||||||
int howmuchscroll=200; /* there is a reason for this */
|
int howmuchscroll=200; /* there is a reason for this */
|
||||||
struct obstruction_type *obstruction_head[20];
|
struct obstruction_type obstruction[12][20];
|
||||||
struct obstruction_type obstructions[20][12];
|
|
||||||
struct obstruction_type *temp_obstruct;
|
|
||||||
int shipadd=0,shipframe=1;
|
int shipadd=0,shipframe=1;
|
||||||
int our_row,rows_goneby=0;
|
int our_row,rows_goneby=0,rows_offset=0;
|
||||||
int grapherror;
|
int grapherror;
|
||||||
int done_waiting,type;
|
int done_waiting,type;
|
||||||
|
|
||||||
@ -337,7 +296,7 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
vmwVisual *virtual_2;
|
vmwVisual *virtual_2;
|
||||||
|
|
||||||
vmwSprite *ship_shape[3];
|
vmwSprite *ship_shape[3];
|
||||||
// int enemies_drawn[200];
|
|
||||||
|
|
||||||
struct level2_data *data;
|
struct level2_data *data;
|
||||||
|
|
||||||
@ -350,7 +309,7 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
game_state->begin_score=game_state->score;
|
game_state->begin_score=game_state->score;
|
||||||
game_state->begin_shields=game_state->shields;
|
game_state->begin_shields=game_state->shields;
|
||||||
|
|
||||||
/* Load Sprite Data */
|
/* Load Sprite Data */
|
||||||
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
|
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
|
||||||
tb1_data_file(shipfile,
|
tb1_data_file(shipfile,
|
||||||
game_state->path_to_data),
|
game_state->path_to_data),
|
||||||
@ -364,7 +323,7 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
/* Load Level Data */
|
/* Load Level Data */
|
||||||
data=parse_data_file(tb1_data_file(levelfile,game_state->path_to_data));
|
data=parse_data_file(tb1_data_file(levelfile,game_state->path_to_data));
|
||||||
|
|
||||||
vmwLoadPicPacked(0,0,virtual_1,1,1,
|
vmwLoadPicPacked(0,0,virtual_1,1,1,
|
||||||
tb1_data_file(spritefile,game_state->path_to_data),
|
tb1_data_file(spritefile,game_state->path_to_data),
|
||||||
game_state->graph_state);
|
game_state->graph_state);
|
||||||
|
|
||||||
@ -373,37 +332,21 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
data->sprites[j*10+i]->data=vmwGetSprite(1+i*21,1+j*11,20,10,virtual_1);
|
data->sprites[j*10+i]->data=vmwGetSprite(1+i*21,1+j*11,20,10,virtual_1);
|
||||||
|
|
||||||
|
|
||||||
/* Initialize Structures for background */
|
/* Initialize Bullets */
|
||||||
bullet_info=calloc(5,sizeof(struct bullet_info_type *));
|
bullets=calloc(BULLETS_MAX,sizeof(struct bullet_info_type));
|
||||||
bullet_info[0]=calloc(5,sizeof(struct bullet_info_type));
|
for (i=0;i<BULLETS_MAX;i++) bullets[i].out=0;
|
||||||
for (i=1;i<5;i++) bullet_info[i]=bullet_info[0]+i*sizeof(struct bullet_info_type);
|
|
||||||
bullet_root=malloc(sizeof(struct bullet_root_type));
|
|
||||||
bullet_root->howmany=0;
|
|
||||||
bullet_root->allowed=5;
|
|
||||||
bullet_root->head=NULL;
|
|
||||||
bullet_root->tail=NULL;
|
|
||||||
for(i=0;i<bullet_root->allowed;i++) {
|
|
||||||
bullet_info[i]->out=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Initialize obstruction heap to 0 */
|
/* Initialize obstructions to zero */
|
||||||
for(j=0;j<20;j++) {
|
for(j=0;j<20;j++) {
|
||||||
for(i=0;i<12;i++) {
|
for(i=0;i<12;i++) {
|
||||||
obstructions[j][i].next=NULL;
|
obstruction[i][j].valid=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=0;i<12;i++) {
|
|
||||||
obstruction_head[i]=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize Enemies */
|
||||||
|
enemies=calloc(ENEMIES_MAX,sizeof(struct enemy_info_type));
|
||||||
|
for(i=0;i<ENEMIES_MAX;i++) enemies[i].out=0;
|
||||||
|
|
||||||
|
|
||||||
/* Announce the Start of the Level */
|
/* Announce the Start of the Level */
|
||||||
@ -432,16 +375,20 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
|
|
||||||
|
|
||||||
/* Get the initial background ready */
|
/* Get the initial background ready */
|
||||||
|
/* We copy the last 40 rows into vaddr_2 */
|
||||||
|
/* as we are scrolling bottom_up */
|
||||||
offscreen_row=data->level_length-(COL_HEIGHT*2);
|
offscreen_row=data->level_length-(COL_HEIGHT*2);
|
||||||
for(i=0;i<ROW_WIDTH;i++) {
|
for(i=0;i<ROW_WIDTH;i++) {
|
||||||
for(j=0;j<40;j++) {
|
for(j=0;j<40;j++) {
|
||||||
vmwPutSpriteNonTransparent(data->sprites[(int) *(data->level_data[offscreen_row+j]+i)]->data,
|
vmwPutSpriteNonTransparent(
|
||||||
|
data->sprites[(int) *(data->level_data[offscreen_row+j]+i)]->data,
|
||||||
i*20,j*10,virtual_2);
|
i*20,j*10,virtual_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
offscreen_row-=20;
|
offscreen_row-=20;
|
||||||
|
|
||||||
/* Get the initial obstructions ready */
|
/* Get the initial obstructions ready */
|
||||||
|
/* Get them from the last 20 rows */
|
||||||
our_row=data->level_length-20;
|
our_row=data->level_length-20;
|
||||||
for(j=0;j<20;j++) {
|
for(j=0;j<20;j++) {
|
||||||
for(i=0;i<12;i++) {
|
for(i=0;i<12;i++) {
|
||||||
@ -451,32 +398,34 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
if ((type==SPRITE_OBSTRUCTION) ||
|
if ((type==SPRITE_OBSTRUCTION) ||
|
||||||
(type==SPRITE_ENEMY_SHOOT) ||
|
(type==SPRITE_ENEMY_SHOOT) ||
|
||||||
(type==SPRITE_ENEMY_REFLECT)) {
|
(type==SPRITE_ENEMY_REFLECT)) {
|
||||||
k=0;
|
|
||||||
obstruction_head[j]=obstructions[j][0];
|
obstruction[i][j].shoots=data->sprites[*(data->level_data[our_row]+i)]->shoots;
|
||||||
temp_obstruct=obstructions[j][0];
|
obstruction[i][j].valid=1;
|
||||||
while(temp_obstruct->next!=NULL) temp_obstruct=temp_obstruct->next;
|
obstruction[i][j].type=type;
|
||||||
temp_obstruct->next=temp_obstruct+1;
|
obstruction[i][j].exploding=0;
|
||||||
temp_obstruct=temp_obstruct->next;
|
obstruction[i][j].lastshot=0;
|
||||||
temp_obstruct->x=i*20;
|
|
||||||
temp_obstruct->y=j*20;
|
|
||||||
temp_obstruct->type=type;
|
|
||||||
temp_obstruct->exploding=0;
|
|
||||||
temp_obstruct->lastshot=0;
|
|
||||||
temp_obstruct->next=NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* howmuchscroll is originally 200, as we start at the bottom */
|
||||||
vmwArbitraryCrossBlit(virtual_2,0,0+howmuchscroll,240,200,
|
vmwArbitraryCrossBlit(virtual_2,0,0+howmuchscroll,240,200,
|
||||||
virtual_1,0,0);
|
virtual_1,0,0);
|
||||||
|
|
||||||
/**** GAME LOOP ****/
|
|
||||||
|
|
||||||
|
/************************************************************/
|
||||||
|
/* MAIN LEVEL 2 GAME LOOP */
|
||||||
|
/************************************************************/
|
||||||
|
|
||||||
while (!levelover) {
|
while (!levelover) {
|
||||||
|
|
||||||
ch=0;
|
ch=0;
|
||||||
|
|
||||||
/* Scroll the Background */
|
/* Scroll the Background */
|
||||||
if (speed_factor>1) howmuchscroll-=speed_factor;
|
howmuchscroll--;
|
||||||
else howmuchscroll--;
|
rows_offset++;
|
||||||
|
|
||||||
/* If used up all the buffered background, draw some more */
|
/* If used up all the buffered background, draw some more */
|
||||||
if (howmuchscroll<0) {
|
if (howmuchscroll<0) {
|
||||||
@ -495,101 +444,113 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
|
|
||||||
|
|
||||||
/* Setup Obstructions */
|
/* Setup Obstructions */
|
||||||
if (rows_goneby%10==0) {
|
if (rows_offset==10) {
|
||||||
|
|
||||||
|
rows_offset=0;
|
||||||
|
|
||||||
/* move all rows down by one, dropping old off end */
|
/* move all rows down by one, dropping old off end */
|
||||||
memmove(obstructions[1],obstructions[0],
|
memmove(&obstruction[0][1],&obstruction[0][0],
|
||||||
19*12*sizeof(struct obstruction_type));
|
19*12*sizeof(struct obstruction_type));
|
||||||
memmove(obstruction_head[1],obstruction_head[0],
|
|
||||||
19*sizeof(struct *obstruction_type));
|
|
||||||
obstructions[0]->next=NULL;
|
|
||||||
our_row--;
|
our_row--;
|
||||||
// printf("ROW %i\n",our_row);
|
|
||||||
temp_obstruct=obstructions[0];
|
|
||||||
for(i=0;i<12;i++) {
|
for(i=0;i<12;i++) {
|
||||||
type=data->sprites[*(data->level_data[our_row]+i)]->type;
|
type=data->sprites[*(data->level_data[our_row]+i)]->type;
|
||||||
// printf("%3i ",type);
|
|
||||||
if ((type==SPRITE_OBSTRUCTION) ||
|
if ((type==SPRITE_OBSTRUCTION) ||
|
||||||
(type==SPRITE_ENEMY_SHOOT) ||
|
(type==SPRITE_ENEMY_SHOOT) ||
|
||||||
(type==SPRITE_ENEMY_REFLECT)) {
|
(type==SPRITE_ENEMY_REFLECT)) {
|
||||||
// printf("*");
|
|
||||||
// printf("Enemy %i on row %i\n",type,our_row);
|
obstruction[i][0].shoots=data->sprites[*(data->level_data[our_row]+i)]->shoots;
|
||||||
// fflush(stdout);
|
obstruction[i][0].valid=1;
|
||||||
while(temp_obstruct->next!=NULL) temp_obstruct=temp_obstruct->next;
|
obstruction[i][0].type=type;
|
||||||
temp_obstruct->next=temp_obstruct+1;
|
obstruction[i][0].exploding=0;
|
||||||
temp_obstruct=temp_obstruct+1;
|
obstruction[i][0].lastshot=0;
|
||||||
temp_obstruct->x=i*20;
|
|
||||||
temp_obstruct->y=j*20;
|
|
||||||
temp_obstruct->type=type;
|
|
||||||
temp_obstruct->exploding=0;
|
|
||||||
temp_obstruct->lastshot=0;
|
|
||||||
temp_obstruct->next=NULL;
|
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
// printf("\n"); fflush(stdout);
|
obstruction[i][0].valid=0;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!enemies_drawn[our_row]) {
|
|
||||||
enemies_drawn[our_row]=1;
|
|
||||||
for(i=0;i<12;i++) {
|
|
||||||
// our_shape=background[our_row][i];
|
|
||||||
if ((our_shape>9)&&(our_shape<20)) {
|
|
||||||
k=0;
|
|
||||||
while ((!passive[k].dead) && (k<40)) k++;
|
|
||||||
passive[k].dead=0;
|
|
||||||
passive[k].kind=our_shape;
|
|
||||||
if ((our_shape>10) && (our_shape<15)) passive[k].shooting=1;
|
|
||||||
else passive[k].shooting=0;
|
|
||||||
passive[k].exploding=0;
|
|
||||||
passive[k].x=i*20;
|
|
||||||
passive[k].y=(rows_goneby%10)-9;
|
|
||||||
passive[k].howmanyhits=1;
|
|
||||||
passive[k].lastshot=0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Flip the far background to regular background */
|
/* Flip the far background to regular background */
|
||||||
vmwArbitraryCrossBlit(virtual_2,0,0+howmuchscroll,240,200,
|
vmwArbitraryCrossBlit(virtual_2,0,0+howmuchscroll,240,200,
|
||||||
virtual_1,0,0);
|
virtual_1,0,0);
|
||||||
|
|
||||||
/***Collision Check***/
|
/***Collision Check***/
|
||||||
for(i=0;i<bullet_root->howmany;i++) {
|
for(i=0;i<BULLETS_MAX;i++) {
|
||||||
temp_obstruct=obstructions[ (bullet_info[i]->y)/10];
|
if (bullets[i].out) {
|
||||||
// printf("%p %p\n",temp_obstruct,temp_obstruct->next);
|
temp_y=(bullets[i].y)/10;
|
||||||
// printf("Row %i\n",(bullet_info[i]->y)/10); fflush(stdout);
|
for(j=0;j<12;j++) {
|
||||||
while (temp_obstruct->next!=NULL) {
|
if (obstruction[j][temp_y].valid) {
|
||||||
temp_obstruct=temp_obstruct->next;
|
if ( ( (bullets[i].x) >= j*20) &&
|
||||||
if ( ( (bullet_info[i]->x-3) >= temp_obstruct->x) &&
|
( bullets[i].x <= j*20+17)) {
|
||||||
( bullet_info[i]->x <= (temp_obstruct->x+20))) {
|
|
||||||
|
|
||||||
if (temp_obstruct->type!=SPRITE_ENEMY_REFLECT) {
|
if (obstruction[j][temp_y].type!=SPRITE_ENEMY_REFLECT) {
|
||||||
if ((game_state->sound_possible)&&(game_state->sound_enabled))
|
if ((game_state->sound_possible)&&(game_state->sound_enabled))
|
||||||
playGameFX(SND_KAPOW);
|
playGameFX(SND_KAPOW);
|
||||||
temp_obstruct->exploding=1;
|
obstruction[j][temp_y].exploding=1;
|
||||||
temp_obstruct->explodeprogress=0;
|
obstruction[j][temp_y].explodeprogress=0;
|
||||||
temp_bullet=bullet_info[i];
|
bullets[i].out=0;
|
||||||
remove_bullet();
|
bullets_out--;
|
||||||
game_state->score+=10;
|
game_state->score+=10;
|
||||||
changescore(game_state);
|
changescore(game_state);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// bullet[j].out=0;
|
else {
|
||||||
// k=0;
|
int k=0;
|
||||||
// while ((!enemy[k].out) && (k<10)) k++;
|
|
||||||
// if (k<9) {
|
while(enemies[k].out) k++;
|
||||||
// enemy[k].out=1;
|
if (k<ENEMIES_MAX) {
|
||||||
// enemy[k].y=bullet[j].y;
|
bullets[i].out=0;
|
||||||
// enemy[k].x=bullet[j].x;
|
bullets_out--;
|
||||||
// enemy[k].yspeed=7;
|
|
||||||
// enemy[k].kind=21;
|
enemies[k].out=1;
|
||||||
// }
|
enemies[k].type=obstruction[j][temp_y].shoots;
|
||||||
}
|
enemies[k].yspeed=5;
|
||||||
|
enemies[k].x=bullets[i].x;
|
||||||
|
enemies[k].y=bullets[i].y;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for(i=0;i<12;i++) {
|
||||||
|
for(j=0;j<20;j++) {
|
||||||
|
|
||||||
|
if (obstruction[i][j].valid) {
|
||||||
|
if (obstruction[i][j].type==SPRITE_ENEMY_SHOOT) {
|
||||||
|
obstruction[i][j].lastshot++;
|
||||||
|
if (obstruction[i][j].lastshot>50) {
|
||||||
|
int k=0;
|
||||||
|
|
||||||
|
obstruction[i][j].lastshot=rand()%10;
|
||||||
|
while(enemies[k].out) k++;
|
||||||
|
if (k<ENEMIES_MAX) {
|
||||||
|
enemies[k].out=1;
|
||||||
|
enemies[k].x=(i*20)+10;
|
||||||
|
enemies[k].y=(j*10)+5;
|
||||||
|
enemies[k].yspeed=4;
|
||||||
|
enemies[k].type=obstruction[i][j].shoots;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// printf("BOOM\n"); fflush(stdout);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,36 +562,6 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
for(i=0;i<40;i++)
|
|
||||||
if ((!passive[i].dead) && (!passive[i].exploding)) {
|
|
||||||
for(j=0;j<3;j++) {
|
|
||||||
if ((bullet[j].out) &&
|
|
||||||
(collision(bullet[j].x,bullet[j].y,3,4,passive[i].x,
|
|
||||||
passive[i].y,10,5))){
|
|
||||||
if (passive[i].kind!=10) {
|
|
||||||
if ((game_state->sound_possible)&&(game_state->sound_enabled))
|
|
||||||
playGameFX(SND_KAPOW);
|
|
||||||
passive[i].exploding=1;
|
|
||||||
passive[i].explodeprogress=0;
|
|
||||||
bullet[j].out=0;
|
|
||||||
game_state->score+=10;
|
|
||||||
changescore(game_state);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bullet[j].out=0;
|
|
||||||
k=0;
|
|
||||||
while ((!enemy[k].out) && (k<10)) k++;
|
|
||||||
if (k<9) {
|
|
||||||
enemy[k].out=1;
|
|
||||||
enemy[k].y=bullet[j].y;
|
|
||||||
enemy[k].x=bullet[j].x;
|
|
||||||
enemy[k].yspeed=7;
|
|
||||||
enemy[k].kind=21;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* See if ship is hitting any Obstructions*/
|
/* See if ship is hitting any Obstructions*/
|
||||||
if ((passive[i].y>155) && (passive[i].kind!=10)) {
|
if ((passive[i].y>155) && (passive[i].kind!=10)) {
|
||||||
if ((collision(passive[i].x,passive[i].y,10,5,shipx+16,165,5,5))||
|
if ((collision(passive[i].x,passive[i].y,10,5,shipx+16,165,5,5))||
|
||||||
@ -661,37 +592,49 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***DO EXPLOSIONS***/
|
|
||||||
for(i=0;i<40;i++)
|
|
||||||
if (passive[i].exploding) {
|
|
||||||
passive[i].explodeprogress++;
|
|
||||||
// vmwPutSprite(shape_table[35+passive[i].explodeprogress],
|
|
||||||
// passive[i].x,passive[i].y+howmuchscroll,
|
|
||||||
// virtual_2);
|
|
||||||
if (passive[i].explodeprogress>3) {
|
|
||||||
passive[i].dead=1;
|
|
||||||
passive[i].exploding=0;
|
|
||||||
// vmwPutSprite(shape_table[34],
|
|
||||||
// passive[i].x,passive[i].y+howmuchscroll,
|
|
||||||
// virtual_2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
/***MOVE BULLETS***/
|
|
||||||
|
|
||||||
temp_bullet=bullet_root->head;
|
|
||||||
while(temp_bullet!=NULL) {
|
|
||||||
if (speed_factor>1) temp_bullet->y-=(5*speed_factor);
|
|
||||||
else temp_bullet->y-=5;
|
|
||||||
if (temp_bullet->y<5) {
|
|
||||||
|
|
||||||
remove_bullet();
|
|
||||||
|
|
||||||
|
|
||||||
|
/***DO EXPLOSIONS***/
|
||||||
|
for(i=0;i<12;i++) {
|
||||||
|
for(j=0;j<20;j++) {
|
||||||
|
if (obstruction[i][j].valid) {
|
||||||
|
if (obstruction[i][j].exploding) {
|
||||||
|
obstruction[i][j].explodeprogress++;
|
||||||
|
|
||||||
|
vmwPutSprite(data->sprites[35+(obstruction[i][j].explodeprogress)/2]->data,
|
||||||
|
// shape_table[35+passive[i].explodeprogress],
|
||||||
|
i*20,j*10+howmuchscroll+rows_offset,
|
||||||
|
virtual_2);
|
||||||
|
if (obstruction[i][j].explodeprogress>6) {
|
||||||
|
obstruction[i][j].valid=0;
|
||||||
|
vmwPutSprite(data->sprites[34]->data,
|
||||||
|
i*20,j*10+howmuchscroll+rows_offset,
|
||||||
|
virtual_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else vmwPutSprite(data->sprites[temp_bullet->type]->data,
|
}
|
||||||
temp_bullet->x,temp_bullet->y,virtual_1);
|
|
||||||
temp_bullet=temp_bullet->next;
|
/***MOVE BULLETS***/
|
||||||
|
for(i=0;i<BULLETS_MAX;i++) {
|
||||||
|
if (bullets[i].out) {
|
||||||
|
bullets[i].y-=4;
|
||||||
|
if (bullets[i].y<4) {
|
||||||
|
bullets[i].out=0;
|
||||||
|
bullets_out--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
vmwPutSprite(data->sprites[20]->data,
|
||||||
|
|
||||||
|
bullets[i].x,
|
||||||
|
bullets[i].y,virtual_1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -718,18 +661,21 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
/* Draw Enemies */
|
||||||
|
for(j=0;j<ENEMIES_MAX;j++) {
|
||||||
|
if (enemies[j].out) {
|
||||||
|
if (enemies[j].y>189) enemies[j].out=0;
|
||||||
|
else {
|
||||||
|
vmwPutSprite(data->sprites[enemies[j].type]->data,
|
||||||
|
enemies[j].x,enemies[j].y,
|
||||||
|
virtual_1);
|
||||||
|
enemies[j].y+=enemies[j].yspeed;
|
||||||
|
}
|
||||||
|
|
||||||
for(j=0;j<10;j++) {
|
|
||||||
if (enemy[j].out) {
|
|
||||||
// vmwPutSprite(shape_table[enemy[j].kind],
|
|
||||||
// enemy[j].x,enemy[j].y,
|
|
||||||
// virtual_1);
|
|
||||||
if (speed_factor==1) enemy[j].y+=enemy[j].yspeed;
|
|
||||||
else enemy[j].y+=(enemy[j].yspeed*speed_factor);
|
|
||||||
if (enemy[j].y>189) enemy[j].out=0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/***READ KEYBOARD***/
|
/***READ KEYBOARD***/
|
||||||
if ((ch=vmwGetInput())!=0) {
|
if ((ch=vmwGetInput())!=0) {
|
||||||
@ -752,53 +698,37 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
case VMW_F2: game_paused=1;
|
case VMW_F2: game_paused=1;
|
||||||
savegame(game_state);
|
savegame(game_state);
|
||||||
break;
|
break;
|
||||||
case ' ': if (bullet_root->howmany<BULLETS_MAX) {
|
case ' ':
|
||||||
/* Find empty slot */
|
i=0;
|
||||||
for (j=0;j<bullet_root->allowed;j++) {
|
while(bullets[i].out) i++;
|
||||||
if (!bullet_info[j]->out) {
|
if (i<BULLETS_MAX) {
|
||||||
temp_bullet=bullet_info[j];
|
bullets_out++;
|
||||||
break;
|
bullets[i].out=1;
|
||||||
}
|
if ((game_state->sound_possible)&&(game_state->sound_enabled))
|
||||||
}
|
playGameFX(SND_CC);
|
||||||
bullet_root->howmany++;
|
bullets[i].x=shipx+21;
|
||||||
temp_bullet->out=1;
|
bullets[i].y=165;
|
||||||
temp_bullet->type=20; /* FIXME */
|
|
||||||
if ((game_state->sound_possible)&&(game_state->sound_enabled))
|
|
||||||
playGameFX(SND_CC);
|
|
||||||
temp_bullet->x=shipx+21;
|
|
||||||
temp_bullet->y=165;
|
|
||||||
temp_bullet->next=NULL;
|
|
||||||
/* Insert in linked list */
|
|
||||||
if (bullet_root->head==NULL) {
|
|
||||||
bullet_root->head=temp_bullet;
|
|
||||||
bullet_root->tail=temp_bullet;
|
|
||||||
temp_bullet->prev=NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
temp_bullet->prev=bullet_root->tail;
|
|
||||||
bullet_root->tail->next=temp_bullet;
|
|
||||||
bullet_root->tail=temp_bullet;
|
|
||||||
}
|
|
||||||
/* Draw Bullet */
|
|
||||||
|
|
||||||
vmwPutSprite(data->sprites[temp_bullet->type]->data,
|
vmwPutSprite(data->sprites[20]->data,
|
||||||
temp_bullet->x,temp_bullet->y,virtual_1);
|
bullets[i].x,
|
||||||
|
bullets[i].y,virtual_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***MOVE SHIP***/
|
/***MOVE SHIP***/
|
||||||
// if (speed_factor>1) {
|
|
||||||
// shipx+=(shipadd*speed_factor);
|
|
||||||
// rows_goneby+=(speed_factor);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
shipx+=shipadd;
|
shipx+=shipadd;
|
||||||
|
|
||||||
rows_goneby++;
|
rows_goneby++;
|
||||||
// }
|
|
||||||
|
|
||||||
|
/* Keep ship on screen */
|
||||||
if (shipx<1) shipx=1;
|
if (shipx<1) shipx=1;
|
||||||
if (shipx>190) shipx=190;
|
if (shipx>190) shipx=190;
|
||||||
switch(shipframe) {
|
switch(shipframe) {
|
||||||
@ -845,7 +775,9 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*printf("%i\n",rows_goneby);*/
|
/* The leve is over */
|
||||||
|
/* FIXME autocalculate rather than 1950 */
|
||||||
|
|
||||||
if (rows_goneby>1950) {
|
if (rows_goneby>1950) {
|
||||||
// printf("%i\n",rows_goneby);
|
// printf("%i\n",rows_goneby);
|
||||||
// coolbox(35,85,215,110,1,virtual_1);
|
// coolbox(35,85,215,110,1,virtual_1);
|
||||||
@ -946,6 +878,7 @@ void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
|
|||||||
pauseawhile(2);
|
pauseawhile(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if (shipx-95==0) shipadd=0;
|
if (shipx-95==0) shipadd=0;
|
||||||
if (shipx-95>0) shipadd=1;
|
if (shipx-95>0) shipadd=1;
|
||||||
|
1
quit.c
1
quit.c
@ -1,5 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h> /* exit() */
|
||||||
|
|
||||||
#include "svmwgraph/svmwgraph.h"
|
#include "svmwgraph/svmwgraph.h"
|
||||||
#include "tb1_state.h"
|
#include "tb1_state.h"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* Routines for drawing the sidebar */
|
/* Routines for drawing the sidebar */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h> /* strlen() */
|
||||||
|
|
||||||
#include "svmwgraph/svmwgraph.h"
|
#include "svmwgraph/svmwgraph.h"
|
||||||
#include "tb1_state.h"
|
#include "tb1_state.h"
|
||||||
|
2
sound.c
2
sound.c
@ -75,7 +75,7 @@ int initSound(char *path_to_data) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
|
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
|
||||||
printf("+ Opened audio at %d Hz %d bit %s\n", audio_rate,
|
printf(" + Opened audio at %d Hz %d bit %s\n", audio_rate,
|
||||||
(audio_format&0xFF),
|
(audio_format&0xFF),
|
||||||
(audio_channels > 1) ? "stereo" : "mono");
|
(audio_channels > 1) ? "stereo" : "mono");
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "svmwgraph.h"
|
#include "svmwgraph.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h> /* memset */
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <stdio.h> /* For File I/O */
|
#include <stdio.h> /* For File I/O */
|
||||||
#include <stdlib.h> /* For malloc/calloc */
|
#include <stdlib.h> /* For malloc/calloc */
|
||||||
|
#include <string.h> /* strlen() */
|
||||||
|
|
||||||
/* The font used is a standard VGA font. */
|
/* The font used is a standard VGA font. */
|
||||||
/* To use the "smallText" functions, the VGA font */
|
/* To use the "smallText" functions, the VGA font */
|
||||||
|
1
tblib.c
1
tblib.c
@ -2,6 +2,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h> /* abs */
|
||||||
#include "svmwgraph/svmwgraph.h"
|
#include "svmwgraph/svmwgraph.h"
|
||||||
#include "tb1_state.h"
|
#include "tb1_state.h"
|
||||||
#include "graphic_tools.h"
|
#include "graphic_tools.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user