This commit is contained in:
Vince Weaver 2000-11-02 01:45:00 -05:00
parent b8225aed5d
commit 811c45211f
16 changed files with 803 additions and 527 deletions

View File

@ -1,3 +1,11 @@
2 November 2000
+ Continued re-writing the level_1 engine that I started last week.
+ Re-wrote frame limiter. Managed to make it a lot less jumpy.
28 October 2000
+ Finished porting the Level2->Level3 cut-scenes
+ Really crude level3 engine.
27 October 2000
+ Started writing an opengl target. Was hoping for a cool tb1 rotating
on the side of a cube type deal. Had some fights with glut and decided

14
README
View File

@ -53,15 +53,15 @@ Then a "make" should compile it.
2.0 System Requirements
---------------------------------------------------------------------
Reccommended Minimum:
486 66Mhz/ 8MB Ram, 1Meg disk space
486 66Mhz/ 8MB Ram, 2Meg disk space
The game was originally written on a 386 33Mhz under DOS.
It has been tested to run fine on my 486 75Mhz laptop
w 12Mb ram and 8bpp display.
The game has not been verified to run on 64 bit or big-endian machines.
Currently tested to work on the following targets:
+ Linux 2.4.x K6-2+ 450Mhz 160MB RAM (sdl/curses)
+ Linux 2.2.x 486 75Mhz 12MB RAM (sdl/curses)
+ Solaris 7, SMP UltraSPARC (curses)
3.0 STARTING THE GAME
---------------------------------------------------------------------

12
TB1.FAQ
View File

