28 #include "../idlib/precompiled.h"
31 #include "../framework/Session_local.h"
41 #define ENTITY_START_DIST 3000
43 #define V_WIDTH 640.0f
44 #define V_HEIGHT 480.0f
52 #define CROSSHAIR_STANDARD_MATERIAL "game/SSD/crosshair_standard"
53 #define CROSSHAIR_SUPER_MATERIAL "game/SSD/crosshair_super"
258 float scaleRadSqr = scaledRad*scaledRad;
263 if(dist < scaleRadSqr) {
280 persize.
x =
idMath::Fabs(screenBounds[1].x - screenBounds[0].x);
281 persize.
y =
idMath::Fabs(screenBounds[1].y - screenBounds[0].y);
285 x = screenBounds[0].x;
286 y = screenBounds[1].y;
305 idBounds screenBounds(screenMin, screenMax);
314 idVec3 cameraTrans(0,0,d);
316 cameraPos = worldPos + cameraTrans;
320 screenPos.
x = d*cameraPos.
x/cameraPos.
z + (0.5f*
V_WIDTH-0.5f);
321 screenPos.
y = -d*cameraPos.
y/cameraPos.
z + (0.5f*
V_HEIGHT-0.5f);
322 screenPos.
z = cameraPos.
z;
331 worldPos.
x = screenPos.
x - 0.5f *
V_WIDTH;
332 worldPos.
y = -(screenPos.
y - 0.5f *
V_HEIGHT);
333 worldPos.
z = screenPos.
z;
397 #define ASTEROID_MATERIAL "game/SSD/asteroid"
466 savefile->
Write(&count,
sizeof(count));
478 savefile->
Read(&count,
sizeof(count));
481 savefile->
Read(&
id,
sizeof(
id));
495 #define ASTRONAUT_MATERIAL "game/SSD/astronaut"
557 savefile->
Write(&count,
sizeof(count));
569 savefile->
Read(&count,
sizeof(count));
572 savefile->
Read(&
id,
sizeof(
id));
595 #define EXPLOSION_MATERIAL_COUNT 2
631 savefile->
Read(&type,
sizeof(type));
632 savefile->
Read(&
id,
sizeof(
id));
700 explosionPool[
i].
Init(_game, _position, _size, _length, _type, _buddy, _killBuddy, _followBuddy);
719 savefile->
Write(&count,
sizeof(count));
731 savefile->
Read(&count,
sizeof(count));
734 savefile->
Read(&
id,
sizeof(
id));
866 savefile->
Write(&count,
sizeof(count));
878 savefile->
Read(&count,
sizeof(count));
881 savefile->
Read(&
id,
sizeof(
id));
895 #define PROJECTILE_MATERIAL "game/SSD/fball"
933 size.Set(_size,_size);
983 savefile->
Write(&count,
sizeof(count));
995 savefile->
Read(&count,
sizeof(count));
998 savefile->
Read(&
id,
sizeof(
id));
1011 "game/SSD/powerupHealthClosed",
"game/SSD/powerupHealthOpen",
1012 "game/SSD/powerupSuperBlasterClosed",
"game/SSD/powerupSuperBlasterOpen",
1013 "game/SSD/powerupNukeClosed",
"game/SSD/powerupNukeOpen",
1014 "game/SSD/powerupRescueClosed",
"game/SSD/powerupRescueOpen",
1015 "game/SSD/powerupBonusPointsClosed",
"game/SSD/powerupBonusPointsOpen",
1016 "game/SSD/powerupDamageClosed",
"game/SSD/powerupDamageOpen",
1019 #define POWERUP_MATERIAL_COUNT 6
1175 savefile->
Write(&count,
sizeof(count));
1187 savefile->
Read(&count,
sizeof(count));
1190 savefile->
Read(&
id,
sizeof(
id));
1257 savefile->
Write(&entCount,
sizeof(entCount));
1258 for(
int i = 0;
i < entCount;
i++) {
1318 savefile->
Read(&entCount,
sizeof(entCount));
1320 for(
int i = 0;
i < entCount;
i++) {
1322 savefile->
Read(&type,
sizeof(type));
1323 savefile->
Read(&
id,
sizeof(
id));
1341 int key =
event->evValue;
1466 idStr tempName = _name;
1476 idStr tempName = _name;
1486 idStr tempName = _name;
1487 int weapon = atoi(tempName.
Right(2))-1;
1496 idStr tempName = _name;
1506 idStr tempName = _name;
1715 int accuracyPoints =
Max( 0, accuracy - 50 ) * 20;
1728 accuracyPoints =
Max( 0, saveAccuracy - 50 ) * 20;
1861 bool flipped =
false;
1862 for (
int j = 0;
j<
i ;
j++) {
1979 if(asteroid->
health <= 0) {
1989 asteroid->
noHit =
true;
2006 asteroid->
noHit =
true;
2188 if(astronaut->
health <= 0) {
2201 astronaut->
noHit =
true;
2215 astronaut->
noHit =
true;
2289 #define MAX_SOUND_CHANNEL 8
void SetPosition(const idVec3 &_position)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
virtual void SetStateString(const char *varName, const char *value)
GLsizei const GLfloat * points
void SetMaterial(const char *_name)
SSDEntity * GetSpecificEntity(int type, int id)
virtual void WriteToSaveGame(idFile *savefile)
virtual void WriteToSaveGame(idFile *savefile)
void Init(idGameSSDWindow *_game, const idVec3 &startPosition, const idVec2 &_size, float _speed, float rotate, int _health)
virtual const idSoundShader * FindSound(const char *name, bool makeDefault=true)=0
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
static SSDPoints * GetNewPoints(idGameSSDWindow *_game, SSDEntity *_ent, int _points, int _length, int _distance, const idVec4 &color)
idVec3 GetCenter(void) const
static SSDAstronaut astronautPool[MAX_ASTRONAUT]
const char * explosionMaterials[]
void HitAstronaut(SSDAstronaut *astronaut, int key)
ID_INLINE T Max(T x, T y)
static void WriteProjectiles(idFile *savefile)
GLenum GLenum GLenum GLenum GLenum scale
virtual bool ParseInternalVar(const char *name, idParser *src)
#define PROJECTILE_MATERIAL
virtual void PlayShaderDirectly(const char *name, int channel=-1)=0
void Init(idGameSSDWindow *_game, SSDEntity *_ent, int _points, int _length, int _distance, const idVec4 &color)
static SSDProjectile * GetNewProjectile(idGameSSDWindow *_game, const idVec3 &_beginPosition, const idVec3 &_endPosition, float _speed, float _size)
static void ReadExplosions(idFile *savefile, idGameSSDWindow *_game)
idBounds WorldToScreen(const idBounds worldBounds)
#define CROSSHAIR_SUPER_MATERIAL
void ParseString(idParser *src, idStr &out)
static SSDPoints * GetSpecificPoints(int id)
virtual void WriteToSaveGame(idFile *savefile)
SSDEntity * EntityHitTest(const idVec2 &pt)
virtual void WriteToSaveGame(idFile *savefile)
static void ReadAsteroids(idFile *savefile, idGameSSDWindow *_game)
virtual void EntityUpdate()
virtual void WriteToSaveGame(idFile *savefile)
int LoadMemory(const char *ptr, int length, const char *name)
void BeginLevel(int level)
GLuint GLuint GLsizei GLenum type
static SSDAsteroid * GetSpecificAsteroid(int id)
virtual void ReadFromSaveGame(idFile *savefile)
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
virtual void WriteToSaveGame(idFile *savefile)
#define ASTRONAUT_MATERIAL
static SSDPowerup * GetNewPowerup(idGameSSDWindow *_game, float _speed, float _rotation)
void PlaySound(const char *sound)
void AddHealth(int health)
void AstronautStruckPlayer(SSDAstronaut *astronaut)
int Icmp(const char *text) const
const idVec2 & ToVec2(void) const
virtual void OnHit(int key)
virtual void WriteToSaveGame(idFile *savefile)
#define ENTITY_START_DIST
virtual const char * HandleEvent(const sysEvent_t *event, bool *updateVisuals)
void SetSize(const idVec2 &_size)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
int nextAstronautSpawnTime
void DrawMaterialRotated(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex=1.0, float scaley=1.0, float angle=0.0f)
virtual void OnHit(int key)
void SetRotation(float _rotation)
void AsteroidStruckPlayer(SSDAsteroid *asteroid)
static void WriteExplosions(idFile *savefile)
GLuint GLuint GLsizei count
virtual void Draw(int time, float x, float y)
idList< SSDEntity * > entities
virtual void ReadFromSaveGame(idFile *savefile)
int DrawText(const char *text, float textScale, int textAlign, idVec4 color, idRectangle rectDraw, bool wrap, int cursor=-1, bool calcOnly=false, idList< int > *breaks=NULL, int limit=0)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
idGameSSDWindow(idUserInterfaceLocal *gui)
#define CROSSHAIR_STANDARD_MATERIAL
void Init(idGameSSDWindow *_game, const idVec3 &startPosition, float _speed, float rotate, int _health)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
void Init(idGameSSDWindow *_game, float _speed, float _rotation)
static float Fabs(float f)
virtual void OnStrikePlayer()
virtual void WriteToSaveGame(idFile *savefile)
void AddDamage(int damage)
idDeviceContext * GetDC(void)
void ParseAsteroidData(int level, const idStr &asteroidDataString)
void ParseAstronautData(int level, const idStr &astronautDataString)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
virtual int Read(void *buffer, int len)
void ContinueGame()
Continue game resets the players health.
static int FindText(const char *str, const char *text, bool casesensitive=true, int start=0, int end=-1)
void Init(idGameSSDWindow *_game, const idVec3 &_position, const idVec2 &_size, int _length, int _type, SSDEntity *_buddy, bool _killBuddy=true, bool _followBuddy=true)
static void ReadPoints(idFile *savefile, idGameSSDWindow *_game)
#define POWERUP_MATERIAL_COUNT
virtual void EntityUpdate()
static void WritePoints(idFile *savefile)
void ParseLevelData(int level, const idStr &levelDataString)
static void ReadAstronauts(idFile *savefile, idGameSSDWindow *_game)
#define MAX_SOUND_CHANNEL
void AddScore(SSDEntity *ent, int points)
virtual void EntityUpdate()
virtual void ReadFromSaveGame(idFile *savefile)
const char * Right(int len, idStr &result) const
static float Tan(float a)
const idMaterial * crosshairMaterial[CROSSHAIR_COUNT]
const idMaterial * material
void ReadSaveGameString(idStr &string, idFile *savefile)
void WriteSaveGameString(const char *string, idFile *savefile)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
virtual void EntityUpdate()
static SSDPoints pointsPool[MAX_POINTS]
static SSDAsteroid * GetNewAsteroid(idGameSSDWindow *_game, const idVec3 &startPosition, const idVec2 &_size, float _speed, float rotate, int _health)
idDeclManager * declManager
virtual idWinVar * GetWinVarByName(const char *_name, bool winLookup=false, drawWin_t **owner=NULL)
const char * powerupMaterials[][2]
int CharWidth(const char c, float scale)
virtual void WriteToSaveGame(idFile *savefile)
static SSDExplosion explosionPool[MAX_EXPLOSIONS]
int Append(const type &obj)
int nextAsteroidSpawnTime
void Init(idGameSSDWindow *_game, const idVec3 &_beginPosition, const idVec3 &_endPosition, float _speed, float _size)
static SSDAstronaut * GetNewAstronaut(idGameSSDWindow *_game, const idVec3 &startPosition, float _speed, float rotate, int _health)
#define EXPLOSION_MATERIAL_COUNT
void SetGame(idGameSSDWindow *_game)
idUserInterfaceLocal * gui
virtual void WriteToSaveGame(idFile *savefile)
idList< SSDAstronautData_t > astronautData
void Lerp(const idVec4 &v1, const idVec4 &v2, const float l)
bool RemoveIndex(int index)
bool IntersectsBounds(const idBounds &a) const
static SSDPowerup powerupPool[MAX_POWERUPS]
void ParseWeaponData(int weapon, const idStr &weaponDataString)
#define ASTEROID_MATERIAL
virtual int Write(const void *buffer, int len)
static SSDExplosion * GetSpecificExplosion(int id)
static SSDAstronaut * GetSpecificAstronaut(int id)
void SetRadius(float _radius, float _hitFactor=1.0f)
GLsizei const GLcharARB const GLint * length
const char * c_str(void) const
idList< SSDWeaponData_t > weaponData
static SSDAsteroid asteroidPool[MAX_ASTEROIDS]
void SetSort(float s) const
void HitAsteroid(SSDAsteroid *asteroid, int key)
bool HitTest(const idVec2 &pt)
static void WritePowerups(idFile *savefile)
void Draw(idDeviceContext *dc, const idVec2 &cursor)
void MoverInit(const idVec3 &_speed, float _rotationSpeed)
idBounds & ExpandSelf(const float d)
void Lerp(const idVec3 &v1, const idVec3 &v2, const float l)
static SSDExplosion * GetNewExplosion(idGameSSDWindow *_game, const idVec3 &_position, const idVec2 &_size, int _length, int _type, SSDEntity *_buddy, bool _killBuddy=true, bool _followBuddy=true)
char * va(const char *fmt,...)
virtual const char * HandleEvent(const sysEvent_t *event, bool *updateVisuals)
virtual void DestroyEntity()
virtual void Draw(idDeviceContext *dc)
virtual void HandleNamedEvent(const char *namedEvent)
virtual void ReadFromSaveGame(idFile *savefile, idGameSSDWindow *_game)
virtual void EntityUpdate()
static void WriteAsteroids(idFile *savefile)
virtual bool ParseInternalVar(const char *name, idParser *src)
idVec3 ScreenToWorld(const idVec3 &screenPos)
static void ReadPowerups(idFile *savefile, idGameSSDWindow *_game)
static SSDProjectile * GetSpecificProjectile(int id)
virtual void WriteToSaveGame(idFile *savefile)
void DrawMaterial(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex=1.0, float scaley=1.0)
idList< SSDPowerupData_t > powerupData
virtual void EntityUpdate()
void Set(const float x, const float y, const float z, const float w)
ID_INLINE T Min(T x, T y)
virtual idWinVar * GetWinVarByName(const char *_name, bool winLookup=false, drawWin_t **owner=NULL)
SSDGameStats_t Data that is used for the game that is currently running.
idList< SSDLevelData_t > levelData
static SSDProjectile projectilePool[MAX_PROJECTILES]
void ParsePowerupData(int level, const idStr &powerupDataString)
Powerups work in two phases: 1.) Closed container hurls at you If you shoot the container it open 3...
SSDLevelStats_t levelStats
float LengthSqr(void) const
virtual void ReadFromSaveGame(idFile *savefile)
static void ReadProjectiles(idFile *savefile, idGameSSDWindow *_game)
virtual void OnStrikePlayer()
static void WriteAstronauts(idFile *savefile)
virtual void WriteToSaveGame(idFile *savefile)
static SSDPowerup * GetSpecificPowerup(int id)
idList< SSDAsteroidData_t > asteroidData