File: enemytype.h

package info (click to toggle)
wing 0.7-33
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,744 kB
  • sloc: cpp: 2,526; sh: 65; makefile: 16
file content (127 lines) | stat: -rw-r--r-- 4,471 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*  Copyright (C) 2000 Anil Shrestha and Adam Hiatt
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2, or (at your option)
*   any later version.
*
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this program; if not, write to the Free Software
*   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * EnemyTYPE																				     *
 *                                                                           *
 * This class provides the methods for keeping track of the linked list of   *
 * enemies that is loaded with each succesive level of play in the game. 	  *
 * It is responsible for AI and for updating the list with each new level of *
 * the game.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


#ifndef _ENEMYTYPE_H
#define _ENEMYTYPE_H

#include <fstream>
#include "bullettype.h"
#include "animationtype.h"
#include "util.h"

		struct EnemyNodeTYPE
      {
	 		EnemyNodeTYPE  *  next;              // pointer to next node
		   EnemyNodeTYPE  *  back;              // pointer to previous node
		  	bool				attacking;
		  	bool				dead;         
   		int   TimeOfLastFired;
	  		WeaponEnum     weapon;
   		EnemyEnum      TypeOfEnemy;
	  		int            xpos, ypos, dx,dy,health;
         StateEnum      state;
         int 				state_stage;
         int 				explode_stage;

   	 	// constructors

	 	   EnemyNodeTYPE (EnemyNodeTYPE * back_link = NULL,EnemyNodeTYPE * next_link = NULL)
		   :  next    			 ( next_link ),
            back    			 ( back_link ),
            attacking		 ( false ),
            dead				 ( false ),
            TimeOfLastFired ( 0 ),
            weapon          ( laser ),
            TypeOfEnemy     ( scout ),
            xpos 				 ( rand () % ( SCREEN_WIDTH - 72) ),
            ypos 				 ( INIT_ENEMY_Y ),
            dx 				 ( 1 ),
            dy 				 ( 1 ),
            health			 ( 0 ),
            state           ( IntToState (rand ()%TOTAL_NUM_STATES) ),
				state_stage  	 ( 0 ),
            explode_stage   ( 0 )
 	     	{  }

         void ResetNode ( )
         {
				xpos = rand () % ( SCREEN_WIDTH - 72);
            ypos = INIT_ENEMY_Y;
            dx = dy = 1;
            state = IntToState (rand ()%TOTAL_NUM_STATES);
            state_stage = TimeOfLastFired = 0; 
         }
		};

class EnemyTYPE
{
	public :
   // Constructors & Destructors
      EnemyTYPE ( );
     ~EnemyTYPE ( );

   // Modifiers
      void LoadEnemies 	       ( char * level_file, char * sprite_file, char * bullet_file , char * explode_file  );
      void UpdateAI            ( int plane_x, int plane_y );
      void AddAttacker         ( );
      void DestroyEnemies 		 ( );
      void SetHealth           ( int index, int new_health );
      

   // Accessors
      void Display 		       ( BITMAP * buffer );
      int  GetTotalNumEnemies  ( );
		int  GetNumAttackers     ( );
      int  GetNumEnemiesLeft   ( );
      int  GetHealth 			 ( int index );
      EnemyNodeTYPE  *  GetEnemyList ( );
      BulletTYPE     *  GetBullets ( );

   // Public Data
      apvector <spr_mask> myEnemyMasks;

   private :
   	// private member functions
		void Attack_1 ( EnemyNodeTYPE * enemy );
		void Attack_2 ( EnemyNodeTYPE * enemy );
		void Attack_3 ( EnemyNodeTYPE * enemy ,int plane_x);
		void Attack_4 ( EnemyNodeTYPE * enemy );
  		void Attack_5 ( EnemyNodeTYPE * enemy );
  		void Attack_6 ( EnemyNodeTYPE * enemy );
      void DeleteNode          ( EnemyNodeTYPE * scan );

   	// private data members
      int num_enemies_left;
      int num_enemies_attacking;
      int num_enemies_per_level;
      EnemyNodeTYPE * most_recent;          // ####################### is this necessary ???
      AnimationTYPE   enemy_images;
      AnimationTYPE   explode_images;
      EnemyNodeTYPE * enemy_list;
      BulletTYPE 		 enemy_bullets;
};

#endif