home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////
- //
- // Snipe2d ludum dare 48h compo entry
- //
- // Jari Komppa aka Sol
- // http://iki.fi/sol
- //
- ///////////////////////////////////////////////
- // License
- ///////////////////////////////////////////////
- //
- // This software is provided 'as-is', without any express or implied
- // warranty. In no event will the authors be held liable for any damages
- // arising from the use of this software.
- //
- // Permission is granted to anyone to use this software for any purpose,
- // including commercial applications, and to alter it and redistribute it
- // freely, subject to the following restrictions:
- //
- // 1. The origin of this software must not be misrepresented; you must not
- // claim that you wrote the original software. If you use this software
- // in a product, an acknowledgment in the product documentation would be
- // appreciated but is not required.
- // 2. Altered source versions must be plainly marked as such, and must not be
- // misrepresented as being the original software.
- // 3. This notice may not be removed or altered from any source distribution.
- //
- // (eg. same as ZLIB license)
- //
- ///////////////////////////////////////////////
- //
- // Houses are taken from a satellite picture of glasgow.
- //
- // The sources are a mess, as I didn't even try to do anything
- // really organized here.. and hey, it's a 48h compo =)
- //
- #include <windows.h>
- #include <stdlib.h>
- #include <math.h>
- #include "SDL.h"
-
- // Config:
-
- #define SHIFT_AMOUNT 12
- #define CAMERA_STEPS
- #define UNREAL_DITHER
- #define WOBBLE 2
- #define RELOAD_TIME 3000
- #define DISPLAY_LOGO_SCREEN
- #define DISPLAY_GAMEOVER_SCREEN
- //#define CAMERA_RECOIL
- //#define RECYCLE_PEDESTRIANS
- #define PLAY_AUDIO
-
- enum COLORSET {
- COLOR_BLACK = 0,
- COLOR_WHITE,
- COLOR_GREEN,
- COLOR_YELLOW,
- COLOR_RED
- };
-
- enum CHARTYPES
- {
- CHAR_BADGUY = 0,
- CHAR_VIP = 1,
- CHAR_PEDESTRIAN = 2
- };
-
- extern SDL_Surface *gScreen;
- extern SDL_Surface *gMap;
- extern SDL_Surface *gAIMap;
- extern SDL_Surface *gFont[5];
- extern SDL_Surface *gCharSprite;
- extern float gMouseX, gMouseY, gMouseZ, gCoordScale;
- extern float gWobbleX, gWobbleY, gCenterX, gCenterY;
- extern int gControlState;
- extern int gStartTick;
- extern int gGameStartTick;
- extern int gFrameCount;
- extern int gLastTick;
- extern int gScore;
- extern int gPedestrianSpawnCount;
- extern int gVIPSpawnCount;
- extern int gBadGuySpawnCount;
- extern int gPedestriansKilled;
- extern int gBadGuisKilled;
- extern int gVIPsGottenToSafety;
- extern float gVIPSpawnTime;
- extern float gVIPSpawnTimePeriod;
- extern float gBadGuySpawnTime;
- extern float gBadGuySpawnTimePeriod;
- extern int gWobbleIndex;
- extern SDL_AudioSpec *gAudioSpec;
- extern int unreal_dither[];
- extern int gGameState;
-
- extern void print(int aXofs, int aYofs, int aColor, const char *aString, ...);
- extern void printShadow(int aXofs, int aYofs, const char *aString, ...);
- extern void zoom(SDL_Surface * src, float ofsx, float ofsy, float scale);
- extern void zoom_unreal(SDL_Surface * src, float ofsx, float ofsy, float scale);
- extern void drawLine(SDL_Surface * aTarget, int x1,int y1,int x2, int y2, int clr);
- extern void target();
- extern void init();
- extern void logoscreen();
- extern void precalc_ai();
- extern void shoot();
- extern void gameoverscreen(int aReason);
-
- typedef struct character_
- {
- float mX, mY; // position
- float mXi, mYi; // direction
- float mSpeed; // speed of this AI
- int mType; // AI type
- int mTTL; // time to live, for normal pedestrians
- int mTarget; // target exit point or target character
- int mNextWaypoint; // waypoint towards which this AI is walking
- int mLastWaypoints[7]; // last 7 waypoints to kill loops
- int mLastWaypoint; // counter for above array
- } CHARACTER;
-
- typedef struct waypointstruc
- {
- int mX,mY;
- int *mConnection;
- int mConnections;
- } WAYPOINT;
-
- typedef struct spawnpointstruc
- {
- int mX, mY;
- int mClosestWaypoint;
- int mType;
- } SPAWNPOINT;
-
- extern int gCharacterCount;
- extern CHARACTER * gCharacter;
- extern SPAWNPOINT *gSpawnpoint;
- extern WAYPOINT *gWaypoint;
- extern int gWaypointCount;
- extern int gSpawnpointCount;
- extern int gReloading;
- extern CHARACTER * gSightedCharacter;
-
- extern float distance(float aX1, float aY1, float aX2, float aY2);
- extern float distance(int aWaypoint, float aX, float aY);
- extern float distance(int aWaypoint1, int aWaypoint2);
- extern void handle_ai(CHARACTER &c);
- extern int spawn_ai(int aType);
-
- extern int gPedestrianSpawnCount;
- extern int gVIPSpawnCount;
- extern int gBadGuySpawnCount;
-
- extern int gVIPCount;
- extern int gBadGuyCount;
-
- extern void drawCharacter(CHARACTER &c);
-