From 799703b5eb47d156be2a0a8d8f42c052696f70f4 Mon Sep 17 00:00:00 2001 From: driAn Date: Sun, 1 Apr 2007 21:07:04 +0000 Subject: [PATCH] radar git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@875 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientextras.cpp | 8 +- source/src/cube.h | 5 +- source/src/main.cpp | 18 +- source/src/renderextras.cpp | 441 ++++++++++++++++++++++-------------- 4 files changed, 284 insertions(+), 188 deletions(-) diff --git a/source/src/clientextras.cpp b/source/src/clientextras.cpp index c97c7fb0..7f71059b 100644 --- a/source/src/clientextras.cpp +++ b/source/src/clientextras.cpp @@ -48,7 +48,7 @@ void renderplayer(playerent *d) if(!d) return; int team = team_int(d->team); - s_sprintfd(skin)("packages/models/playermodels/%s/0%i.jpg", team==TEAM_CLA ? "terrorist" : "counterterrorist", 1 + max(0, min(d->skin, (team==TEAM_CLA ? 3 : 5)))); + s_sprintfd(skin)("packages/models/playermodels/%s/0%i.jpg", d->team, 1 + max(0, min(d->skin, (team==TEAM_CLA ? 3 : 5)))); string vwep; if(d->gunselect>=0 && d->gunselectgunselect]); else vwep[0] = 0; @@ -58,11 +58,7 @@ void renderplayer(playerent *d) void renderclients() { playerent *d; - loopv(players) if((d = players[i]) && (!demoplayback || i!=democlientnum)) - { - renderplayer(d); - } - + loopv(players) if((d = players[i]) && (!demoplayback || i!=democlientnum)) renderplayer(d); if(player1->state==CS_DEAD) renderplayer(player1); } diff --git a/source/src/cube.h b/source/src/cube.h index 6d208e70..a74bad45 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -123,12 +123,11 @@ extern bool intermission; extern bool arenajoin; extern int maxclients; -#define VIRTW 2400 // virtual screen size for text & HUD +extern int VIRTW; // virtual screen size for text & HUD #define VIRTH 1800 #define FONTH 64 #define PIXELTAB (VIRTW/12) #include "protos.h" // external function decls -#endif - +#endif \ No newline at end of file diff --git a/source/src/main.cpp b/source/src/main.cpp index cbfdf3d6..a61e8f3d 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -39,8 +39,9 @@ void fatal(char *s, char *o) // failure exit int scr_w = 640; int scr_h = 480; +int VIRTW; -void screenshot() +void screenshot(char *imagepath) { SDL_Surface *image; SDL_Surface *temp; @@ -56,8 +57,8 @@ void screenshot() memcpy(dest, (char *)image->pixels+image->pitch*(scr_h-1-idx), 3*scr_w); endianswap(dest, 3, scr_w); } - s_sprintfd(buf)("screenshots/screenshot_%d.bmp", lastmillis); - SDL_SaveBMP(temp, path(buf)); + if(!imagepath) s_sprintf(imagepath)("screenshots/screenshot_%d.bmp", lastmillis); + SDL_SaveBMP(temp, path(imagepath)); SDL_FreeSurface(temp); } SDL_FreeSurface(image); @@ -271,6 +272,7 @@ int main(int argc, char **argv) screen = SDL_SetVideoMode(scr_w, scr_h, bpp, SDL_OPENGL|resize|fs); if(screen==NULL) fatal("Unable to create OpenGL screen"); fullscreen = fs!=0; + VIRTW = scr_w*VIRTH/scr_h; log("video: misc"); SDL_WM_SetCaption("ActionCube", NULL); @@ -285,15 +287,11 @@ int main(int argc, char **argv) gl_init(scr_w, scr_h, bpp, depth, fsaa); crosshair = textureload("packages/misc/crosshairs/default.png"); - if(!crosshair) fatal("could not find core textures (hint: run cube from the parent of the bin directory)"); + if(!crosshair) fatal("could not find core textures (hint: run ActionCube from the parent of the bin directory)"); loadingscreen(); particleinit(); - log("models"); - preload_playermodels(); - preload_hudguns(); - log("sound"); initsound(); @@ -316,6 +314,10 @@ int main(int argc, char **argv) if(!execfile("config/saved.cfg")) exec("config/defaults.cfg"); execfile("config/autoexec.cfg"); + log("models"); + preload_playermodels(); + preload_hudguns(); + execute("start_game"); log("localconnect"); diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index 6d5c5a1b..bad803e7 100644 --- a/source/src/renderextras.cpp +++ b/source/src/renderextras.cpp @@ -30,6 +30,18 @@ void box(block &b, float z1, float z2, float z3, float z4) xtraverts += 4; } +inline void quad(Texture *tex, float x, float y, int s, float tx, float ty, float ts) +{ + if(tex) glBindTexture(GL_TEXTURE_2D, tex->id); + glBegin(GL_QUADS); + glTexCoord2f(tx, ty); glVertex2i(x, y); + glTexCoord2f(tx+ts, ty); glVertex2i(x+s, y); + glTexCoord2f(tx+ts, ty+ts); glVertex2i(x+s, y+s); + glTexCoord2f(tx, ty+ts); glVertex2i(x, y+s); + glEnd(); + xtraverts += 4; +}; + void dot(int x, int y, float z) { const float DOF = 0.1f; @@ -184,27 +196,41 @@ void readdepth(int w, int h, vec &pos) pos.z = (float)worldz; } -void drawicon(float tx, float ty, int x, int y, Texture *tex = NULL, float scaling = 1/3.0f) // EDIT: AH +void drawicon(Texture *tex, float x, float y, float s, int col, int row, float ts) { - if(!tex) + if(tex && tex->xs == tex->ys) quad(tex, x, y, s, ts*col, ts*row, ts); +}; + +void drawequipicon(float x, float y, int col, int row, float blend) +{ + static Texture *tex = NULL; + if(!tex) tex = textureload("packages/misc/items.png"); + if(tex) { - static Texture *itemstex = NULL; - if(!itemstex) itemstex = textureload("packages/misc/items.png"); - tex = itemstex; - } - glBindTexture(GL_TEXTURE_2D, tex->id); - glBegin(GL_QUADS); - tx /= 192; - ty /= 192; - float o = scaling; - int s = 120; - glTexCoord2f(tx, ty); glVertex2i(x, y); - glTexCoord2f(tx+o, ty); glVertex2i(x+s, y); - glTexCoord2f(tx+o, ty+o); glVertex2i(x+s, y+s); - glTexCoord2f(tx, ty+o); glVertex2i(x, y+s); - glEnd(); - xtraverts += 4; -} + if(blend) glEnable(GL_BLEND); + drawicon(tex, x, y, 120, col, row, 1/3.0f); + if(blend) glDisable(GL_BLEND); + }; +}; + +void drawradaricon(float x, float y, int s, int col, int row, bool blend) +{ + static Texture *tex = NULL; + if(!tex) tex = textureload("packages/misc/radaricons.png"); + if(tex) + { + if(blend) glEnable(GL_BLEND); + drawicon(tex, x, y, s, col, row, 1/4.0f); + if(blend) glDisable(GL_BLEND); + }; +}; + +void drawctficon(float x, float y, int s, int col, int row, float ts) +{ + static Texture *tex = NULL; + if(!tex) tex = textureload("packages/misc/teamicons.png"); + if(tex) drawicon(tex, x, y, s, col, row, ts); +}; void invertperspective() { @@ -228,6 +254,149 @@ void damageblend(int n) { dblend += n; } VARP(hidestats, 0, 1, 1); VARP(crosshairfx, 0, 1, 1); +VARP(hideradar, 0, 0, 1); +VARP(radarres, 1, 64, 1024); +VARP(radarentsize, 1, 4, 64); +VARP(hidectfhud, 0, 0, 1); +VARP(hideteamhud, 0, 0, 1); + +bool showmap = false; +void toggleshowmap() { showmap = !showmap; } +COMMAND(toggleshowmap, ARG_NONE); + +void drawscope() +{ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.9f); + static Texture *scopetex = NULL; + if(!scopetex) scopetex = textureload("packages/misc/scope.png"); + glBindTexture(GL_TEXTURE_2D, scopetex->id); + glBegin(GL_QUADS); + glColor3ub(255,255,255); + + glTexCoord2i(0, 0); glVertex2i(0, 0); + glTexCoord2i(1, 0); glVertex2i(VIRTW, 0); + glTexCoord2i(1, 1); glVertex2i(VIRTW, VIRTH); + glTexCoord2i(0, 1); glVertex2i(0, VIRTH); + + glEnd(); + glDisable(GL_ALPHA_TEST); +}; + +void drawcrosshair(bool showteamwarning) +{ + glBlendFunc(GL_ONE, GL_ONE); + static Texture *teammatetex = NULL; + if(!teammatetex) teammatetex = textureload("packages/misc/teammate.png"); + glBindTexture(GL_TEXTURE_2D, showteamwarning ? teammatetex->id : crosshair->id); + glBegin(GL_QUADS); + glColor3ub(255,255,255); + if(crosshairfx) + { + if(showteamwarning) glColor3ub(255, 0, 0); + else if(player1->gunwait) glColor3ub(128,128,128); + else if(!m_osok) + { + if(player1->health<=25) glColor3ub(255,0,0); + else if(player1->health<=50) glColor3ub(255,128,0); + }; + }; + float chsize = (float)crosshairsize * (player1->gunselect==GUN_ASSAULT && player1->shots > 3 ? 1.4f : 1.0f) * (showteamwarning ? 2.0f : 1.0f); + glTexCoord2i(0, 0); glVertex2f(VIRTW/2 - chsize, VIRTH/2 - chsize); + glTexCoord2i(1, 0); glVertex2f(VIRTW/2 + chsize, VIRTH/2 - chsize); + glTexCoord2i(1, 1); glVertex2f(VIRTW/2 + chsize, VIRTH/2 + chsize); + glTexCoord2i(0, 1); glVertex2f(VIRTW/2 - chsize, VIRTH/2 + chsize); + glEnd(); +}; + +void drawequipicons() +{ + glDisable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4f(1.0f, 1.0f, 1.0f, 0.2f+(sinf(lastmillis/100.0f)+1.0f)/2.0f); + + // health & armor + if(player1->armour) drawequipicon(620, 1650, 2, 0, false); + drawequipicon(20, 1650, 1, 0, (player1->health <= 20 && !m_osok)); + + // weapons + int c = player1->gunselect, r = 1; + if(c>2) { c -= 3; r = 2; } + if(c==GUN_GRENADE) c = r = 0; + + drawequipicon(1220, 1650, c, r, (!player1->mag[player1->gunselect] && player1->gunselect != GUN_KNIFE && player1->gunselect != GUN_GRENADE)); + glEnable(GL_BLEND); +}; + +void drawradarent(float x, float y, float yaw, int col, int row, float iconsize, bool blend) +{ + glPushMatrix(); + glTranslatef(x, y, 0); + glRotatef(yaw, 0, 0, 1); + drawradaricon(-iconsize/2.0f, -iconsize/2.0f, iconsize, col, row, blend); + glPopMatrix(); +}; + +void drawradar(vec ¢er, int radarres, int w, int h, bool fullscreen) +{ + static Texture *radar = NULL; + static char *map = NULL; + + char *curmap = getclientmap(); + + if(!map || strcmp(map, curmap)) // update once on map load + { + map = curmap; + s_sprintfd(texpath)("packages/%s.jpg", map); + radar = textureload(texpath); + }; + + if(radar) + { + glPushMatrix(); + glDisable(GL_BLEND); + glOrtho(0, VIRTW, VIRTH, 0, -1, 1); + + const float worldsize = (float)ssize; + const float radarviewsize = fullscreen ? VIRTH : VIRTH/6; + const float radarsize = worldsize/radarres*radarviewsize; + + if(fullscreen) glTranslatef(VIRTW/2-radarviewsize/2, 0, 0); + else glTranslatef(VIRTW-radarviewsize-10, 10, 0); + + vec centerpos(min(max(center.x, radarres/2), worldsize-radarres/2), min(max(center.y, radarres/2), worldsize-radarres/2), 0); + quad(radar, 0, 0, radarviewsize, (centerpos.x-radarres/2)/worldsize, (centerpos.y-radarres/2)/worldsize, radarres/worldsize); + glTranslatef(-(centerpos.x-radarres/2)/worldsize*radarsize, -(centerpos.y-radarres/2)/worldsize*radarsize, 0); + + const float iconsize = radarentsize/(float)radarres*radarviewsize; + const float coordtrans = radarsize/worldsize; + + drawradarent(player1->o.x*coordtrans, player1->o.y*coordtrans, player1->yaw, player1->state==CS_ALIVE ? (player1->attacking ? 2 : 0) : 1, 2, iconsize, false); // local player + loopv(players) // other players + { + playerent *pl = players[i]; + if(!pl || !isteam(player1->team, pl->team) || (centerpos.z=pl->o.z && centerpos.reject(pl->o, radarres/2))) continue; + drawradarent(pl->o.x*coordtrans, pl->o.y*coordtrans, pl->yaw, pl->state==CS_ALIVE ? (pl->attacking ? 2 : 0) : 1, team_int(pl->team), iconsize, false); + }; + if(m_ctf) + { + glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); + loopi(2) // flag items + { + flaginfo &f = flaginfos[i]; + entity *e = f.flag; + if(!e) continue; + if(f.state==CTFF_STOLEN && f.actor && (centerpos.z=f.actor->o.z && !centerpos.reject(f.actor->o, radarres/2))) + drawradarent(f.actor->o.x*coordtrans+iconsize/2, f.actor->o.y*coordtrans+iconsize/2, 0, 3, f.team, iconsize, true); // draw near flag thief + else if(!vec(e->x, e->y, centerpos.z).reject(centerpos, radarres/2)) drawradarent(e->x*coordtrans, e->y*coordtrans, 0, 3, f.team, iconsize, false); // draw on entitiy pos + }; + }; + + glEnable(GL_BLEND); + glPopMatrix(); + }; +}; void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater) { @@ -242,7 +411,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glDisable(GL_DEPTH_TEST); invertperspective(); - glPushMatrix(); + + glPushMatrix(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); glEnable(GL_BLEND); @@ -265,80 +435,43 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glEnable(GL_TEXTURE_2D); - playerent *player = playerincrosshair(); - bool didteamkill = player1->lastteamkill && player1->lastteamkill + 5000 > lastmillis; + playerent *targetplayer = playerincrosshair(); + bool didteamkill = player1->lastteamkill && player1->lastteamkill + 5000 > lastmillis; + bool menuvisible = rendermenu(); - if(!rendermenu()) + if(player1->state==CS_ALIVE && !player1->reloading && !didteamkill && !menuvisible) { - bool teammate_in_xhair = player ? (isteam(player->team, player1->team) && player->state!=CS_DEAD) : false; - if(scoped && player1->gunselect == GUN_SNIPER) - { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.9f); - static Texture *scopetex = NULL; - if(!scopetex) scopetex = textureload("packages/misc/scope.png"); - glBindTexture(GL_TEXTURE_2D, scopetex->id); - glBegin(GL_QUADS); - glColor3ub(255,255,255); - - glTexCoord2i(0, 0); glVertex2i(0, 0); - glTexCoord2i(1, 0); glVertex2i(VIRTW, 0); - glTexCoord2i(1, 1); glVertex2i(VIRTW, VIRTH); - glTexCoord2i(0, 1); glVertex2i(0, VIRTH); - - glEnd(); - glDisable(GL_ALPHA_TEST); - } - else if((player1->gunselect != GUN_SNIPER || teammate_in_xhair) && !player1->reloading && !player1->state==CS_DEAD && !didteamkill) - { - glBlendFunc(GL_ONE, GL_ONE); - static Texture *teammatetex = NULL; - if(!teammatetex) teammatetex = textureload("packages/misc/teammate.png"); - glBindTexture(GL_TEXTURE_2D, teammate_in_xhair ? teammatetex->id : crosshair->id); - glBegin(GL_QUADS); - glColor3ub(255,255,255); - if(crosshairfx) - { - if(teammate_in_xhair) glColor3ub(255, 0, 0); - else if(player1->gunwait) glColor3ub(128,128,128); - else if(!m_osok) - { - if(player1->health<=25) glColor3ub(255,0,0); - else if(player1->health<=50) glColor3ub(255,128,0); - } - } - float chsize = (float)crosshairsize * (player1->gunselect==GUN_ASSAULT && player1->shots > 3 ? 1.4f : 1.0f) * (teammate_in_xhair ? 2.0f : 1.0f); - glTexCoord2i(0, 0); glVertex2f(VIRTW/2 - chsize, VIRTH/2 - chsize); - glTexCoord2i(1, 0); glVertex2f(VIRTW/2 + chsize, VIRTH/2 - chsize); - glTexCoord2i(1, 1); glVertex2f(VIRTW/2 + chsize, VIRTH/2 + chsize); - glTexCoord2i(0, 1); glVertex2f(VIRTW/2 - chsize, VIRTH/2 + chsize); - glEnd(); - } - } + bool drawteamwarning = targetplayer ? (isteam(targetplayer->team, player1->team) && targetplayer->state!=CS_DEAD) : false; + if(player1->gunselect==GUN_SNIPER && scoped) drawscope(); + else if((player1->gunselect!=GUN_SNIPER || drawteamwarning)) drawcrosshair(drawteamwarning); + }; + + drawequipicons(); if(getcurcommand()) rendercommand(20, 1570); else if(closeent[0]) draw_text(closeent, 20, 1570); - else if(player) draw_text(player->name, 20, 1570); + else if(targetplayer) draw_text(targetplayer->name, 20, 1570); glPopMatrix(); - glPushMatrix(); - glOrtho(0, VIRTW*4/3, VIRTH*4/3, 0, -1, 1); - renderconsole(); + if(!hideradar) + { + if(showmap) drawradar(vec(ssize/2, ssize/2, 0), ssize, w, h, true); + else drawradar(player1->o, radarres, w, h, false); + }; + glPushMatrix(); + glOrtho(0, VIRTW*2, VIRTH*2, 0, -1, 1); + renderconsole(); if(!hidestats) { - glPopMatrix(); - glPushMatrix(); - glOrtho(0, VIRTW*3/2, VIRTH*3/2, 0, -1, 1); - draw_textf("fps %d", 3200, 2320, curfps); - draw_textf("lod %d", 3200, 2390, lod_factor()); - draw_textf("wqd %d", 3200, 2460, nquads); - draw_textf("wvt %d", 3200, 2530, curvert); - draw_textf("evt %d", 3200, 2600, xtraverts); - } - + const int left = (VIRTW-225-10)*2, top = (VIRTH*7/8)*2; + draw_textf("fps %d", left, top, curfps); + draw_textf("lod %d", left, top+80, lod_factor()); + draw_textf("wqd %d", left, top+160, nquads); + draw_textf("wvt %d", left, top+240, curvert); + draw_textf("evt %d", left, top+320, xtraverts); + }; glPopMatrix(); if(player1->state==CS_ALIVE) @@ -356,6 +489,17 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat } glPopMatrix(); + if(m_teammode && !hideteamhud) + { + glPushMatrix(); + glOrtho(0, VIRTW, VIRTH, 0, -1, 1); + glDisable(GL_BLEND); + drawctficon(VIRTW-120-10, VIRTH/6+10+10, 120, team_int(player1->team), 1, 1/4.0f); // local players team + glEnable(GL_BLEND); + draw_textf(player1->team, VIRTW-VIRTH/6-10, VIRTH/6+10+10+120/2); + glPopMatrix(); + }; + if(didteamkill) { glPushMatrix(); @@ -364,68 +508,30 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glPopMatrix(); } - #define ctf_scl 0.75 - if(m_ctf) + if(m_ctf && !hidectfhud) { glPushMatrix(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glColor4f(1.0f, 1.0f, 1.0f, 0.2f); - if(flaginfos[TEAM_CLA].state == CTFF_INBASE) glDisable(GL_BLEND); else glEnable(GL_BLEND); - static Texture *flagtex = NULL; - if(!flagtex) flagtex = textureload("packages/misc/flag_icons.png"); - drawicon(64*ctf_scl, 0, 1940, 1650, flagtex, 1.0f/4.0f); - if(flaginfos[TEAM_RVSF].state == CTFF_INBASE) glDisable(GL_BLEND); else glEnable(GL_BLEND); - drawicon(0, 0, 1820, 1650, flagtex, 1.0f/4.0f); - glDisable(GL_BLEND); - drawicon((float)(team_int(player1->team)*64*ctf_scl), (float)(64*ctf_scl), VIRTW-128-10, 10, flagtex, 1.0/4.0); // shows which team you are - glPopMatrix(); - - // big flag icon - flaginfo &f = flaginfos[team_opposite(team_int(player1->team))]; - if(f.state==CTFF_STOLEN && f.actor == player1 && f.ack) - { - glPushMatrix(); - glOrtho(0, VIRTW/2, VIRTH/2, 0, -1, 1); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); - glEnable(GL_BLEND); - drawicon((float)(team_opposite(team_int(player1->team))*128*ctf_scl),(float)(128*ctf_scl), 1065, VIRTH/2/3*2, flagtex, 1.0/2.0); - glPopMatrix(); - } - } - glPushMatrix(); - glOrtho(0, VIRTW, VIRTH, 0, -1, 1); - glDisable(GL_BLEND); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(1.0f, 1.0f, 1.0f, 0.2f+(sinf(lastmillis/100.0f)+1.0f)/2.0f); - - if(player1->health <= 20 && !m_osok) - { - glEnable(GL_BLEND); - drawicon(64, 0, 20, 1650); - glDisable(GL_BLEND); + loopi(2) // flag state + { + if(flaginfos[i].state == CTFF_INBASE) glDisable(GL_BLEND); else glEnable(GL_BLEND); + drawctficon(i*120+VIRTW/4.0f*3.0f, 1650, 120, i, 0, 1/4.0f); + }; + + // big flag-stolen icon + flaginfo &f = flaginfos[team_opposite(team_int(player1->team))]; + if(f.state==CTFF_STOLEN && f.actor == player1 && f.ack) + { + glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis/100.0f)+1.0f) / 2.0f); + glEnable(GL_BLEND); + drawctficon(VIRTW-225-10, VIRTH*5/8, 225, team_opposite(team_int(player1->team)), 1, 1/2.0f); + glDisable(GL_BLEND); + } + glPopMatrix(); } - else drawicon(64, 0, 20, 1650); - if(player1->armour) drawicon((float)(128), 0, 620, 1650); - int g = player1->gunselect; - int r = 64; - if(g>2) { g -= 3; r = 128; } - - if(!player1->mag[player1->gunselect] && player1->gunselect != GUN_KNIFE && player1->gunselect != GUN_GRENADE) - { - glEnable(GL_BLEND); - drawicon((float)(g*64), (float)r, 1220, 1650); - glDisable(GL_BLEND); - } - else - { - if (player1->gunselect==GUN_GRENADE) drawicon(0, 0, 1220, 1650); - else drawicon((float)(g*64), (float)r, 1220, 1650); - } - glPopMatrix(); } glDisable(GL_BLEND); @@ -498,42 +604,35 @@ void addgib(playerent *d) p->vel.x = sinf(RAD*angle)*rnd(1000)/1000.0f; p->vel.y = cosf(RAD*angle)*rnd(1000)/1000.0f; p->vel.z = rnd(1000)/1000.0f; - p->vel.mul(gibspeed/100.0f); + p->vel.mul(speed/100.0f); } } -// fixme -void gibtest() { playerent t = *player1; t.o.x = worldpos.x; t.o.y = worldpos.y; addgib(&t); } -COMMAND(gibtest, ARG_NONE); - void loadingscreen() { static Texture *logo = NULL; - if(!logo) logo = textureload("packages/misc/full_logo.png", false); - - glPushMatrix(); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glOrtho(0, VIRTW, VIRTH, 0, -1, 1); - - glDisable(GL_DEPTH_TEST); - glEnable(GL_TEXTURE_2D); - - glColor3f(1, 1, 1); - glBindTexture(GL_TEXTURE_2D, logo->id); - - loopi(2) - { - glBegin(GL_QUADS); - glTexCoord2i(0, 0); glVertex2i(0, 0); - glTexCoord2i(1, 0); glVertex2i(VIRTW, 0); - glTexCoord2i(1, 1); glVertex2i(VIRTW, VIRTH); - glTexCoord2i(0, 1); glVertex2i(0, VIRTH); - glEnd(); - - SDL_GL_SwapBuffers(); - } - - glDisable(GL_TEXTURE_2D); - glPopMatrix(); + if(!logo) logo = textureload("packages/misc/startscreen.png", false); + if(logo) + { + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + glClearColor(0, 0, 0, 1); + loopi(2) + { + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glClear(GL_COLOR_BUFFER_BIT); + glOrtho(0, VIRTW, VIRTH, 0, -1, 1); + quad(logo, (VIRTW-VIRTH)/2, 0, VIRTH, 0, 0, 1); + SDL_GL_SwapBuffers(); + } + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + } } -