Fixed bullet images.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1689 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2005-12-09 02:10:24 +00:00
parent b511be1e27
commit 127ce4a500

View file

@ -139,7 +139,7 @@ int monsterpics;
typedef struct SIEnemyType_s typedef struct SIEnemyType_s
{ {
qhandle_t *picture; texture *picture;
float width; float width;
float height; float height;
int health; int health;
@ -154,7 +154,7 @@ typedef struct SIEnemyType_s
int healthregen; int healthregen;
int shotdamage; int shotdamage;
qhandle_t *shotpicture; texture *shotpicture;
} SIEnemyType_t; } SIEnemyType_t;
typedef struct SIRoute_s typedef struct SIRoute_s
@ -182,7 +182,7 @@ typedef struct SIaddon_s
int power; int power;
float refire; float refire;
float reloadtime; float reloadtime;
qhandle_t *tex; texture *tex;
} SIaddon_t; } SIaddon_t;
typedef struct SIp_s typedef struct SIp_s
@ -238,7 +238,7 @@ typedef struct SIbullet_s
float alpha; float alpha;
float alphachange; float alphachange;
qhandle_t *tex; texture *tex;
} SIbullet_t; } SIbullet_t;
typedef struct ShopRegion_s typedef struct ShopRegion_s
@ -250,10 +250,10 @@ typedef struct ShopRegion_s
char *text; char *text;
qhandle_t *tex; texture *tex;
qboolean (*AppearCondition) (int ident); qboolean (*AppearCondition) (int ident);
void (*CallFunc) (int ident); void (*CallFunc) (int ident);
qhandle_t *(*Texture) (qhandle_t *def, int ident); texture *(*Texture) (texture *def, int ident);
int ident; int ident;
} ShopRegion_t; } ShopRegion_t;
@ -274,19 +274,19 @@ float leveltime;
int livingmonsters; int livingmonsters;
qhandle_t SIplayertexture; //both texture SIplayertexture; //both
qhandle_t *SIbaddietexture; //game only texture *SIbaddietexture; //game only
qhandle_t *SIbullettexture; //game only texture *SIbullettexture; //game only
qhandle_t SIexplosiontexture; //game only texture SIexplosiontexture; //game only
qhandle_t SIhealthtexture; //shop only texture SIhealthtexture; //shop only
qhandle_t SIleaveshoptexture; //shop only texture SIleaveshoptexture; //shop only
qhandle_t SIshrinktexture; //shop only texture SIshrinktexture; //shop only
qhandle_t SIcannontexture; //game+shop texture SIcannontexture; //game+shop
qhandle_t SIsideshottexture; //shop only texture SIsideshottexture; //shop only
qhandle_t SIrapidtexture; texture SIrapidtexture;
qhandle_t SIsavegametexture; texture SIsavegametexture;
qhandle_t SIloadgametexture; texture SIloadgametexture;
qhandle_t SIquittexture; texture SIquittexture;
/* /*
sound SoundWin; sound SoundWin;
sound SoundLoose; sound SoundLoose;
@ -326,7 +326,7 @@ void SISPUpgrade1 (int ident)
SIp.cannon[M_FORWARD].power++; SIp.cannon[M_FORWARD].power++;
SIp.cash -= 500; SIp.cash -= 500;
} }
qhandle_t *SISPUpgrade1Texture (qhandle_t *def, int ident) texture *SISPUpgrade1Texture (texture *def, int ident)
{ {
return &SIbullettexture[SIp.cannon[M_FORWARD].power+1]; return &SIbullettexture[SIp.cannon[M_FORWARD].power+1];
} }
@ -535,7 +535,7 @@ bool gamesaved = 2;
void SISaveGame(int ident) void SISaveGame(int ident)
{ {
int a; int a;
qhandle_t handle; texture handle;
FS_Open("spaceinv/spaceinv.sav", &handle, 2); FS_Open("spaceinv/spaceinv.sav", &handle, 2);
@ -559,7 +559,7 @@ void SILoadGame(int ident)
{ {
int a; int a;
int len; int len;
qhandle_t handle; texture handle;
len = FS_Open("spaceinv/spaceinv.sav", &handle, 1); len = FS_Open("spaceinv/spaceinv.sav", &handle, 1);
if (len < 0) if (len < 0)
@ -585,7 +585,7 @@ void SILoadGame(int ident)
bool SILoadGameThere(int ident) bool SILoadGameThere(int ident)
{ {
qhandle_t handle; texture handle;
if (gamesaved = 2) if (gamesaved = 2)
{ {
if (FS_Open("spaceinv/spaceinv.sav", &handle, 1) >= 0) if (FS_Open("spaceinv/spaceinv.sav", &handle, 1) >= 0)
@ -717,7 +717,7 @@ void Draw_String2C(int x, int y, char *string, int extraparam)
} }
} }
void Draw_Picture(qhandle_t tex, float x, float y, float w, float h) void Draw_Picture(texture tex, float x, float y, float w, float h)
{ {
Draw_Image(x, y, w, h, 0, 0, 1, 1, tex); Draw_Image(x, y, w, h, 0, 0, 1, 1, tex);
} }
@ -799,6 +799,8 @@ void SI_2D (void)
{ {
Draw_Colour4f(1, 1, 1, 1); Draw_Colour4f(1, 1, 1, 1);
/* /*
was a flame trail. :(
grDisable(GL_TEXTURE_2D); grDisable(GL_TEXTURE_2D);
grShadeModel(GL_SMOOTH); grShadeModel(GL_SMOOTH);
grBegin(GL_TRIANGLES); grBegin(GL_TRIANGLES);
@ -895,71 +897,25 @@ void SI_2D (void)
{ {
switch (SIbullet[a].type) switch (SIbullet[a].type)
{ {
case 1: case 1:
/* grDisable(GL_TEXTURE_2D);
grBegin(GL_LINES);
for (b = 0; b < SIbullet[a].charge; b++) for (b = 0; b < SIbullet[a].charge; b++)
{ {
// frame = (int)random() * 1000; Draw_Colour4f(random(), random(), random(), SIbullet[a].alpha);
grColor4f(random(), random(), random(), SIbullet[a].alpha); Draw_Line (SIbullet[a].xpos+SIbullet[a].width/2,
#if 1 SIbullet[a].ypos+SIbullet[a].height/2,
grVertex2f (SIbullet[a].xpos+SIbullet[a].width/2, SIbullet[a].ypos+SIbullet[a].height/2); SIbullet[a].xpos+SIbullet[a].width/2+(float)sin((frame+2)*(a+1)*(b+1))*SIbullet[a].width,
#else SIbullet[a].ypos+SIbullet[a].height/2+(float)cos((frame+2)*(a+1)*(b+1))*SIbullet[a].height);
grVertex2f (SIbullet[a].xpos+SIbullet[a].width/2+(float)sin((frame+1)*(a+1)*(b+1))*SIbullet[a].width, SIbullet[a].ypos+SIbullet[a].height/2+(float)cos((frame+1)*(a+1)*(b+1))*SIbullet[a].height);
#endif
grVertex2f (SIbullet[a].xpos+SIbullet[a].width/2+(float)sin((frame+2)*(a+1)*(b+1))*SIbullet[a].width, SIbullet[a].ypos+SIbullet[a].height/2+(float)cos((frame+2)*(a+1)*(b+1))*SIbullet[a].height);
} }
grEnd();
grEnable(GL_TEXTURE_2D);
break; break;
*/
/* case 2: case 2:
x=realtime*50; x=realtime*50;
grColor4f(1, 1, 1, SIbullet[a].alpha);
grDisable(GL_TEXTURE_2D);
grShadeModel(GL_SMOOTH);
grBegin(GL_QUADS);
x = SIbullet[a].xpos+SIbullet[a].width/2; Draw_Colour4f(1, 1, 1, SIbullet[a].alpha);
y = SIbullet[a].ypos+SIbullet[a].height/2; Draw_Picture(*SIbullet[a].tex, SIbullet[a].xpos, 0, SIbullet[a].width, SIbullet[a].ypos+SIbullet[a].height);
grColor4f(1, 1, 1, 0);
grVertex2f(x+SIbullet[a].width, y);
grColor4f(1, 1, 1, SIbullet[a].alpha);
grVertex2f(x, y);
grVertex2f(x, 0);
grColor4f(1, 1, 1, 0);
grVertex2f(x+SIbullet[a].width, 0);
grColor4f(1, 1, 1, SIbullet[a].alpha);
grVertex2f(x, y);
grColor4f(1, 1, 1, 0);
grVertex2f(x-SIbullet[a].width, y);
grVertex2f(x-SIbullet[a].width, 0);
grColor4f(1, 1, 1, SIbullet[a].alpha);
grVertex2f(x, 0);
grColor4f(1, 1, 1, 0);
grVertex2f(x+SIbullet[a].width, y);
grColor4f(1, 1, 1, SIbullet[a].alpha);
grVertex2f(x, y);
grColor4f(1, 1, 1, 0);
grVertex2f(x, y+SIbullet[a].height);
grVertex2f(x+SIbullet[a].width, y+SIbullet[a].height);
grVertex2f(x, y+SIbullet[a].height);
grColor4f(1, 1, 1, SIbullet[a].alpha);
grVertex2f(x, y);
grColor4f(1, 1, 1, 0);
grVertex2f(x-SIbullet[a].width, y);
grVertex2f(x-SIbullet[a].width, y+SIbullet[a].height);
grEnd();
grEnable(GL_TEXTURE_2D);
break; break;
*/
/* case 3: /* case 3:
x=realtime*50; x=realtime*50;
grColor4f(1, 1, 1, SIbullet[a].alpha); grColor4f(1, 1, 1, SIbullet[a].alpha);
@ -1665,9 +1621,9 @@ void SI_KeyDown(int k)
SIp.contols |= CONT_FIREKEY; SIp.contols |= CONT_FIREKEY;
else if (k == K_MOUSE2) else if (k == K_MOUSE2)
SIp.contols |= CONT_MOUSE; SIp.contols |= CONT_MOUSE;
else if (k == K_F1) else if (k == '1')
SIp.health = 9; SIp.health = 9;
else if (k == K_F2) else if (k == '2')
SIp.cash += 100; SIp.cash += 100;
else if (k == K_ESCAPE) else if (k == K_ESCAPE)
Menu_Control(0); Menu_Control(0);
@ -1726,6 +1682,7 @@ void SI_Initialize(void)
free(SIbaddietexture); free(SIbaddietexture);
free(SIbullettexture); free(SIbullettexture);
SIbullettexture = NULL;
free(SISquad); free(SISquad);
free(SIRoute); free(SIRoute);
@ -1809,8 +1766,15 @@ void SI_Initialize(void)
SIweapons[a].alpha = (float)atof(val); SIweapons[a].alpha = (float)atof(val);
else if (!strcasecmp(s, "alphachange")) else if (!strcasecmp(s, "alphachange"))
SIweapons[a].alphachange = (float)atof(val); SIweapons[a].alphachange = (float)atof(val);
// else if (!strcasecmp(s, "texturenum")) else if (!strcasecmp(s, "texturenum"))
// SIweapons[a].tex = (int)atoi(val)-1; //allow different pictures {
if (!SIbullettexture)
{
SIbullettexture = malloc(sizeof(texture) * weaponlevels);
memset(SIbullettexture, 0, sizeof(texture) * weaponlevels);
}
SIweapons[a].tex = &SIbullettexture[atoi(val)-1]; //allow different pictures
}
else if (!strcasecmp(s, "charge")) else if (!strcasecmp(s, "charge"))
SIweapons[a].charge = atoi(val); //allow different pictures SIweapons[a].charge = atoi(val); //allow different pictures
else if (!strcasecmp(s, "type")) else if (!strcasecmp(s, "type"))
@ -1863,6 +1827,12 @@ void SI_Initialize(void)
} }
} }
if (!SIbullettexture)
{
SIbullettexture = malloc(sizeof(texture) * weaponlevels);
memset(SIbullettexture, 0, sizeof(texture) * weaponlevels);
}
SIEnemyType = malloc(sizeof(SIEnemyType_t) * ENEMYTYPES); SIEnemyType = malloc(sizeof(SIEnemyType_t) * ENEMYTYPES);
memset(SIEnemyType, 0, sizeof(SIEnemyType_t) * ENEMYTYPES); memset(SIEnemyType, 0, sizeof(SIEnemyType_t) * ENEMYTYPES);
SImonster = malloc(sizeof(SImonster_t) * MAXMONSTERS); SImonster = malloc(sizeof(SImonster_t) * MAXMONSTERS);
@ -1872,19 +1842,12 @@ void SI_Initialize(void)
SIbaddietexture = malloc(sizeof(texture) * ENEMYTYPES); SIbaddietexture = malloc(sizeof(texture) * ENEMYTYPES);
memset(SIbaddietexture, 0, sizeof(texture) * ENEMYTYPES); memset(SIbaddietexture, 0, sizeof(texture) * ENEMYTYPES);
SIbullettexture = malloc(sizeof(texture) * weaponlevels);
memset(SIbullettexture, 0, sizeof(texture) * weaponlevels);
SIRoute = malloc((sizeof(SIRoute_t)+(MAXROUTEPOINTS-1)*sizeof(vec3_t)) * MAXROUTES); SIRoute = malloc((sizeof(SIRoute_t)+(MAXROUTEPOINTS-1)*sizeof(vec3_t)) * MAXROUTES);
memset(SIRoute, 0, (sizeof(SIRoute_t)+(MAXROUTEPOINTS-1)*sizeof(vec3_t)) * MAXROUTES); memset(SIRoute, 0, (sizeof(SIRoute_t)+(MAXROUTEPOINTS-1)*sizeof(vec3_t)) * MAXROUTES);
SISquad = malloc(sizeof(SISquad_t) * MAXSQUADS); SISquad = malloc(sizeof(SISquad_t) * MAXSQUADS);
memset(SISquad, 0, sizeof(SISquad_t) * MAXSQUADS); memset(SISquad, 0, sizeof(SISquad_t) * MAXSQUADS);
for (a = 0; a < weaponlevels; a++)
{
SIweapons[a].tex = &SIbullettexture[(int)SIweapons[a].tex];
}
//loaded elsewhere //loaded elsewhere
// SIweapons = mmalloc(sizeof(SIbullet_t) * weaponlevels); // SIweapons = mmalloc(sizeof(SIbullet_t) * weaponlevels);
@ -2342,6 +2305,7 @@ int Plug_Init(int *args)
Cmd_AddCommand("spaceinv"); Cmd_AddCommand("spaceinv");
SI_Initialize(); SI_Initialize();
SI_LoadTextures();
return 1; return 1;
} }