home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 November / Chip_2002-11_cd1.bin / oddech / orbital / orbital.exe / src / snipe2d.h < prev    next >
C/C++ Source or Header  |  2002-07-15  |  5KB  |  160 lines

  1. ///////////////////////////////////////////////
  2. // 
  3. //  Snipe2d ludum dare 48h compo entry
  4. //
  5. //  Jari Komppa aka Sol 
  6. //  http://iki.fi/sol
  7. // 
  8. ///////////////////////////////////////////////
  9. // License
  10. ///////////////////////////////////////////////
  11. // 
  12. //     This software is provided 'as-is', without any express or implied
  13. //     warranty.    In no event will the authors be held liable for any damages
  14. //     arising from the use of this software.
  15. // 
  16. //     Permission is granted to anyone to use this software for any purpose,
  17. //     including commercial applications, and to alter it and redistribute it
  18. //     freely, subject to the following restrictions:
  19. // 
  20. //     1. The origin of this software must not be misrepresented; you must not
  21. //        claim that you wrote the original software. If you use this software
  22. //        in a product, an acknowledgment in the product documentation would be
  23. //        appreciated but is not required.
  24. //     2. Altered source versions must be plainly marked as such, and must not be
  25. //        misrepresented as being the original software.
  26. //     3. This notice may not be removed or altered from any source distribution.
  27. // 
  28. // (eg. same as ZLIB license)
  29. //
  30. ///////////////////////////////////////////////
  31. //
  32. // Houses are taken from a satellite picture of glasgow.
  33. //
  34. // The sources are a mess, as I didn't even try to do anything
  35. // really organized here.. and hey, it's a 48h compo =)
  36. //
  37. #include <windows.h>
  38. #include <stdlib.h>
  39. #include <math.h>
  40. #include "SDL.h"      
  41.  
  42. // Config:
  43.  
  44. #define SHIFT_AMOUNT 12
  45. #define CAMERA_STEPS
  46. #define UNREAL_DITHER
  47. #define WOBBLE 2
  48. #define RELOAD_TIME 3000
  49. #define DISPLAY_LOGO_SCREEN
  50. #define DISPLAY_GAMEOVER_SCREEN
  51. //#define CAMERA_RECOIL
  52. //#define RECYCLE_PEDESTRIANS
  53. #define PLAY_AUDIO
  54.  
  55. enum COLORSET {
  56.     COLOR_BLACK = 0,
  57.     COLOR_WHITE,
  58.     COLOR_GREEN,
  59.     COLOR_YELLOW,
  60.     COLOR_RED
  61. };
  62.  
  63. enum CHARTYPES
  64. {
  65.     CHAR_BADGUY = 0,
  66.     CHAR_VIP = 1,
  67.     CHAR_PEDESTRIAN = 2
  68. };
  69.  
  70. extern SDL_Surface *gScreen;
  71. extern SDL_Surface *gMap;
  72. extern SDL_Surface *gAIMap;
  73. extern SDL_Surface *gFont[5];
  74. extern SDL_Surface *gCharSprite;
  75. extern float gMouseX, gMouseY, gMouseZ, gCoordScale;
  76. extern float gWobbleX, gWobbleY, gCenterX, gCenterY;
  77. extern int gControlState;
  78. extern int gStartTick;
  79. extern int gGameStartTick;
  80. extern int gFrameCount;
  81. extern int gLastTick;
  82. extern int gScore;
  83. extern int gPedestrianSpawnCount;
  84. extern int gVIPSpawnCount;
  85. extern int gBadGuySpawnCount;
  86. extern int gPedestriansKilled;
  87. extern int gBadGuisKilled;
  88. extern int gVIPsGottenToSafety;
  89. extern float gVIPSpawnTime;
  90. extern float gVIPSpawnTimePeriod;
  91. extern float gBadGuySpawnTime;
  92. extern float gBadGuySpawnTimePeriod;
  93. extern int gWobbleIndex;
  94. extern SDL_AudioSpec *gAudioSpec;
  95. extern int unreal_dither[];
  96. extern int gGameState;
  97.  
  98. extern void print(int aXofs, int aYofs, int aColor, const char *aString, ...);
  99. extern void printShadow(int aXofs, int aYofs, const char *aString, ...);
  100. extern void zoom(SDL_Surface * src, float ofsx, float ofsy, float scale);
  101. extern void zoom_unreal(SDL_Surface * src, float ofsx, float ofsy, float scale);
  102. extern void drawLine(SDL_Surface * aTarget, int x1,int y1,int x2, int y2, int clr);
  103. extern void target();
  104. extern void init();
  105. extern void logoscreen();
  106. extern void precalc_ai();
  107. extern void shoot();
  108. extern void gameoverscreen(int aReason);
  109.  
  110. typedef struct character_
  111. {
  112.     float mX, mY; // position
  113.     float mXi, mYi; // direction
  114.     float mSpeed;   // speed of this AI
  115.     int mType;   // AI type
  116.     int mTTL;    // time to live, for normal pedestrians
  117.     int mTarget; // target exit point or target character
  118.     int mNextWaypoint;   // waypoint towards which this AI is walking
  119.     int mLastWaypoints[7];   // last 7 waypoints to kill loops
  120.     int mLastWaypoint;  // counter for above array
  121. } CHARACTER;
  122.  
  123. typedef struct waypointstruc
  124. {
  125.     int mX,mY;
  126.     int *mConnection;
  127.     int mConnections;
  128. } WAYPOINT;
  129.  
  130. typedef struct spawnpointstruc
  131. {
  132.     int mX, mY;
  133.     int mClosestWaypoint;
  134.     int mType;
  135. } SPAWNPOINT;
  136.  
  137. extern int gCharacterCount;
  138. extern CHARACTER * gCharacter;
  139. extern SPAWNPOINT *gSpawnpoint;
  140. extern WAYPOINT *gWaypoint;
  141. extern int gWaypointCount;
  142. extern int gSpawnpointCount;
  143. extern int gReloading;
  144. extern CHARACTER * gSightedCharacter;
  145.  
  146. extern float distance(float aX1, float aY1, float aX2, float aY2);
  147. extern float distance(int aWaypoint, float aX, float aY);
  148. extern float distance(int aWaypoint1, int aWaypoint2);
  149. extern void handle_ai(CHARACTER &c);
  150. extern int spawn_ai(int aType);
  151.  
  152. extern int gPedestrianSpawnCount;
  153. extern int gVIPSpawnCount;
  154. extern int gBadGuySpawnCount;
  155.  
  156. extern int gVIPCount;
  157. extern int gBadGuyCount;
  158.  
  159. extern void drawCharacter(CHARACTER &c);
  160.