From: psalp@acad2.alaska.edu (Albert L. Perrien II)
Newsgroups: rec.games.programmer
Subject: game library part 2
Date: 29 Jul 92 23:28:53 GMT
Organization: University of Alaska


                Copyright (C) 1992,  Albert L. Perrien II
 
        This work may be used freely to create computer games for private use,
and for the education of individuals wishing to create computer games.  For use
in creating commercial games, please contact the Author.  The Author is not
responsible for any addictions that are created by thease games.
 

	Here's more of this ugly beast...
	Hey out there! If there is anybody feeling like critcizeing someone's
code, try mine. There always a bug in here somewhere...

	psalp@acad2.alaska.edu

 
 
        Okay, on to the buisness at hand...
=============================================================
 
        StatusType = {Alive,hit, dead, exploding}
        
 
        MonsterT = Record
                             x,y, {Current XYpos}
                             ox,oy, {old XYpos}
                             dx,dy, {XY direction}
                             sx,sy  {XY speed}
			                       			:integer;
                             MonsterType:integer;
                             status:statustype;
                             energy:integer;
                             a1,a2,a3,a4,a5,a6,a7,a8,a9:integer;   
                                           {some TScratchU variables for}
                                                    {individual monsters}
        end;
        BulletT = Record
                             x,y, {Current XYpos}
                             ox,oy, {old XYpos}
                             dx,dy, {XY direction}
                             sx,sy  {XY speed}
			                       			:integer;
                             BulletType:integer;
                             status:statustype;
                             energy:integer;
                             b1,b2,b3,b4,b5,b6,b7,b8,b9 :integer;   
                                           {some TScratchU variables for}
                                                    {individual monsters}
        end;
 
=============================================================
 
 
 
Create_Bullet
 
        Create_Bullet is passed a bullet spec from either a player or bullet. 
It finds an empty slot in the bullet array, loads in the bullet spec, and sets
the Status of the bullet to Alive.
 
 
Procedure Create_Bullet (var Bullet: Bullettype);
 
var
i:integer;
 
Begin
        Repeat i:=i+1 until Blist(i).Status:= dead;
        Blist(i):=Bullet;
        Blist(i).Status:=Alive;
end;
 
Do_Bullet
 
        This routine is a driver program that routes information to the various
bullets in the game. It is used in conjunction with the Create_Bullet and
Kill_Bullet routines (explained later) to manage the subroutines for each
individual bullet.
 
Procedure Do_Bullet
 
 
Begin
        repeat
                i:=i+1;
		
                Bullet:=Blist(i);
                With Blist(i) do
                        Begin
 
                                Case Bullettype of
                                     1:BounceBullet(Bullet);
                                          end;
                                     2:AirBullet(Bullet);
                                          end;
                                     3:DartBullet(Bullet);
                                         end;
                                     4:BoomerangBullet(Bullet);
                                         end;
                                end;
                        end;
                end;
                if Did_I_Hit(i):=true then
		   begin
			Kill_Bullet(i);
			Kill_Monster(Which_Did_I_Hit);
		   end;
                
        end;
end;
 
Kill_Bullet
 
 
        The Kill_Bullet routine removes a bullet with the identity k from the
list.  A bullet is killed whenever it moves too far away from the player
in either an x or y direction, or if it's energy is expired.
 
procedure Kill_Bullet(k:integer);
 
Begin
        Blist[k].Status:=dead;
end;
 
 
 
Did_I_Hit
 
	This boolean function returns True if a bullet hits a monster.
 
Function Did_I_Hit(k):boolean;
 
Potential_Victim:monster;
b:bullet;
 
begin
 
For I:=1 to maxMonster do 
 
begin
	 Potential_Victim:=Mlist[i];
	 B:=Blist[k];
  if ((b.x>Potential_Victim.x) and
(b.x<Potential_Victim.x+Potential_Victim.zx))
       and 
     ((b.y>Potential_Victim.y)
       and 
(b.y<Potential_Victim.y+Potential_Victim.zy))
                         {**whew**}
      then
        Did_I_Hit:=True;
      else
        Did_I_Hit:=False;
 
end; 
 
 
Function Which_Did_I_Hit(k:integer):integer;
 
begin
  I:=0;
  repeat
    I:=I+1;
    PV:=Mlist[i];
    B:=Blist[i];
    until ((b.x>pv.x) and (b.x<pv.x+pv.zx)) and ((b.y>pv.y) and
(b.y<pv.y+pv.zy))
                         {**whew again**}
   Which_Did_I_Hit:=i;
end; 
 
 
 
 
 
 
 
=============================================================
   I believe five impossible things before breakfast.
   Six is one too many...
      Albert L. Perrien II
      psalp@acad2.alaska.edu
 
Newsgroups: rec.games.programmer