⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic.h

📁 2D即时战略游戏源码.仿红色警戒之类的。不过有点粗糙
💻 H
字号:
#ifndef BASIC_H
#define BASIC_H
#include"windows.h"
#include"ddraw.h"
#include"dsound.h"


#define ALL 0xFF
#define TANKFACTORY   101  
#define HOUSEA		   201 	 
#define GREENFACTORY   202                          
#define TANK  0
#define GREENER 3
#define MAN   1



#define HACKMOVE 255
#define FIXCAR 3
#define GREENING 5
#define STAY    1
#define WAIT    2  
#define HOME    4     
#define FORENEMY 8    
#define FIGHTING   16 
#define ROTATE    32
#define ROUND       64
#define WALK    128


#define DEADLAND  1

#define HILL      2 
#define CAR       128 
#define BUILD     8   
#define TREE      16//no way can be pass
#define LEFTTOPTREE 32 //can pass from left to right or right to left
#define RIGHTTOPTREE 64



#define WE   50
#define WEFIX 51

#define ENEMY 75                      
                     
#define RADARWIDTH 128
#define RADARHEIGHT 128
#define RADARx    17
#define RADARy    13 
#define PANELWIDTH  480
#define PANELHEIGHT 480                          

#define UP 1
#define DOWN 4
#define LEFT 16
#define RIGHT 128                            

#define BACKGROUND 0   
#define SHOWED 1
#define BACKGROUNDHEIGHT  64
#define BACKGROUNDWIDTH   64
#define BS       48
#define CS       24
#define RADARBLOCK (int)(RADARWIDTH/BACKGROUNDWIDTH)

#define EAST 4
#define EASTSOUTH 6     //all tank orient is the same
#define SOUTH 8  
#define WESTSOUTH 10 
#define WEST 12
#define WESTNORTH 14
#define NORTH      0
#define EASTNORTH 2 

#define LEFTPATH 1
#define RIGHTPATH 2
#define UPPATH  3
#define DOWNPATH 4 
#define STOP {-1,-1}
#define FORE 1
#define BACK -1  

#define PLAYANI  0
#define MENU      1
#define READY    5
#define PLAYING   2
#define GAMEEDITOR 3
#define OPTION    4
#define ALONE     8
#define SPLASH    16
#define MUD       32 
#define GETSELECT 64
#define GETCONNECT 128
#define EXIT	   255 	

/*class basic{
      public:void Free();
             basic *Prev;
             basic *Next;
             
            };
*/
class myarmy{
public:       
       int type; 
       int family;
       int Number;
       int state;//FINXING,ROUNDING,FORENEMY,HOME,WALK,FIGHTING,STAY
					
	   POINT bkgdposite;  
       POINT nextpos;
	   POINT nowpos;
	   POINT lastpos;
       
	   POINT nowHL;
       POINT befHL;
	   POINT nextHL;

	   int  nowdir;
       int  dect; 
	   int dir;

	   POINT station;
       POINT placetogo;
       POINT placeready;
	   POINT FightPoint;
       
       int   around;
	   BOOL  bAround;
       POINT firstdot;//the  max distance I have gone;
       BOOL bStop; 
       BOOL view; 
       BOOL fight;    
       BOOL bCallFix;
	   BOOL active;
       BOOL dead;
	   BOOL Sounded;
       BOOL readytostop;
       
       int waittime;
       int fighttime;//rest time to dead;
	   int fixtime;
	   
       //replace part;
       //int size;

       int blood;
       int attack;
       int damage;
       int protect;
       float speed;
       int speedmax;
       int searchability;
	   int Goods;
       int movability;    

      
       LPDIRECTDRAWSURFACE mysurf; 
	  
	   int frame;
       RECT rcPic;
	   int part;
	   int size;
	   

       
       //POINT pic; 
       
    /*   struct
       {BOOL readytostop;
        BOOL east;
        BOOL south;
        BOOL west;
        BOOL north; 
        BOOL around;
        }forstop;  */
        
       struct
	  {int powertype;
	   int bulletnum;
	   }power;
       
             
	   myarmy *Next;
	   myarmy *Prev;
	   myarmy* captain;
      
	   myarmy(int x,int y,int tanktype,int tankID);	
	   myarmy();
       void FlashBlock();
	   void Free();
	   void Draw();//the Graphics Motor;
       void wait();//I can't go
       void ToHell(void);//ready to visit Max;
       void Move(void);//walk Motor;
       void DoMyThings(void);//when frame=0;
	  
       
       
};   



