mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-27 10:22:32 +00:00
Improve analog handling and input display
This commit is contained in:
parent
64dd306138
commit
0052d15fc8
6 changed files with 31 additions and 4 deletions
|
|
@ -982,6 +982,8 @@ struct player_t
|
|||
INT16 incontrol; // -1 to -175 when spinning out or tumbling, 1 to 175 when not. Use to check for combo hits or emergency inputs.
|
||||
UINT16 progressivethrust; // When getting beat up in GTR_BUMPERS, speed up the longer you've been out of control.
|
||||
|
||||
boolean analoginput; // Has an input been recorded that requires analog usage? For input display.
|
||||
|
||||
boolean markedfordeath;
|
||||
boolean dotrickfx;
|
||||
UINT8 bumperinflate;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ const char* dpad_suffix(const Vec2<float>& v)
|
|||
void K_DrawInputDisplay(INT32 x, INT32 y, INT32 flags, char mode, UINT8 pid, boolean local, boolean transparent)
|
||||
{
|
||||
const ticcmd_t& cmd = players[displayplayers[pid]].cmd;
|
||||
const boolean analog = (mode == '4' || mode == '5') ? players[displayplayers[pid]].analoginput : false;
|
||||
const std::string prefix = fmt::format("PR{}", mode);
|
||||
auto gfx = [&](auto format, auto&&... args) { return prefix + fmt::format(format, args...); };
|
||||
auto but = [&](char key, INT32 gc, UINT32 bt)
|
||||
|
|
@ -81,10 +82,10 @@ void K_DrawInputDisplay(INT32 x, INT32 y, INT32 flags, char mode, UINT8 pid, boo
|
|||
} :
|
||||
Vec2<float> {
|
||||
-cmd.turning / (float)KART_FULLTURN,
|
||||
(float)cmd.throwdir,
|
||||
-cmd.throwdir / (float)KART_FULLTURN,
|
||||
};
|
||||
|
||||
box.patch(gfx("PAD{}", dpad_suffix(dpad)));
|
||||
box.patch(gfx("PAD{}", analog ? "N" : dpad_suffix(dpad)));
|
||||
box.patch(but('A', gc_a, BT_ACCELERATE));
|
||||
box.patch(but('B', gc_b, BT_LOOKBACK));
|
||||
box.patch(but('C', gc_c, BT_SPINDASHMASK));
|
||||
|
|
@ -99,6 +100,9 @@ void K_DrawInputDisplay(INT32 x, INT32 y, INT32 flags, char mode, UINT8 pid, boo
|
|||
{
|
||||
float dist = (mode == '4') ? 3.f : 2.f;
|
||||
|
||||
if (!analog)
|
||||
dist = 0;
|
||||
|
||||
box.patch(gfx("JOY1"));
|
||||
box.xy(dpad.x * dist, -dpad.y * dist).patch(gfx("JOY2"));
|
||||
}
|
||||
|
|
|
|||
15
src/k_kart.c
15
src/k_kart.c
|
|
@ -8868,6 +8868,19 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
|
|||
player->defenseLockout--;
|
||||
}
|
||||
|
||||
UINT16 normalturn = abs(cmd->turning);
|
||||
UINT16 normalaim = abs(cmd->throwdir);
|
||||
|
||||
if (normalturn != 0 || normalaim != 0)
|
||||
{
|
||||
if (normalturn != KART_FULLTURN && normalturn != KART_FULLTURN/2 && normalturn != 0)
|
||||
player->analoginput = true;
|
||||
if (normalaim != KART_FULLTURN && normalaim != KART_FULLTURN/2 && normalaim != 0)
|
||||
player->analoginput = true;
|
||||
if (normalturn == KART_FULLTURN/2 && normalaim == KART_FULLTURN)
|
||||
player->analoginput = false;
|
||||
}
|
||||
|
||||
if (player->dotrickfx && !player->mo->hitlag)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -12803,7 +12816,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
|
|||
INT16 aimingcompare = abs(cmd->throwdir) - abs(cmd->turning);
|
||||
|
||||
// Uses cmd->turning over steering intentionally.
|
||||
#define TRICKTHRESHOLD (KART_FULLTURN/4)
|
||||
#define TRICKTHRESHOLD (KART_FULLTURN/2)
|
||||
if (aimingcompare < -TRICKTHRESHOLD) // side trick
|
||||
{
|
||||
S_StartSoundAtVolume(player->mo, sfx_trick0, 255/2);
|
||||
|
|
|
|||
|
|
@ -255,6 +255,8 @@ static int player_get(lua_State *L)
|
|||
lua_pushinteger(L, plr->justDI);
|
||||
else if (fastcmp(field,"flipDI"))
|
||||
lua_pushboolean(L, plr->flipDI);
|
||||
else if (fastcmp(field,"analoginput"))
|
||||
lua_pushboolean(L, plr->analoginput);
|
||||
else if (fastcmp(field,"markedfordeath"))
|
||||
lua_pushboolean(L, plr->markedfordeath);
|
||||
else if (fastcmp(field,"incontrol"))
|
||||
|
|
@ -793,6 +795,8 @@ static int player_set(lua_State *L)
|
|||
plr->incontrol = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"progressivethrust"))
|
||||
plr->progressivethrust = luaL_checkboolean(L, 3);
|
||||
else if (fastcmp(field,"analoginput"))
|
||||
plr->markedfordeath = luaL_checkboolean(L, 3);
|
||||
else if (fastcmp(field,"markedfordeath"))
|
||||
plr->markedfordeath = luaL_checkboolean(L, 3);
|
||||
else if (fastcmp(field,"dotrickfx"))
|
||||
|
|
|
|||
|
|
@ -594,6 +594,8 @@ static void P_NetArchivePlayers(savebuffer_t *save)
|
|||
WRITEINT16(save->p, players[i].incontrol);
|
||||
WRITEUINT16(save->p, players[i].progressivethrust);
|
||||
|
||||
WRITEUINT8(save->p, players[i].analoginput);
|
||||
|
||||
WRITEUINT8(save->p, players[i].markedfordeath);
|
||||
WRITEUINT8(save->p, players[i].dotrickfx);
|
||||
WRITEUINT8(save->p, players[i].bumperinflate);
|
||||
|
|
@ -1173,6 +1175,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
|
|||
players[i].incontrol = READINT16(save->p);
|
||||
players[i].progressivethrust = READUINT16(save->p);
|
||||
|
||||
players[i].analoginput = READUINT8(save->p);
|
||||
|
||||
players[i].markedfordeath = READUINT8(save->p);
|
||||
players[i].dotrickfx = READUINT8(save->p);
|
||||
players[i].bumperinflate = READUINT8(save->p);
|
||||
|
|
|
|||
|
|
@ -4075,7 +4075,7 @@ void P_PlayerThink(player_t *player)
|
|||
// Save the dir the player is holding
|
||||
// to allow items to be thrown forward or backward.
|
||||
{
|
||||
const INT16 threshold = 0; //(KART_FULLTURN / 2);
|
||||
const INT16 threshold = 6*KART_FULLTURN/10;
|
||||
if (cmd->throwdir > threshold)
|
||||
{
|
||||
player->throwdir = 1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue