From: xolatile Date: Thu, 24 Jul 2025 23:47:52 +0000 (+0200) Subject: Speedometer game script variables... X-Git-Url: https://git.xolatile.top/?a=commitdiff_plain;h=4565d089bc3d9a3b7c6ff6c641acffdd61676bca;p=xolatile-badassbug.git Speedometer game script variables... --- diff --git a/src/fpsgame/fps.cpp b/src/fpsgame/fps.cpp index 038fe47..885bb3a 100644 --- a/src/fpsgame/fps.cpp +++ b/src/fpsgame/fps.cpp @@ -872,16 +872,50 @@ namespace game pophudmatrix(); } + VARP(speedometer, 0, 1, 1); + FVARP(speedometerx, 0.0, 0.5, 1.0); + FVARP(speedometery, 0.0, 0.6, 1.0); + FVARP(speedometerscale, 0.1, 0.5, 2.0); + VARP(speedometercolor, 0, 1, 1); + FVARP(speedometeralpha, 0.0, 0.5, 1.0); + + //~void drawspeedometer(fpsent *d, int w, int h) { + //~int speedforreal = (int) (sqrtf(d->vel.squaredlen()) + 1.0f); + //~speedforreal = (speedforreal == 1) ? 0 : speedforreal; + //~vec colour = vec(255, 255, 255); + //~float realw = 0; + //~float realh = 0; + //~if (speedometercolor) { + //~if (speedforreal==0) colour = vec(60, 60, 60); + //~else if (speedforreal>0 && speedforreal<=60) colour = vec(240, 30, 30); + //~else if (speedforreal>60 && speedforreal<=120) colour = vec(180, 90, 60); + //~else if (speedforreal>120 && speedforreal<=180) colour = vec(180, 180, 30); + //~else if (speedforreal>180 && speedforreal<=240) colour = vec(90, 180, 60); + //~else colour = vec(30, 240, 30); + //~} + + //~defformatstring(speedstring, "%d", speedforreal); + //~text_boundsf(speedstring, realw, realh); + //~vec2 offset = vec2(speedometerx, speedometery).mul(vec2(w, h).div(speedometerscale)); + //~offset.x -= realw/2.0f; + //~offset.y -= realh/2.0f; + + //~pushhudmatrix(); + //~hudmatrix.scale(speedometerscale, speedometerscale, 1); + //~flushhudmatrix(); + + //~draw_text(speedstring, int(offset.x), int(offset.y), colour.x, colour.y, colour.z, speedometeralpha); + + //~pophudmatrix(); + //~} + VARP(healthcolors, 0, 1, 1); void drawhudicons(fpsent *d) { - int speedforreal = (int) (sqrtf(d->vel.squaredlen()) + /*speedmodifier*/ + 1.0f); - pushhudmatrix(); hudmatrix.scale(2, 2, 1); flushhudmatrix(); - defformatstring(health, "%d", d->state==CS_DEAD ? 0 : d->health); bvec healthcolor = bvec::hexcolor(healthcolors && !m_insta ? (d->state==CS_DEAD ? 0x808080 : (d->health<=25 ? 0xFF0000 : (d->health<=50 ? 0xFF8000 : (d->health<=100 ? 0xFFFFFF : 0x40C0FF)))) : 0xFFFFFF); draw_text(health, (HICON_X + HICON_SIZE + HICON_SPACE)/2, HICON_TEXTY/2, healthcolor.r, healthcolor.g, healthcolor.b); @@ -889,10 +923,7 @@ namespace game { if(d->armour) draw_textf("%d", (HICON_X + HICON_STEP + HICON_SIZE + HICON_SPACE)/2, HICON_TEXTY/2, d->armour); draw_textf("%d", (HICON_X + 2*HICON_STEP + HICON_SIZE + HICON_SPACE)/2, HICON_TEXTY/2, d->ammo[d->gunselect]); - //~draw_textf("%d", (HICON_X + 2*HICON_STEP + HICON_SIZE + HICON_SPACE)/2+800, HICON_TEXTY/2, (int) (100.0f+speedmodifier)); - draw_textf("%d", (HICON_X + 2*HICON_STEP + HICON_SIZE + HICON_SPACE)/2+400, HICON_TEXTY/2, speedforreal); } - pophudmatrix(); if(d->state != CS_DEAD && d->maxhealth > 100) @@ -1074,15 +1105,47 @@ namespace game if(ammobar) drawammobar(w, h, d); } + if(!m_edit) { - if(gameclock) drawgameclock(w, h); - if(hudscore) drawhudscore(w, h); + if(gameclock) drawgameclock(w, h); + if(hudscore) drawhudscore(w, h); + //~if(speedometer) drawspeedometer(d, w, h); + } + + /// Speedometer. + + int speedforreal = (int) (sqrtf(d->vel.squaredlen()) + 1.0f); + speedforreal = (speedforreal == 1) ? 0 : speedforreal; + vec colour = vec(255, 255, 255); + float realw = 0; + float realh = 0; + if (speedometercolor) { + if (speedforreal==0) colour = vec(60, 60, 60); + else if (speedforreal>0 && speedforreal<=60) colour = vec(240, 30, 30); + else if (speedforreal>60 && speedforreal<=120) colour = vec(180, 90, 60); + else if (speedforreal>120 && speedforreal<=180) colour = vec(180, 180, 30); + else if (speedforreal>180 && speedforreal<=240) colour = vec(90, 180, 60); + else colour = vec(30, 240, 30); } + defformatstring(speedstring, "%d", speedforreal); + text_boundsf(speedstring, realw, realh); + vec2 offset = vec2(speedometerx, speedometery).mul(vec2(w, h).div(speedometerscale)); + offset.x -= realw/2.0f; + offset.y -= realh/2.0f; + + pushhudmatrix(); + hudmatrix.scale(speedometerscale, speedometerscale, 1); + flushhudmatrix(); + + draw_text(speedstring, int(offset.x), int(offset.y), colour.x, colour.y, colour.z, (int)(speedometeralpha*255.0f)); + + pophudmatrix(); + /// Frag message. - if(hudfragmillis+fragmessageduration > lastmillis) + if((hudfragmillis+fragmessageduration > lastmillis) && (lastmillis>fragmessageduration)) { vec2 center = vec2(0.5*w, 0.2*h); float width = 0, height = 0; diff --git a/src/fpsgame/game.h b/src/fpsgame/game.h index 9427864..ad102f1 100644 --- a/src/fpsgame/game.h +++ b/src/fpsgame/game.h @@ -430,6 +430,8 @@ struct fpsstate } }; +extern int screenw, screenh; + struct fpsent : dynent, fpsstate { int weight; // affects the effectiveness of hitpush