@ -61,3 +61,15 @@ Q7). Your "Tentaclee" aliens look like aliens from Commander Keen. Did
A7). I've been drawing aliens like that from before Commander Keen was
published, and I can produce sketches to show it. It is just some
weird co-incidence.
Q8). Why can't I shoot more than 2 or 3 missiles at a time?
A8). For game balancing issues. [And also because of speed/memory
constraints, but on modern systems that doesn't matter anymore].
Come on, what's the fun if you can pulverize everything with
a volley of 20 missiles?
If you really must have more, then you can probably find the
proper define in the source code and up the limit yourself.

View File

@ -5,9 +5,9 @@ Hairold
Kevin
Leonard
Lizann
ZURGTROYD
Bon
Pete
Vince
Jim
5000
4500
4000
@ -15,6 +15,6 @@ Pete
3000
2500
2000
1670
1520
1500
1160
1000

Binary file not shown.

Binary file not shown.

BIN
data/music/boss1.mod Normal file

Binary file not shown.

622
level_1.c
View File

@ -1,5 +1,8 @@
/*
Level 1 Engine Code for Tom Bombem
*
* November 2000 -- Changed the inner workings of engine.
* Now somewhat different than original feel.
*/
/* The Includes */
@ -21,7 +24,7 @@
#include "graphic_tools.h"
/* Define this to get a frames per second readout */
/* #define DEBUG_ON */
#define DEBUG_ON
/* The sounds */
@ -35,6 +38,10 @@
#define SND_OW 6
#define SND_ZRRP 7
#define NUM_ENEMIES 5
#define NUM_MISSILES 2
struct enemyinfo {
int x,y;
int kind;
@ -44,32 +51,67 @@ struct enemyinfo {
int hitsneeded;
};
struct bulletinfo {
struct missileinfo {
int out,x,y;
};
/* Define how many sound effects there are */
/* o/~ more structures o/~ */
struct enemyinfo enemy[5];
struct bulletinfo bullet[3];
/* Global Variables*/
struct enemyinfo enemy[NUM_ENEMIES];
struct missileinfo missile[NUM_MISSILES];
struct timeval timing_info;
struct timezone dontcare;
int enemies_out;
#define LEVEL_OVER 9
#define STANDARD 0
#define DIAGONAL 1
#define DIAGONAL_NO_WAIT 2
#define WIGGLING 3
#define RAINING 4
#define SCROLL_A_BIT 7
#define BEFORE_BOSS 10
#define BOSS_BEHAVIOR 11
#define AFTER_BOSS 12
#define BOSS_DESTROYED 13
#define INVISIBLE_WAVE 15
#define THE_END 100
typedef struct {
int enemy_type;
int how_many;
}level_one_behavior_t;
/* This seemed like a good idea to modularize things */
int level_one_wave_behavior[]=
{0,0,0,0,0, 1,1,1,1,1,
1,1,2,2,2, 2,2,2,2,2,
3,3,3,3,3, 3,3,3,3,3,
2,2,2,2,2, 2,3,3,3,3,
3,3,3,3,3, 3,1,1,1,1,
1,3,3,3,3, 3,3,3,3,3,
3,2,2,2,2, 2,2,2,2,2,
2,2,2,2,2, 2,1,1,1,1,
1,1,1,3,3, 3,2,2,2,2,
2,2,2,2,2, 2,1,1,1,1,
1,4,4,4,4};
level_one_behavior_t level_one_wave_behavior[]=
{{STANDARD,5},
{STANDARD,5},
{DIAGONAL,5},
{DIAGONAL_NO_WAIT,5},
{WIGGLING,8},
{RAINING,10},
{WIGGLING,6},
{RAINING,12},
{DIAGONAL,5},
{RAINING,10},
{WIGGLING,16},
{DIAGONAL,5},
{DIAGONAL_NO_WAIT,5},
{RAINING,3},
{WIGGLING,10},
{DIAGONAL,5},
{SCROLL_A_BIT,100},
{BEFORE_BOSS,1},
{SCROLL_A_BIT,100},
{BOSS_BEHAVIOR,1},
{BOSS_DESTROYED,100},
{AFTER_BOSS,1},
{THE_END,1}};
@ -182,154 +224,246 @@ void afterboss(tb1_state *game_state)
/* Defines the behavior of the objects in level 1 */
int level_one_behavior(int reset, tb1_state *game_state)
{
int what,temp,whichone,need_to_pause=0;
static int wave=0;
static int saucersout=0;
/* Should change so it works even if NUM_ENEMIES>5 */
int add_another_enemy(int start_of_level,
tb1_state *game_state) {
int what_type,i,need_to_pause=0;
static int wave_pointer=0;
static int wait_full_wave=0;
static int enemies_left_in_wave=0;
static int fighting_boss=0;
if (reset) {
wave=0;
saucersout=0;
/* If re-initing, then clear some variables */
/* If we don't do this, the static variables won't get reset */
/* After Level1 starts over [i.e. you die] */
if (start_of_level) {
wave_pointer=0;
enemies_out=0;
enemies_left_in_wave=0;
fighting_boss=0;
}
if (level_one_wave_behavior[wave]!=4) wave++;
saucersout--;
if (saucersout<0) saucersout=0;
if (saucersout>5) saucersout=5;
/* **START NEW WAVE ***/
/* If waiting for empty, then return w/o adding any */
if ((wait_full_wave) && (enemies_out)) return 0;
else {
wait_full_wave=0;
}
// if (level_one_wave_behavior[behavior_pointer]!=BOSS_BEHAVIOR) behavior_pointer++;
/* In order to be called, an enemy was destroyed */
switch(level_one_wave_behavior[wave]) {
/* Are these sanity checks needed? */
if (enemies_out<0) {
enemies_out=0;
printf("Blargh 0\n");
}
if (enemies_out>NUM_ENEMIES) {
enemies_out=NUM_ENEMIES;
printf("Blargh 7\n");
}
if (enemies_left_in_wave<=0) {
wave_pointer++;
enemies_left_in_wave=level_one_wave_behavior[wave_pointer].how_many;
}
/* Move on to next behvior */
switch(level_one_wave_behavior[wave_pointer].enemy_type) {
/* STANDARD */
case 0: if (saucersout==0) {
saucersout=5;
what=(3+rand()%8);
for(temp=0; temp<5; temp++) {
enemy[temp].kind=what;
enemy[temp].x=0;
enemy[temp].y=0;
enemy[temp].xspeed=5;
enemy[temp].x=temp*20;
enemy[temp].minx=(temp*20);
enemy[temp].maxx=(temp*20)+120;
enemy[temp].boundarycheck=1;
enemy[temp].yspeed=10;
enemy[temp].out=1;
enemy[temp].exploding=0;
enemy[temp].hitsneeded=1;
enemy[temp].dead=0;
/* That is, 5 enemies bouncing back/forth, gradually lowering*/
case STANDARD:
/* We add all 5 at once, so there better not be anything else out */
if (enemies_out==0) {
enemies_out=5;
enemies_left_in_wave-=5;
wait_full_wave=1;
/* Randomly pick what type they are */
what_type=(2+rand()%8);
for(i=0; i<5; i++) {
enemy[i].kind=what_type;
enemy[i].x=i*20; /* Space them in one line */
enemy[i].y=0;
enemy[i].xspeed=5;
enemy[i].minx=(i*20); /* Make sure they "bounce" */
enemy[i].maxx=(i*20)+120; /* Properly even when some */
enemy[i].boundarycheck=1; /* Destroyed */
enemy[i].yspeed=10;
enemy[i].out=1;
enemy[i].exploding=0;
enemy[i].hitsneeded=1;
enemy[i].dead=0;
}
}
} break;
break;
/* *FALLING STRAIGHT* */
case 3:
for (temp=0; temp<5;temp++)
if (!enemy[temp].out) {
enemy[temp].kind=rand()%8+3;
enemy[temp].x=rand()%200+1;
enemy[temp].y=0;
enemy[temp].xspeed=0;
enemy[temp].minx=enemy[temp].x;
enemy[temp].maxx=enemy[temp].x;
enemy[temp].boundarycheck=1;
enemy[temp].yspeed=5+(wave/40);
enemy[temp].out=1;
enemy[temp].exploding=0;
enemy[temp].hitsneeded=1;
enemy[temp].dead=0;
saucersout++;
} break;
/* That is, raining down from above */
case RAINING:
/* Fill up all empty slots? Interesting behavior */
for(i=0; i<5;i++) {
if ((!enemy[i].out) && ( (rand()%5)==3) ){
enemies_left_in_wave--;
enemy[i].kind=rand()%8+2;
enemy[i].x=rand()%200+1;
enemy[i].y=0;
enemy[i].xspeed=0;
enemy[i].minx=enemy[i].x; /* Hacky way of making sure they */
enemy[i].maxx=enemy[i].x; /* Fall vertically */
enemy[i].boundarycheck=1;
enemy[i].yspeed=5+(wave_pointer/8); /* Fall faster as game */
/* goes on */
enemy[i].out=1;
enemy[i].exploding=0;
enemy[i].hitsneeded=1;
enemy[i].dead=0;
enemies_out++;
}
}
break;
/* *FALLING GRADUALLY SIDEWAYS* */
case 2:
for(temp=0;temp<5;temp++)
if (!enemy[temp].out) {
enemy[temp].kind=rand()%8+3;
enemy[temp].y=0;
enemy[temp].xspeed=5;
enemy[temp].minx=rand()%100;
enemy[temp].maxx=rand()%100+120;
enemy[temp].x=enemy[temp].minx;
enemy[temp].boundarycheck=0;
enemy[temp].yspeed=1;
enemy[temp].out=1;
enemy[temp].exploding=0;
enemy[temp].hitsneeded=1;
enemy[temp].dead=0;
saucersout++;
} break;
/* AKA Wiggling back and forth independently */
case WIGGLING:
for(i=0;i<5;i++) {
if (!enemy[i].out) {
enemies_left_in_wave--;
enemy[i].kind=rand()%8+2;
enemy[i].y=0;
enemy[i].xspeed=5;
enemy[i].minx=rand()%100; /* Set a random range to "wiggle */
enemy[i].maxx=rand()%100+120;
enemy[i].x=enemy[i].minx;
enemy[i].boundarycheck=0;
enemy[i].yspeed=1; /* Constantly Fall */
enemy[i].out=1;
enemy[i].exploding=0;
enemy[i].hitsneeded=1;
enemy[i].dead=0;
enemies_out++;
}
}
break;
/**ZIG-ZAG**/
case 1: if (!saucersout) {
saucersout=5;
whichone=rand()%8+3;
for(temp=0;temp<5;temp++)
if (!enemy[temp].out) {
enemy[temp].kind=whichone;
enemy[temp].y=temp*10;
enemy[temp].xspeed=5;
enemy[temp].minx=0;
enemy[temp].maxx=220;
enemy[temp].x=temp*20;
enemy[temp].boundarycheck=0;
enemy[temp].yspeed=1;
enemy[temp].out=1;
enemy[temp].exploding=0;
enemy[temp].hitsneeded=1;
enemy[temp].dead=0;
}
} break;
/* That is, fall in a diagonal formation */
case DIAGONAL:
if (!enemies_out) wait_full_wave=1;
case DIAGONAL_NO_WAIT:
/* Another one of these that we need all to be empty */
if (!enemies_out) {
enemies_out=5;
enemies_left_in_wave-=5;
what_type=rand()%8+2;
for(i=0;i<5;i++) {
if (!enemy[i].out) {
enemy[i].kind=what_type;
enemy[i].x=i*20; /* Nice diagonal pattern */
enemy[i].y=i*10;
enemy[i].xspeed=5;
enemy[i].minx=0;
enemy[i].maxx=220;
enemy[i].boundarycheck=0;
enemy[i].yspeed=1; /* Gradually fall */
enemy[i].out=1;
enemy[i].exploding=0;
enemy[i].hitsneeded=1;
enemy[i].dead=0;
}
}
}
break;
case SCROLL_A_BIT:
enemies_left_in_wave--;
break;
case BEFORE_BOSS:
beforeboss(game_state);
enemies_left_in_wave--;
if ((game_state->sound_possible) &&(game_state->music_enabled)) {
loadSound(tb1_data_file("music/boss1.mod",game_state->path_to_data));
playSound();
}
break;
case BOSS_DESTROYED:
enemies_left_in_wave--;
if ((enemies_left_in_wave>25) && ( !(enemies_left_in_wave%3)) &&
(game_state->sound_possible)&&(game_state->sound_enabled)) {
playGameFX(SND_KAPOW);
}
break;
case AFTER_BOSS:
stopSound();
afterboss(game_state);
enemies_left_in_wave--;
break;
case THE_END:
return LEVEL_OVER;
/* Beginning of Boss */
case 4:
if (!saucersout) {
beforeboss(game_state);
need_to_pause=1;
enemy[0].kind=15;
enemy[1].kind=15;
enemy[2].kind=14;
for(temp=0;temp<3;temp++) {
enemy[temp].x=(temp*20)+10;
enemy[temp].y=0;
enemy[temp].xspeed=5;
enemy[temp].minx=0;
enemy[temp].maxx=220;
enemy[temp].boundarycheck=1;
enemy[temp].yspeed=0;
enemy[temp].out=1;
enemy[temp].exploding=0;
enemy[temp].hitsneeded=3;
enemy[temp].dead=0;
saucersout++;
case BOSS_BEHAVIOR:
if ((!enemies_out) && (!fighting_boss)) {
fighting_boss=1;
enemy[0].kind=14;
enemy[1].kind=14;
enemy[2].kind=13;
for(i=0;i<3;i++) {
enemy[i].x=(i*20)+10;
enemy[i].y=0;
enemy[i].xspeed=5;
enemy[i].minx=0;
enemy[i].maxx=220;
enemy[i].boundarycheck=1;
enemy[i].yspeed=0;
enemy[i].out=1;
enemy[i].exploding=0;
enemy[i].hitsneeded=5;
enemy[i].dead=0;
enemies_out++;
}
} break;
default: break;
}
if (fighting_boss) {
/* Objects Cast off by the Boss */
if (enemy[1].kind==15) {
/* Detect if Level One is Over */
if ((enemy[0].dead) && (enemy[1].dead) && (enemy[2].dead)) return 9;
for(temp=3;temp<5;temp++) {
saucersout++;
if ((!enemy[temp].out) && (enemy[temp-3].out)) {
enemy[temp].kind=rand()%8+3;
enemy[temp].x=enemy[temp-3].x;
enemy[temp].y=20;
enemy[temp].xspeed=0;
enemy[temp].minx=enemy[temp].x;
enemy[temp].maxx=enemy[temp].x;
enemy[temp].boundarycheck=0;
enemy[temp].yspeed=4;
enemy[temp].out=1;
enemy[temp].exploding=0;
enemy[temp].hitsneeded=1;
enemy[temp].dead=0;
}
/* Detect if Level One is Over */
if ((enemy[0].dead) && (enemy[1].dead) && (enemy[2].dead)) {
enemies_left_in_wave--;
fighting_boss=0;
}
else
for(i=3;i<5;i++) {
if ((!enemy[i].out) && (enemy[i-3].out)) {
enemies_out++;
enemy[i].kind=rand()%8+2;
enemy[i].x=enemy[i-3].x;
enemy[i].y=20;
enemy[i].xspeed=0;
enemy[i].minx=enemy[i].x;
enemy[i].maxx=enemy[i].x;
enemy[i].boundarycheck=0;
enemy[i].yspeed=4;
enemy[i].out=1;
enemy[i].exploding=0;
enemy[i].hitsneeded=1;
enemy[i].dead=0;
}
}
}
return need_to_pause;
}
@ -337,18 +471,19 @@ int level_one_behavior(int reset, tb1_state *game_state)
/* The Main Level One */
void levelone(tb1_state *game_state) {
void LevelOneEngine(tb1_state *game_state) {
int ch=0;
int i,j,grapherror;
char tempst[300];
int itemp,whatdelay=1,levelover=0;
int itemp,levelover=0;
int shipx=36,shipadd=0,shipframe=1;
vmwSprite *bigship1,*bigship2,*bigship3;
vmwSprite *shapetable[20];
long oldsec,oldusec,time_spent;
long oldsec,oldusec,time_spent=1;
int howmuchscroll=0;
int speed_factor=1,game_paused=0;
int game_paused=0;
int done_waiting=0;
vmwVisual *virtual_1,*virtual_2;
vmwFont *tb1_font;
@ -362,7 +497,7 @@ void levelone(tb1_state *game_state) {
game_state->begin_score=game_state->score;
game_state->begin_shields=game_state->shields;
/* Load Sprites */
/* Load Ship Sprites */
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file("level1/ships.tb1",game_state->path_to_data),
game_state->graph_state);
@ -371,29 +506,28 @@ void levelone(tb1_state *game_state) {
bigship2=vmwGetSprite(0,32,48,30,virtual_1);
bigship3=vmwGetSprite(0,64,48,30,virtual_1);
/* Load Inanimate Object Shapes */
grapherror=vmwLoadPicPacked(0,0,virtual_1,0,1,
tb1_data_file("level1/tbshapes.tb1",game_state->path_to_data),
game_state->graph_state);
game_state->graph_state);
for(j=0;j<2;j++)
for(i=0;i<10;i++)
shapetable[(j*10)+i]=vmwGetSprite(1+(i*19),1+(j*19),18,18,
virtual_1);
shapetable[(j*10)+i]=vmwGetSprite(1+(i*19),1+(j*19),18,18,virtual_1);
/* Set up initial Enemy Structs */
for(i=0;i<5;i++) {
/* Set up initial system conditions [ie, no enemies] */
for(i=0;i<NUM_ENEMIES;i++) {
enemy[i].exploding=0;
enemy[i].out=0;
enemy[i].dead=0;
}
for(i=0;i<2;i++) {
bullet[i].out=0;
bullet[i].x=0;
bullet[i].y=0;
for(i=0;i<NUM_MISSILES;i++) {
missile[i].out=0;
missile[i].x=0;
missile[i].y=0;
}
/* Draw the Little Box announcing the Start of the Level */
/* Draw the Little Box announcing the Start of the Level */
vmwDrawBox(0,0,320,200,0,virtual_1);
coolbox(70,85,240,120,1,virtual_1);
vmwTextXY(" LEVEL ONE:",84,95,4,7,0,tb1_font,virtual_1);
@ -406,8 +540,8 @@ void levelone(tb1_state *game_state) {
vmwFlipVirtual(virtual_1,virtual_2,320,200);
sprintf(tempst,"%d",game_state->level);
vmwDrawBox(251,52,63,7,0,virtual_2);
vmwTextXY(tempst,307,51,12,0,0,tb1_font,virtual_2);
// vmwDrawBox(251,52,62,7,0,virtual_1);
vmwTextXY(tempst,307,51,12,0,0,tb1_font,virtual_1);
/* Clear the screen and draw the stars */
vmwDrawBox(0,0,320,400,0,virtual_2);
@ -415,22 +549,29 @@ void levelone(tb1_state *game_state) {
vmwPutSprite(shapetable[11],rand()%238,rand()%380,virtual_2);
vmwPutSprite(shapetable[12],rand()%238,rand()%380,virtual_2);
}
/* Initialize shield state */
change_shields(game_state);
/* Initiate some last variables */
level_one_behavior(1,game_state);
add_another_enemy(1,game_state);
pauseawhile(5);
/* Get time values for frame-limiting */
gettimeofday(&timing_info,&dontcare);
oldsec=timing_info.tv_sec; oldusec=timing_info.tv_usec;
oldsec=timing_info.tv_sec;
oldusec=timing_info.tv_usec;
/* MAIN GAME LOOP */
while(!levelover) {
ch=0;
/* Scroll the Stars */
if (speed_factor>1) howmuchscroll-=speed_factor;
else howmuchscroll--;
/* We have a 240x400 field of stars */
howmuchscroll--;
if (howmuchscroll<0) howmuchscroll=399;
/* If scroll>199, then we have to split into two copies */
/* One from scroll to 400 */
/* Another from 0-(scroll-200) */
if (howmuchscroll>199) {
vmwArbitraryCrossBlit(virtual_2,0,howmuchscroll,240,
400-howmuchscroll,
@ -443,13 +584,25 @@ void levelone(tb1_state *game_state) {
virtual_1,0,0);
}
/* Add new enemies and move to next wave if needed */
if (enemies_out<NUM_ENEMIES) {
if (add_another_enemy(0,game_state)==LEVEL_OVER) {
game_state->level=2;
levelover=1;
}
}
/* Check for Collisions */
for(i=0;i<5;i++) {
/* See if the enemies have hit anything/scrolled off screen */
for(i=0;i<NUM_ENEMIES;i++) {
if (!enemy[i].dead) {
for(itemp=0;itemp<2;itemp++) {
if (bullet[itemp].out)
if (collision(bullet[itemp].x,bullet[itemp].y,10,10,
/* Check to see if our missiles have hit any enemies */
for(itemp=0;itemp<NUM_MISSILES;itemp++) {
if (missile[itemp].out) {
if (collision(missile[itemp].x,missile[itemp].y,10,10,
enemy[i].x,enemy[i].y,9,9)) {
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_KAPOW);
@ -458,70 +611,68 @@ void levelone(tb1_state *game_state) {
else enemy[i].dead=0;
enemy[i].exploding=1;
enemy[i].explodeprogress=0;
bullet[itemp].out=0;
missile[itemp].out=0;
game_state->score+=10;
changescore(game_state);
}
}
}
}
/* While we are at it, see if scrolled off screen */
if (enemy[i].y>179) {
enemy[i].out=0;
enemy[i].dead=1;
enemies_out--;
}
}
}
/* Explode the things that are exploding */
for(i=0;i<5;i++) {
for(i=0;i<NUM_ENEMIES;i++) {
if (enemy[i].exploding) {
enemy[i].explodeprogress++;
if (enemy[i].explodeprogress<=5)
vmwPutSprite(shapetable[enemy[i].explodeprogress+14],
enemy[i].x,enemy[i].y,
virtual_1);
else if (enemy[i].dead) {
if (enemy[i].explodeprogress<10)
vmwPutSprite(shapetable[(enemy[i].explodeprogress/2)+15],
enemy[i].x,enemy[i].y,virtual_1);
else if (enemy[i].dead) { /* Handle for objects w hitpoints >1 */
enemy[i].out=0;
enemy[i].exploding=0;
game_paused=level_one_behavior(0,game_state);
enemies_out--;
}
else enemy[i].exploding=0;
}
}
/* Move the Missiles */
for(i=0;i<2;i++) {
if (bullet[i].out) {
if (speed_factor>1) bullet[i].y-=(5*speed_factor);
else bullet[i].y-=5;
if (bullet[i].y<5) bullet[i].out=0;
else vmwPutSprite(shapetable[0],
bullet[i].x,bullet[i].y,
for(i=0;i<NUM_MISSILES;i++) {
if (missile[i].out) {
missile[i].y-=5;
if (missile[i].y<5) missile[i].out=0;
else vmwPutSprite(shapetable[0],missile[i].x,missile[i].y,
virtual_1);
}
}
/* MOVE ENEMIES */
for(i=0;i<5;i++) {
for(i=0;i<NUM_ENEMIES;i++) {
if ((enemy[i].out) && (!enemy[i].dead)) {
vmwPutSprite(shapetable[enemy[i].kind-1],
enemy[i].x,enemy[i].y,
virtual_1);
if (speed_factor==1) enemy[i].x+=enemy[i].xspeed;
else enemy[i].x+=(enemy[i].xspeed*speed_factor);
/* Check Position */
/* Check Position */
vmwPutSprite(shapetable[enemy[i].kind],
enemy[i].x,enemy[i].y,virtual_1);
/* Move in X direction */
enemy[i].x+=enemy[i].xspeed;
/* Move in Y direction */
if (!enemy[i].boundarycheck) {
if (speed_factor>1) enemy[i].y+=(enemy[i].yspeed*speed_factor);
else enemy[i].y+=enemy[i].yspeed;
enemy[i].y+=enemy[i].yspeed;
}
/* Move down if an oscilating type */
if ((enemy[i].x<=enemy[i].minx) || (enemy[i].x>=enemy[i].maxx)) {
enemy[i].xspeed=-enemy[i].xspeed;
if (speed_factor>1) enemy[i].x+=(enemy[i].xspeed*speed_factor);
else enemy[i].x+=enemy[i].xspeed;
if (speed_factor>1) enemy[i].y+=(enemy[i].yspeed*speed_factor);
else enemy[i].y+=enemy[i].yspeed;
enemy[i].x+=enemy[i].xspeed;
enemy[i].y+=enemy[i].yspeed;
}
/* Too Low */
/* Too Low */
if (enemy[i].y>179) {
enemy[i].out=0;
game_paused=level_one_behavior(0,game_state);
}
/* See if colliding with spaceship */
if (enemy[i].y>140) {
if (collision(shipx,165,24,15,enemy[i].x,enemy[i].y,9,9)) {
if ((game_state->sound_possible)&&(game_state->sound_enabled))
@ -538,12 +689,6 @@ void levelone(tb1_state *game_state) {
}
}
}
/* See if beat the level. Yes, bad variable name. Oh well */
if (game_paused==9) {
afterboss(game_state);
game_state->level=2;
levelover=1;
}
/* **READ KEYBOARD** */
if ( (ch=vmwGetInput())!=0) {
@ -552,7 +697,6 @@ void levelone(tb1_state *game_state) {
case VMW_RIGHT: if (shipadd>=0) shipadd+=3; else shipadd=0; break;
case VMW_LEFT: if (shipadd<=0) shipadd-=3; else shipadd=0; break;
case VMW_F1: game_paused=1; help(game_state); break;
case '+': whatdelay++; if (whatdelay>25) whatdelay=25; break;
case 'P': case 'p': game_paused=1;
coolbox(65,85,175,110,1,virtual_1);
vmwTextXY("GAME PAUSED",79,95,4,7,
@ -562,7 +706,6 @@ void levelone(tb1_state *game_state) {
usleep(30000);
}
break;
case '-': whatdelay--; if (whatdelay<1) whatdelay=1; break;
case 'S':
case 's': if (game_state->sound_possible)
game_state->sound_enabled=!(game_state->sound_enabled); break;
@ -570,23 +713,22 @@ void levelone(tb1_state *game_state) {
savegame(game_state);
break;
case ' ': for(j=0;j<2;j++)
if (!bullet[j].out) {
if (!missile[j].out) {
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_CC);
bullet[j].out=1;
bullet[j].x=shipx+15;
bullet[j].y=165;
missile[j].out=1;
missile[j].x=shipx+15;
missile[j].y=165;
vmwPutSprite(shapetable[0],
bullet[j].x,
bullet[j].y,virtual_1);
missile[j].x,
missile[j].y,virtual_1);
j=3;
}
}
}
/* **MOVE SHIP** */
if (speed_factor>1) shipx+=(shipadd*speed_factor);
else shipx+=shipadd;
shipx+=shipadd;
if (shipx<1) shipx=1;
if (shipx>190) shipx=190;
switch(shipframe) {
@ -603,28 +745,32 @@ void levelone(tb1_state *game_state) {
if (shipframe==5) shipframe=1;
/* Flip Pages */
#ifdef DEBUG_ON
sprintf(tempst,"%li",1000000/time_spent);
vmwTextXY(tempst,10,10,4,7,0,tb1_font,virtual_1);
#endif
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
/* Calculate how much time has passed */
gettimeofday(&timing_info,&dontcare);
time_spent=timing_info.tv_usec-oldusec;
if (timing_info.tv_sec-oldsec) time_spent+=1000000;
#ifdef DEBUG_ON
printf("%f\n",1000000/(float)time_spent);
#endif
/* If time passed was too little, wait a bit */
while (time_spent<33000){
/* 33,333 would frame rate to 30Hz */
/* Linux with 100Hz scheduling only gives +- 10000 accuracy */
done_waiting=0;
while (!done_waiting){
gettimeofday(&timing_info,&dontcare);
usleep(5);
time_spent=timing_info.tv_usec-oldusec;
if (timing_info.tv_sec-oldsec) time_spent+=1000000;
}
/* It game is paused, don't keep track of time */
if (!game_paused) speed_factor=(time_spent/30000);
/* Assume we don't lag more than a second */
/* Seriously, if we lag more than 10ms we are screwed anyway */
if (time_spent<0) time_spent+=1000000;
if (time_spent<30000) usleep(100);
else (done_waiting=1);
}
oldusec=timing_info.tv_usec;
oldsec=timing_info.tv_sec;
/* It game is paused, don't keep track of time */
if (game_paused) {
gettimeofday(&timing_info,&dontcare);
oldusec=timing_info.tv_usec;
@ -636,7 +782,7 @@ void levelone(tb1_state *game_state) {
}
/* The little opener before Level 1 */
void littleopener(tb1_state *game_state)
void LevelOneLittleOpener(tb1_state *game_state)
{
vmwSprite *ship1,*ship2;

231
level_2.c
View File

@ -59,7 +59,7 @@ void leveltwoengine(tb1_state *game_state)
int ch,i;
char tempst[BUFSIZ];
int k,game_paused=0,speed_factor=1;
int shipx=36;
int shipx=36,shipy;
int whatdelay=1;
FILE *f=NULL;
int levelover=0,j,backrow=0;
@ -444,125 +444,146 @@ void leveltwoengine(tb1_state *game_state)
/*printf("%i\n",rows_goneby);*/
if (rows_goneby>1950) {
// printf("%i\n",rows_goneby);
coolbox(35,85,215,110,1,virtual_1);
vmwTextXY("TO BE CONTINUED...",55,95,4,7,0,tb1_font,virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(10);
// coolbox(35,85,215,110,1,virtual_1);
// vmwTextXY("TO BE CONTINUED...",55,95,4,7,0,tb1_font,virtual_1);
// vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
// pauseawhile(10);
/*
clearkeyboardbuffer;
pauseawhile(200);
fade;
grapherror:=Mode13LoadPicPacked(0,0,vaddr,false,true,'viewscr.tb1');
cls(0,vga);
blockmove(0,79,58,116,vaddr,10,10,vga);
clearkeyboardbuffer;
outsmalltextxy('UNIDENTIFIED SPACECRAFT!',70,10,2,0,vga,true);
outsmalltextxy('DO YOU WISH TO DEACTIVATE ',70,20,2,0,vga,true);
outsmalltextxy('THIS SHIP''S SECURITY SYSTEMS? (Y/N)',70,30,2,0,vga,true);
unfade;
clearkeyboardbuffer;
ch:='!';
repeat
if keypressed then ch:=readkey;
until (upcase(ch)='Y') or (upcase(ch)='N');
vmwClearKeyboardBuffer();
pauseawhile(5);
vmwLoadPicPacked(0,0,game_state->virtual_3,0,1,
tb1_data_file("level1/viewscr.tb1",game_state->path_to_data),
game_state->graph_state);
vmwClearScreen(game_state->virtual_1,0);
vmwArbitraryCrossBlit(game_state->virtual_3,0,79,58,37,
game_state->virtual_1,10,10);
vmwClearKeyboardBuffer();
vmwSmallTextXY("UNIDENTIFIED SPACECRAFT!",70,10,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("DO YOU WISH TO DEACTIVATE ",70,20,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("THIS SHIP'S SECURITY SYSTEMS? (Y/N)",70,30,2,0,1,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
vmwClearKeyboardBuffer();
ch='!';
while ((ch!='Y') && (ch!='y') && (ch!='N') && (ch!='n')) {
while(!(ch=vmwGetInput())) usleep(1000);
}
if ((ch=='N') || (ch=='n')) {
vmwArbitraryCrossBlit(game_state->virtual_3,0,79,58,37,
game_state->virtual_1,10,50);
vmwSmallTextXY("NO? AFFIRMATIVE. ",70,50,9,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("ARMING REMOTE DESTRUCTION RAY.",70,60,9,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("GOOD-BYE.",70,70,9,0,1,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(4);
}
if upcase(ch)='N' then begin
blockmove(0,79,58,116,vaddr,10,50,vga);
outsmalltextxy('NO? AFFIRMATIVE. ',70,50,9,0,vga,true);
outsmalltextxy('ARMING REMOTE DESTRUCTION RAY.',70,60,9,0,vga,true);
outsmalltextxy('GOOD-BYE.',70,70,9,0,vga,true);
pauseawhile(400);
fade;
end;
if ((ch=='Y') || (ch=='y')) {
vmwArbitraryCrossBlit(game_state->virtual_3,0,79,58,37,
game_state->virtual_1,10,50);
vmwSmallTextXY("'Y'=CORRECT PASSWORD. ",70,50,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("WELCOME SUPREME TENTACLEE COMMANDER.",70,60,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("INITIATING TRACTOR BEAM AND AUTOMATIC",70,70,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("LANDING PROCEDURE.",70,80,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("WE WILL BE DEPARTING FOR THE PLANET",70,90,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("EERM IN THREE MICROCYCLE UNITS.",70,100,2,0,1,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(5);
game_state->level=3;
vmwClearKeyboardBuffer();
vmwArbitraryCrossBlit(game_state->virtual_3,0,42,58,37,
game_state->virtual_1,10,110);
vmwSmallTextXY("Wha? Wait!",70,110,9,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("What's happening?",70,120,9,0,1,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(6);
}
vmwLoadPicPacked(0,0,game_state->virtual_3,0,1,
tb1_data_file("level3/tbtract.tb1",game_state->path_to_data),
game_state->graph_state);
if upcase(ch)='Y' then begin
blockmove(0,79,58,116,vaddr,10,50,vga);
outsmalltextxy('"Y"=CORRECT PASSWORD. ',70,50,2,0,vga,true);
outsmalltextxy('WELCOME SUPREME TENTACLEE COMMANDER.',70,60,2,0,vga,true);
outsmalltextxy('INITIATING TRACTOR BEAM AND AUTOMATIC',70,70,2,0,vga,true);
outsmalltextxy('LANDING PROCEDURE.',70,80,2,0,vga,true);
outsmalltextxy('WE WILL BE DEPARTING FOR THE PLANET',70,90,2,0,vga,true);
outsmalltextxy('EERM IN THREE MICROCYCLE UNITS.',70,100,2,0,vga,true);
pauseawhile(550);
level:=3;
clearkeyboardbuffer;
blockmove(0,42,58,79,vaddr,10,110,vga);
outsmalltextxy('Wha? Wait!',70,110,9,0,vga,true);
outsmalltextxy('What''s happening?',70,120,9,0,vga,true);
pauseawhile(550);
fade;
end;
grapherror:=Mode13LoadPicPacked(0,0,vaddr,false,true,'tbtract.tb1');
for i:=0 to 239 do
for j:=0 to 49 do
putpixel240(i,j,getpixel(i,j,vaddr),vaddr2);
cls(0,vga);
unfade;
for howmuchscroll:=50 downto 1 do begin
flipd240(howmuchscroll,vaddr,vaddr2);
putshape (bigship3off,vaddr,43,30,shipx,165);
waitretrace;
flipd320(vaddr,vga);
end;
if upcase(ch)='N' then begin
clearkeyboardbuffer;
line(7,6,shipx+10,180,4,vga);
line(shipx+37,180,231,6,4,vga);
pauseawhile(50);
clearkeyboardbuffer;
for i:=shipx to shipx+48 do
verticalline(165,195,i,4,vga);
pauseawhile(200);
flipd240(howmuchscroll,vaddr,vaddr2);
flipd320(vaddr,vga);
pauseawhile(150);
end;
if upcase(ch)='Y' then begin;
shipadd:=sgn(shipx-95);
shipy:=165;
repeat
if shipx<>95 then shipx:=shipx-shipadd;
if shipy>9 then dec(shipy);
flipd240(howmuchscroll,vaddr,vaddr2);
line(7,6,shipx+10,shipy+15,2,vaddr);
line(shipx+37,shipy+15,231,6,2,vaddr);
putshape (bigship3off,vaddr,43,30,shipx,shipy);
waitretrace;
flipd320(vaddr,vga);
until (shipx=95) and (shipy=9);
clearkeyboardbuffer;
pauseawhile(850);
fade;
cls(0,vga);
vmwArbitraryCrossBlit(game_state->virtual_3,0,0,240,50,
game_state->virtual_2,0,0);
vmwClearScreen(game_state->virtual_1,0);
setupsidebar(game_state,virtual_1);
for(howmuchscroll=50;howmuchscroll>0;howmuchscroll--) {
vmwArbitraryCrossBlit(virtual_2,0,howmuchscroll,240,200,virtual_1,0,0);
usleep(30000);
vmwPutSprite(ship_shape[0],shipx,165,virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
}
if ((ch=='N') || (ch=='n')) {
vmwClearKeyboardBuffer();
vmwLine(7,6,shipx+10,180,4,virtual_1);
vmwLine(shipx+37,180,231,6,4,virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(1);
vmwClearKeyboardBuffer();
for(i=shipx;i<shipx+48;i++) {
vmwDrawVLine(i,165,30,4,virtual_1);
}
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(2);
vmwArbitraryCrossBlit(virtual_2,0,howmuchscroll,240,200,virtual_1,0,0);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(2);
}
else {
if (shipx-95==0) shipadd=0;
if (shipx-95>0) shipadd=1;
if (shipx-95<0) shipadd=-1;
shipy=165;
while ((shipx!=95) || (shipy>10)) {
if (shipx!=95) shipx-=shipadd;
if (shipy>10) shipy--;
vmwArbitraryCrossBlit(virtual_2,0,howmuchscroll,240,200,virtual_1,0,0);
vmwLine(7,6,shipx+12,shipy+15,2,virtual_1);
vmwLine(shipx+37,shipy+15,231,6,2,virtual_1);
vmwPutSprite(ship_shape[0],shipx,shipy,virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
usleep(30000);
}
vmwClearKeyboardBuffer();
pauseawhile(8);
vmwClearScreen(virtual_1,0);
}
/*
while keypressed do ch:=readkey;
if level=4 then begin
outsmalltextxy('THE PLANET EERM?',20,20,10,0,vga,true);
outsmalltextxy('XENOCIDE FLEET?',20,30,10,0,vga,true);
outsmalltextxy('WHAT''S GOING ON?',20,40,10,0,vga,true);
outsmalltextxy('A MAJOR GOVERNMENT CONSPIRACY? MASS HALUCINATIONS?',20,50,10,0,vga,true);
vmwSmallTextXY('THE PLANET EERM?',20,20,10,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('XENOCIDE FLEET?',20,30,10,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('WHAT'S GOING ON?',20,40,10,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('A MAJOR GOVERNMENT CONSPIRACY? MASS HALUCINATIONS?',20,50,10,0,1,tb1_font,game_state->virtual_1);
outsmalltextxy('WATCH FOR TOM BOMBEM LEVEL 3 (CURRENTLY IN THE DESIGN PHASE).',10,70,12,0,vga,true);
outsmalltextxy('ALL THESE QUESTIONS WILL BE ANSWERED!',10,80,12,0,vga,true);
outsmalltextxy('ALSO MORE FEATURES WILL BE ADDED:',10,90,12,0,vga,true);
outsmalltextxy(' BETTER GRAPHICS, SOUND AND SPEED.',10,100,12,0,vga,true);
vmwSmallTextXY('WATCH FOR TOM BOMBEM LEVEL 3 (CURRENTLY IN THE DESIGN PHASE).',10,70,12,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('ALL THESE QUESTIONS WILL BE ANSWERED!',10,80,12,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('ALSO MORE FEATURES WILL BE ADDED:',10,90,12,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY(' BETTER GRAPHICS, SOUND AND SPEED.',10,100,12,0,1,tb1_font,game_state->virtual_1);
outsmalltextxy('TO HASTEN COMPLETION, SEND QUESTIONS/COMMENTS/DONATIONS TO ',9,120,9,0,vga,true);
outsmalltextxy('THE AUTHOR (SEE THE REGISTER MESSAGE FOR RELEVANT ADDRESSES).',9,130,9,0,vga,true);
vmwSmallTextXY('TO HASTEN COMPLETION, SEND QUESTIONS/COMMENTS/DONATIONS TO ',9,120,9,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('THE AUTHOR (SEE THE REGISTER MESSAGE FOR RELEVANT ADDRESSES).',9,130,9,0,1,tb1_font,game_state->virtual_1);
outsmalltextxy('THANK YOU FOR PLAYING TOM BOMBEM',80,150,14,0,vga,true);
vmwSmallTextXY('THANK YOU FOR PLAYING TOM BOMBEM',80,150,14,0,1,tb1_font,game_state->virtual_1);
unfade;
pauseawhile(1800);
end; */
levelover=1;
}
}
}
}

395
level_3.c
View File

@ -1,5 +1,8 @@
#include <stdio.h>
#include <stdlib.h> /* For rand() */
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include "./svmwgraph/svmwgraph.h"
#include "tb1_state.h"
@ -7,31 +10,45 @@
#include "help.h"
#include "loadsave.h"
#include "graphic_tools.h"
#include "tblib.h"
#define NORTH 0
#define SOUTH 1
#define EAST 2
#define WEST 3
#define TOM_SHAPE 60
vmwSprite *shape_table[80];
void loadlevel3shapes(tb1_state *game_state) {
void loadlevel3shapes() {
/*
var x,y,i,j,shape:byte;
begin
clearshape;
grapherror:=loadpicsuperpacked(0,0,vaddr,false,true,'tblev3.tb1');
for j:=0 to 3 do
for i:=0 to 19 do
for x:=0 to 9 do
for y:=0 to 9 do
ShapeTable1^[shape3array[(j*20)+i]+((y*10)+x)]
:=getpixel(1+x+(i*11),1+y+(j*11),vaddr);
cls(0,vaddr);
end;
*/
int i,j;
vmwLoadPicPacked(0,0,game_state->virtual_2,0,1,
tb1_data_file("level3/tblev3.tb1",
game_state->path_to_data),
game_state->graph_state);
for(j=0;j<5;j++) {
for(i=0;i<20;i++) {
shape_table[(j*20)+i]=vmwGetSprite(1+(i*11),1+(j*11),
10,10,game_state->virtual_2);
}
}
}
int our_sgn(int value) {
if (value==0) return 0;
if (value<0) return -1;
return 1;
}
/*
Procedure levelthree;
label newroom;
@ -157,21 +174,28 @@ void LevelThreeEngine(tb1_state *game_state) {
int level_over=0;
int ch,direction=NORTH;
int x_add,y_add;
int x_add=0,y_add=0;
int game_paused=0;
int tom_x=100,tom_y=100,walking=0;
vmwVisual *virtual_1,*virtual_2;
vmwFont *tb1_font;
long oldsec,oldusec,time_spent;
struct timeval timing_info;
struct timezone dontcare;
int speed_factor=0;
virtual_1=game_state->virtual_1;
virtual_2=game_state->virtual_2;
tb1_font=game_state->graph_state->default_font;
/*
BEGIN
{loadlevel3shapes;}
computer_0hits:=0;
loadlevel3shapes(game_state);
/* computer_0hits:=0;
whatdelay:=1;
havegun:=true;
for i:=0 to 3 do keycards[i]:=false;
@ -202,7 +226,7 @@ BEGIN
flip(vaddr2,vaddr);
str(level,tempst);
fillblock(251,52,314,59,0,vaddr);
outtextxy(tempst,307,51,12,0,vaddr,false);
vmwTextXY(tempst,307,51,12,0,vaddr,false);
cls(0,vaddr2);
@ -214,8 +238,8 @@ BEGIN
cls(0,vga);
coolbox(70,85,240,120,true,vga);
outtextxy(' LEVEL THREE:',84,95,4,7,vga,false);
outtextxy(' THE ALIEN SHIP',84,105,4,7,vga,false);
vmwTextXY(' LEVEL THREE:',84,95,4,7,vga,false);
vmwTextXY(' THE ALIEN SHIP',84,105,4,7,vga,false);
clearkeyboardbuffer;
pauseawhile(300);
@ -386,15 +410,15 @@ newroom:
begin
levelover:=true;
cls(0,vga);
outtextxy('You Have won!',5,5,9,7,vga,false);
outtextxy('But as you can see this level is not done yet.',5,15,9,7,vga,false);
{outtextxy('Anyway');}
vmwTextXY('You Have won!',5,5,9,7,vga,false);
vmwTextXY('But as you can see this level is not done yet.',5,15,9,7,vga,false);
{vmwTextXY('Anyway');}
readln;
inc(level);
end
else begin
cls(0,vga);
outtextxy('You Cannot Leave Yet',5,5,9,7,vga,true);
vmwTextXY('You Cannot Leave Yet',5,5,9,7,vga,true);
repeat until keypressed; tempch:=readkey;
levelover:=false;
shipframe:=1;
@ -405,7 +429,9 @@ newroom:
*/
gettimeofday(&timing_info,&dontcare);
oldsec=timing_info.tv_sec; oldusec=timing_info.tv_usec;
/**** GAME LOOP ****/
/*******************/
@ -423,7 +449,7 @@ newroom:
grapherror:=loadpicsuperpacked(0,0,vga,false,true,'tbpit.tb1');
{outtextxy('You Fell In A Pit!',5,5,9,2,vga,false);}
{vmwTextXY('You Fell In A Pit!',5,5,9,2,vga,false);}
clearkeyboardbuffer;
repeat until keypressed; tempch:=readkey;
end;
@ -486,33 +512,33 @@ newroom:
inc(computer_0hits);
if computer_0hits=1 then begin
outtextxy('COMPUTER ACTIVATED:',47,30,2,0,vga,true);
outsmalltextxy(' HUMAN YOU HAVE COME TOO SOON. LEVELS 3',47,40,2,0,vga,true);
outsmalltextxy(' AND 4 ARE INCOMPLETE.',47,48,2,0,vga,true);
outsmalltextxy(' ANYWAY I CAN SEE YOU ARE NOT THE',47,58,2,0,vga,true);
outsmalltextxy(' TENTACLEE COMMANDER. YOU ARE IN',47,66,2,0,vga,true);
outsmalltextxy(' GRAVE DANGER. LUCKILY THE MAIN',47,74,2,0,vga,true);
outsmalltextxy(' COMPUTER SYSTEM DOES NOT APPROVE',47,82,2,0,vga,true);
outsmalltextxy(' OF THE TENTACLEE''S POLICIES.',47,90,2,0,vga,true);
outsmalltextxy(' I PERSONALLY CANNOT SHUT OFF THE TRACTOR',47,100,2,0,vga,true);
outsmalltextxy(' BEAM. YOU MUST RETRIEVE FOUR KEYCARDS',47,108,2,0,vga,true);
outsmalltextxy(' SCATTERED AROUND THE FLIGHT DECK.',47,116,2,0,vga,true);
outsmalltextxy(' THE MAP BELOW WILL AID YOU.',47,124,2,0,vga,true);
vmwTextXY('COMPUTER ACTIVATED:',47,30,2,0,vga,true);
vmwSmallTextXY(' HUMAN YOU HAVE COME TOO SOON. LEVELS 3',47,40,2,0,vga,true);
vmwSmallTextXY(' AND 4 ARE INCOMPLETE.',47,48,2,0,vga,true);
vmwSmallTextXY(' ANYWAY I CAN SEE YOU ARE NOT THE',47,58,2,0,vga,true);
vmwSmallTextXY(' TENTACLEE COMMANDER. YOU ARE IN',47,66,2,0,vga,true);
vmwSmallTextXY(' GRAVE DANGER. LUCKILY THE MAIN',47,74,2,0,vga,true);
vmwSmallTextXY(' COMPUTER SYSTEM DOES NOT APPROVE',47,82,2,0,vga,true);
vmwSmallTextXY(' OF THE TENTACLEE'S POLICIES.',47,90,2,0,vga,true);
vmwSmallTextXY(' I PERSONALLY CANNOT SHUT OFF THE TRACTOR',47,100,2,0,vga,true);
vmwSmallTextXY(' BEAM. YOU MUST RETRIEVE FOUR KEYCARDS',47,108,2,0,vga,true);
vmwSmallTextXY(' SCATTERED AROUND THE FLIGHT DECK.',47,116,2,0,vga,true);
vmwSmallTextXY(' THE MAP BELOW WILL AID YOU.',47,124,2,0,vga,true);
end;
if computer_0hits=2 then begin
outtextxy('COMPUTER ACTIVATED:',47,30,2,0,vga,true);
outsmalltextxy(' HUMAN I HAVE ALREADY TOLD YOU MUCH.',47,40,2,0,vga,true);
outsmalltextxy(' COLLECT THE 4 KEYCARDS, MADE OF',47,48,2,0,vga,true);
outsmalltextxy(' RUBY, GOLD, EMERALD, AND ALUMINUM.',47,56,2,0,vga,true);
outsmalltextxy(' WATCH OUT FOR ENEMIES NOT UNDER MY',47,66,2,0,vga,true);
outsmalltextxy(' CONTROL, RADIOACTIVE FLOORS, AND',47,74,2,0,vga,true);
outsmalltextxy(' EXTREMELY DEEP PITS.',47,82,2,0,vga,true);
vmwTextXY('COMPUTER ACTIVATED:',47,30,2,0,vga,true);
vmwSmallTextXY(' HUMAN I HAVE ALREADY TOLD YOU MUCH.',47,40,2,0,vga,true);
vmwSmallTextXY(' COLLECT THE 4 KEYCARDS, MADE OF',47,48,2,0,vga,true);
vmwSmallTextXY(' RUBY, GOLD, EMERALD, AND ALUMINUM.',47,56,2,0,vga,true);
vmwSmallTextXY(' WATCH OUT FOR ENEMIES NOT UNDER MY',47,66,2,0,vga,true);
vmwSmallTextXY(' CONTROL, RADIOACTIVE FLOORS, AND',47,74,2,0,vga,true);
vmwSmallTextXY(' EXTREMELY DEEP PITS.',47,82,2,0,vga,true);
end;
if computer_0hits>2 then begin
outtextxy('COMPUTER ACTIVATED:',47,30,2,0,vga,true);
outsmalltextxy(' HUMAN, GO AWAY. YOU ANNOY ME.',47,40,2,0,vga,true);
outsmalltextxy(' I HAVE TOLD YOU EVERYTHING.',47,48,2,0,vga,true);
vmwTextXY('COMPUTER ACTIVATED:',47,30,2,0,vga,true);
vmwSmallTextXY(' HUMAN, GO AWAY. YOU ANNOY ME.',47,40,2,0,vga,true);
vmwSmallTextXY(' I HAVE TOLD YOU EVERYTHING.',47,48,2,0,vga,true);
end;
@ -530,12 +556,12 @@ newroom:
/*{ for i:=0 to 30 do
if passive[i].exploding then with passive[i] do begin
inc(explodeprogress);
putshape240(shape2array[35+explodeprogress],vaddr2,
vmwPutSprite240(shape2array[35+explodeprogress],vaddr2,
20,9,x,y+howmuchscroll);
if explodeprogress>4 then begin
dead:=true;
exploding:=false;
putshape240over(14800(*shape2array[34]*),vaddr2,
vmwPutSprite240over(14800(*shape2array[34]*),vaddr2,
20,9,x,y+howmuchscroll);
end;
end;
@ -559,12 +585,12 @@ newroom:
end;
if collide<>0 then bullet1out:=false;
if bullet1out then putshape(shape3array[76],vaddr,10,9,bullet1x,bullet1y);
if bullet1out then vmwPutSprite(shape3array[76],vaddr,10,9,bullet1x,bullet1y);
end;
if bullet2out then begin
dec(bullet2y,5);
if bullet2y<5 then bullet2out:=false;
if bullet2out then putshape(shape3array[76],vaddr,10,9,bullet2x,bullet2y);
if bullet2out then vmwPutSprite(shape3array[76],vaddr,10,9,bullet2x,bullet2y);
end;
*/
/***MOVE ENEMIES***/
@ -594,7 +620,7 @@ newroom:
end;
for j:=0 to 5 do begin
if enemy[j].out then begin
putshape(shape2array[enemy[j].kind],vaddr,
vmwPutSprite(shape2array[enemy[j].kind],vaddr,
20,9,enemy[j].x,enemy[j].y);
enemy[j].y:=enemy[j].y+enemy[j].yspeed;
if enemy[j].y>189 then enemy[j].out:=false;
@ -659,7 +685,7 @@ newroom:
bullet1x:=shipx+3;
bullet1y:=shipy+4;
bullet1dir:=shipframe;
putshape(shape3array[76],vaddr,10,9,bullet1x,bullet1y);
vmwPutSprite(shape3array[76],vaddr,10,9,bullet1x,bullet1y);
end
else
if (bullet2out=false) then begin
@ -668,7 +694,7 @@ newroom:
bullet2x:=shipx;
bullet2y:=shipy;
bullet2dir:=shipframe;
putshape(shape3array[76],vaddr,10,9,bullet2x,bullet2y);
vmwPutSprite(shape3array[76],vaddr,10,9,bullet2x,bullet2y);
end;
end;
*/
@ -687,10 +713,12 @@ newroom:
if (shipframe=3) and (dcollide<>0) then shipyadd:=0;
if (shipframe=2) and (rcollide<>0) then shipxadd:=0;
if (shipframe=4) and (lcollide<>0) then shipxadd:=0;
shipy:=shipy+shipyadd;
shipyadd:=shipyadd-sgn(shipyadd);
shipx:=shipx+shipxadd;
shipxadd:=shipxadd-sgn(shipxadd);
*/
tom_x+=x_add;
tom_y+=y_add;
y_add-=our_sgn(y_add);
x_add-=our_sgn(x_add);
/*
case ucollide of
5: begin
@ -716,108 +744,165 @@ newroom:
room:=whichroomnext[3];
end;
end;
if (shipyadd<>0) or (shipxadd<>0) then inc(walking,4)
else walking:=0;
if walking>12 then walking:=0;
*/
/* CASE shipframe of
1 : putshape (shape3array[60+walking],vaddr,10,9,shipx,shipy);
2 : putshape (shape3array[61+walking],vaddr,10,9,shipx,shipy);
3 : putshape (shape3array[62+walking],vaddr,10,9,shipx,shipy);
4 : putshape (shape3array[63+walking],vaddr,10,9,shipx,shipy);
END;
*/
*/
if ((!y_add) || (!x_add)) walking+=4;
else walking=0;
if (walking>12) walking=0;
switch(direction) {
case NORTH: vmwPutSprite(shape_table[TOM_SHAPE+walking],tom_x,tom_y,game_state->virtual_1);
break;
case EAST: vmwPutSprite (shape_table[TOM_SHAPE+1+walking],tom_x,tom_y,game_state->virtual_1);
break;
case SOUTH: vmwPutSprite (shape_table[TOM_SHAPE+2+walking],tom_x,tom_y,game_state->virtual_1);
break;
case WEST: vmwPutSprite (shape_table[TOM_SHAPE+3+walking],tom_x,tom_y,game_state->virtual_1);
}
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
/* Calculate how much time has passed */
gettimeofday(&timing_info,&dontcare);
time_spent=timing_info.tv_usec-oldusec;
if (timing_info.tv_sec-oldsec) time_spent+=1000000;
#ifdef DEBUG_ON
printf("%f\n",1000000/(float)time_spent);
#endif
/* If time passed was too little, wait a bit */
while (time_spent<33000){
gettimeofday(&timing_info,&dontcare);
usleep(5);
time_spent=timing_info.tv_usec-oldusec;
if (timing_info.tv_sec-oldsec) time_spent+=1000000;
}
/* It game is paused, don't keep track of time */
if (game_paused) {
gettimeofday(&timing_info,&dontcare);
oldusec=timing_info.tv_usec;
oldsec=timing_info.tv_sec;
game_paused=0;
speed_factor=1;
}
else {
speed_factor=(time_spent/30000);
oldusec=timing_info.tv_usec;
oldsec=timing_info.tv_sec;
}
}
}
void littleopener3() {
/*
var star_x:array[0..5]of integer;
star_y:array[0..5]of integer;
begin
loadlevel3shapes;
grapherror:=loadpicsuperpacked(0,0,vga,true,false,'tbl2ship.tb1');
fade;
cls(0,vga);
grapherror:=loadpicsuperpacked(0,0,vaddr,false,true,'tbl3intr.tb1');
blockmove(0,3,171,117,vaddr,10,10,vga);
putshape (shape3array[60],vga,10,9,113,52);
void LevelThreeLittleOpener(tb1_state *game_state) {
int grapherror,i,j;
vmwFont *tb1_font;
vmwVisual *virtual_1,*virtual_2;
int star_x[6];
int star_y[6];
tb1_font=game_state->graph_state->default_font;
virtual_1=game_state->virtual_1;
virtual_2=game_state->virtual_2;
loadlevel3shapes(game_state);
vmwClearScreen(game_state->virtual_1,0);
grapherror=vmwLoadPicPacked(0,0,virtual_2,
1,1,tb1_data_file("level3/tbl3intr.tb1",
game_state->path_to_data),game_state->graph_state);
vmwArbitraryCrossBlit(game_state->virtual_2,0,3,171,114,
game_state->virtual_1,10,10);
unfade;
outtextxy('Hmmmm... STUPID TRACTOR BEAM.',10,155,10,0,vga,false);
outtextxy('I GUESS I''D BETTER GO SHUT IT OFF.',10,165,10,0,vga,false);
pauseawhile(700);
clearkeyboardbuffer;
for i:=24 downto 0 do begin
blockmove(0,3,171,117,vaddr,10,10,vga);
putshape (shape3array[60+(4*(i mod 4))],vga,10,9,113,28+i);
waitretrace; waitretrace; waitretrace;
waitretrace; waitretrace; waitretrace;
end;
putshape (shape3array[60],vga,10,9,113,28);
fillblock(10,155,300,185,0,vga);
outtextxy('I''M LUCKY I WORE MAGNETIC SHOES.',10,155,12,0,vga,false);
outtextxy('Hmmmm. SOMEONE LEFT THE AIR-LOCK',10,165,12,0,vga,false);
outtextxy(' UNLOCKED. STRANGE.',10,175,12,0,vga,false);
pauseawhile(600);
clearkeyboardbuffer;
putpixel(110,20,10,vga);
putpixel(110,22,10,vga);
fillblock(111,14,123,29,0,vga);
fillblock(10,155,300,185,0,vga);
outtextxy('I HOPE THIS ISN''T A TRAP.',10,155,9,0,vga,false);
outtextxy('I WISH I HAD SOME FORM OF ',10,165,9,0,vga,false);
outtextxy(' WEAPON.',10,175,9,0,vga,false);
pauseawhile(600);
clearkeyboardbuffer;
fade;
cls(0,vga);
blockmove(179,41,287,134,vaddr,10,10,vga);
for i:=0 to 5 do begin
star_x[i]:=37+random(70);
star_y[i]:=18+random(56);
putpixel(star_x[i],star_y[i],15,vga);
end;
outtextxy('WOW!! A GLASS-WALLED AIR-LOCK.',10,135,9,0,vga,false);
unfade;
pauseawhile(500);
clearkeyboardbuffer;
fillblock(10,135,300,185,0,vga);
outtextxy('NOW WHERE ARE WE GOING?',5,125,9,0,vga,false);
outtextxy('I GUESS THE PLANET EERM.',5,135,9,0,vga,false);
outtextxy('WHAT AN ODD NAME.',5,145,9,0,vga,false);
outtextxy('AND WHY AM I TALKING TO MYSELF?',5,155,10,0,vga,false);
outtextxy('ANYWAY I JUST WANT TO GO HOME',5,165,9,0,vga,false);
outtextxy(' AND SLEEP.',5,175,9,0,vga,false);
vmwPutSprite(shape_table[TOM_SHAPE],113,52,game_state->virtual_1);
clearkeyboardbuffer;
j:=0;
while (j<2400) and (not(keypressed)) do begin
inc(j);
for i:=0 to 5 do begin
putpixel(star_x[i],star_y[i],0,vga);
inc(star_x[i]);
if star_x[i]>107 then begin
star_x[i]:=37;
star_y[i]:=18+random(56);
end;
putpixel(star_x[i],star_y[i],15,vga);
end;
waitretrace; waitretrace;waitretrace;
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
vmwTextXY("Hmmmm... STUPID TRACTOR BEAM.",10,155,10,0,0,tb1_font,virtual_1);
vmwTextXY("I GUESS I'D BETTER GO SHUT IT OFF.",10,165,10,0,0,tb1_font,virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
pauseawhile(8);
vmwClearKeyboardBuffer();
end;
for(i=24;i>=0;i--) {
vmwArbitraryCrossBlit(game_state->virtual_2,0,3,171,114,
game_state->virtual_1,10,10);
vmwPutSprite(shape_table[TOM_SHAPE+(4*(i% 4))],113,28+i,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
usleep(50000);
}
vmwPutSprite (shape_table[TOM_SHAPE],113,28,game_state->virtual_1);
vmwDrawBox(10,155,290,30,0,game_state->virtual_1);
vmwTextXY("I'M LUCKY I WORE MAGNETIC SHOES.",10,155,12,0,0,tb1_font,game_state->virtual_1);
vmwTextXY("Hmmmm. SOMEONE LEFT THE AIR-LOCK",10,165,12,0,0,tb1_font,game_state->virtual_1);
vmwTextXY(" UNLOCKED. STRANGE.",10,175,12,0,0,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
pauseawhile(8);
vmwClearKeyboardBuffer();
vmwPutPixel(110,20,10,game_state->virtual_1);
vmwPutPixel(110,22,10,game_state->virtual_1);
vmwDrawBox(111,14,12,14,0,game_state->virtual_1);
vmwDrawBox(10,155,290,30,0,game_state->virtual_1);
vmwTextXY("I HOPE THIS ISN'T A TRAP.",10,155,9,0,0,tb1_font,game_state->virtual_1);
vmwTextXY("I WISH I HAD SOME FORM OF ",10,165,9,0,0,tb1_font,game_state->virtual_1);
vmwTextXY(" WEAPON.",10,175,9,0,0,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
pauseawhile(7);
vmwClearKeyboardBuffer();
vmwClearScreen(game_state->virtual_1,0);
vmwArbitraryCrossBlit(game_state->virtual_2,179,41,108,93,
game_state->virtual_1,10,10);
for(i=0;i<6;i++) {
star_x[i]=37+rand()%70;
star_y[i]=18+rand()%56;
vmwPutPixel(star_x[i],star_y[i],15,game_state->virtual_1);
}
if keypressed then ch:=readkey;
fade;
cls(0,vga);
unfade;
end;
*/
vmwTextXY("WOW!! A GLASS-WALLED AIR-LOCK.",10,135,9,0,0,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
pauseawhile(5);
vmwClearKeyboardBuffer();
vmwDrawBox(10,135,290,50,0,game_state->virtual_1);
vmwTextXY("NOW WHERE ARE WE GOING?",5,125,9,0,0,tb1_font,game_state->virtual_1);
vmwTextXY("I GUESS THE PLANET EERM.",5,135,9,0,0,tb1_font,game_state->virtual_1);
vmwTextXY("WHAT AN ODD NAME.",5,145,9,0,0,tb1_font,game_state->virtual_1);
vmwTextXY("AND WHY AM I TALKING TO MYSELF?",5,155,10,0,0,tb1_font,game_state->virtual_1);
vmwTextXY("ANYWAY I JUST WANT TO GO HOME",5,165,9,0,0,tb1_font,game_state->virtual_1);
vmwTextXY(" AND SLEEP.",5,175,9,0,0,tb1_font,game_state->virtual_1);
vmwClearKeyboardBuffer();
j=0;
while ((j<1000) && (!(vmwGetInput()))) {
j++;
for(i=0;i<6;i++) {
vmwPutPixel(star_x[i],star_y[i],0,game_state->virtual_1);
star_x[i]++;
if (star_x[i]>107) {
star_x[i]=37;
star_y[i]=18+rand()%56;
}
vmwPutPixel(star_x[i],star_y[i],15,game_state->virtual_1);
}
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
usleep(30000);
}
vmwClearKeyboardBuffer();
}

View File

@ -1,5 +1,6 @@
void levelone(tb1_state *game_state);
void littleopener(tb1_state *game_state);
void LevelOneEngine(tb1_state *game_state);
void LevelOneLittleOpener(tb1_state *game_state);
void leveltwoengine(tb1_state *game_state);
void littleopener2(tb1_state *game_state);
void LevelThreeEngine(tb1_state *game_state);
void LevelThreeLittleOpener(tb1_state *game_state);

View File

@ -156,7 +156,6 @@ void loadgame(tb1_state *game_state)
vmwTextXY("LOAD GAME",110,10,9,0,0,tb1_font,vis);
dir_name=check_for_tb1_directory(game_state,0);
printf("%s\n",dir_name);
if (dir_name!=NULL) {
num_of_save_games=list_saved_games(dir_name,tb1_font,vis);
@ -182,8 +181,6 @@ void loadgame(tb1_state *game_state)
}
if (!(save_slots[ch-48])) goto IchLiebeMree;
printf("%c\n",ch);
if (ch==VMW_ESCAPE) {
coolbox(0,0,319,199,1,vis);
vmwTextXY("LOAD CANCELED",90,95,12,0,0,tb1_font,vis);

View File

@ -15,25 +15,26 @@ void playthegame(tb1_state *game_state)
char *hiname;
if (game_state->level==0) {
littleopener(game_state);
LevelOneLittleOpener(game_state);
game_state->shields=12;
game_state->score=0;
game_state->level++;
}
if (game_state->level==1) {
levelone(game_state);
LevelOneEngine(game_state);
if (game_state->level==2) littleopener2(game_state);
}
if (game_state->level==2) {
leveltwoengine(game_state);
if (game_state->level==3) LevelThreeLittleOpener(game_state);
}
if (game_state->level==3) {
/*littleopener3();
levelthree();*/
LevelThreeEngine(game_state);
}
if (game_state->level==4) {
// leveltwoengine(&level,&shields,&score);
leveltwoengine(game_state);
}
coolbox(70,85,170,110,1,game_state->virtual_1);
vmwTextXY("GAME OVER",84,95,4,7,0,

View File

@ -1,8 +1,8 @@
/* "borrowed" from gltron */
#ifdef SDL_MIXER_SOUND
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <SDL.h>
#include <SDL_mixer.h>
#endif
#include "sound.h"

View File

@ -1,14 +1,14 @@
Begin3
Title: tb1
Version: 2.9.11
Entered-date: 27OCT00
Version: 2.9.12
Entered-date: 03NOV00
Description: A 2d, sci-fi arcade game.
Shoot the aliens, save the world.
Keywords: tom bombem alien game arcade SDL curses
Author: weave@eng.umd.edu (Vince Weaver)
Maintained-by: weave@eng.umd.edu (Vince Weaver)
Primary-site: metalab.unc.edu /pub/Linux/games/arcade
350kB tb1-2.9.11.tar.gz
400kB tb1-2.9.12.tar.gz
Alternate-site: http://www.glue.umd.edu/~weave/tb1
Original-site:
Platforms: Linux

9
tb1.c
View File

@ -1,6 +1,6 @@
/****************************************************************\
\* TOM BOMBEM AND THE INVASION OF THE INANIMATE_OBJECTS */
/* version 2.9.11 20 October 2000 *\
/* version 2.9.12 3 November 2000 *\
\* by Vince Weaver weave@eng.umd.edu */
/* *\
\* Originally written in Pascal and x86 assembly for DOS */
@ -10,7 +10,7 @@
\* This source is released under the GPL */
/****************************************************************/
#define TB1_VERSION "2.9.11"
#define TB1_VERSION "2.9.12"
#include <stdio.h>
#include <stdlib.h> /* for calloc */
@ -326,6 +326,11 @@ int main(int argc,char **argv)
while (1) {
/* If virtual_3 was over-written, re-load it */
if (reloadpic) {
if ((game_state->sound_possible) && (game_state->music_enabled)) {
loadSound(tb1_data_file("music/weave1.mod",game_state->path_to_data));
}
grapherror=vmwLoadPicPacked(0,0,virtual_3,1,1,
tb1_data_file("tbomb1.tb1",
game_state->path_to_data),