class FixCar{                  

       public:BOOL bFIX; 
              myarmy* tanknum;
              int  fixlevel;
              myarmy* befixed; 
              BOOL bCALL;
              void Fix(void); 
              };



struct TANKINFO{
   myarmy* tanknum; 
   int type;
   int blood;
   float speed;
   int attack;
   int protect;
   BOOL view;
   };



class bullet{
             
      public: int type;
              int state;
			  
              int waittime;
              int life;

              int speed;
              int power;

              LPDIRECTDRAWSURFACE mysurf;
			  LPDIRECTDRAWSURFACE bufsurf;
//		      LPDIRECTSOUNDBUFFER   lpDirectSoundBuffer  [8]; // SoundBuffer interface
  //            LPDIRECTSOUND3DBUFFER lpDirectSound3DBuffer[8]; // 3D interface (to same buffer)  
  
              int frame;
              RECT rcPic;

              POINT lastpos;
              POINT nowHL;
              POINT nowpos;
			  POINT fir;
			  POINT goat;

              BOOL getit;

			  bullet *Prev;
              bullet *Next;
             

              void Move(void);
			  void Draw(void);
			  void Free(void);
			  void DoMyThings(void);
			  bullet(POINT firstHL,POINT lastHL,int bulltype);
			  bullet();
            
             }; 


class Exp{
		public:int type;
		       POINT nowpos;
			   
		       
			   LPDIRECTDRAWSURFACE mysurf; 
			   LPDIRECTDRAWSURFACE bufsurf;
//		       LPDIRECTSOUNDBUFFER   lpDirectSoundBuffer  [8]; // SoundBuffer interface
//               LPDIRECTSOUND3DBUFFER lpDirectSound3DBuffer[8]; // 3D interface (to same buffer)  
  
			   RECT rcPic;
			   int w;
			   int h;
			   int frame;

		       int power;
		       int life;
		       
		       Exp(POINT p,int type);
			   Exp();
		       Exp* Prev;
		       Exp* Next;
			   void DoMyThings(void);
			   void Draw();
		       void Free(); 
		       
	};		       
		       	
  
  
class Building{
          public: 
                
			      int type;
				  int family;
				  int state;
					
				  LPDIRECTDRAWSURFACE mysurf; 
//			      LPDIRECTSOUNDBUFFER   lpDirectSoundBuffer  [8]; // SoundBuffer interface
 //                 LPDIRECTSOUND3DBUFFER lpDirectSound3DBuffer[8]; // 3D interface (to same buffer)  
  
				  int frame;
				  RECT rcPic;

				  POINT nowpos;	 
				  POINT nowHL;
				  
                  int life; 
                  int blood;
				  int protect;
                  int unittime;
				  BOOL active;

				   Building *Next;
                   Building *Prev;
				
                 

                  Building(int x,int y,int family,int type); 
				  Building();
				  void Draw();
                  void ToHell();
                  void DoMyThings();
                  void Free();
                };  
                  
               
class intro{
public:
	  POINT p;
	  LPDIRECTDRAWPALETTE     lpDDPal;  
	  LPDIRECTDRAWSURFACE     lpIntr;
	  DWORD time;
	  BOOL  bplay;
	  void InitIntro();
	  void FreeIntro();
	  BOOL Intro();
    };
  

class track{
     public:
		   track *Next;
		   track *Prev;

           POINT p;
           LPDIRECTDRAWSURFACE     mysurf;
		   DWORD time;
		   track();
		   track(POINT p,int type);
		   void DoMyThings();
		   void Free();
           };
	

struct TABLE{
int blocktype;
int displaystate;
int whatin;//CAR,HILL,TREE,Build,etc
BOOL bsthtop;
BOOL bsthbottom;
BOOL bsthleft;
BOOL bsthright;
struct {
		LPDIRECTDRAWSURFACE mysurf; 
		POINT nowpos;
		RECT rcPic;
           }tree;//everything on the floor;
myarmy* CarOb;
Building* BuildOb;
//TABLE *Next;
//TABLE *Prev;
};

struct Around{
	int nn;
	int ne;
	int ee;
	int es;
	int ss;
	int sw;
	int ww;
	int wn;
};



		 
POINT Howtogo(POINT nowHL,int dect,POINT objectplace,myarmy *soldier,TABLE table[66][66]);

int DecideDect(POINT firstpace,POINT secondpace);
int DecideDir(POINT firstpace,POINT secondpace); //for decide around?           
            


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -