Skip to content

Commit

Permalink
180° Turn only once per button press
Browse files Browse the repository at this point in the history
Introduced state variable to only allow a 180° Turn once per button press (either mouse or keyboard). This improves the useability when binding it to a mouse key.
  • Loading branch information
Noseey committed Nov 21, 2024
1 parent e9906c6 commit ba920ff
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
13 changes: 10 additions & 3 deletions src/doom/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ void G_BuildTiccmd (ticcmd_t* cmd, int maketic)
int look;
player_t *const player = &players[consoleplayer];
static char playermessage[48];
static boolean keyrevstate = false; // [crispy]

// [crispy] For fast polling.
G_PrepTiccmd();
Expand Down Expand Up @@ -506,9 +507,15 @@ void G_BuildTiccmd (ticcmd_t* cmd, int maketic)
// [crispy] add quick 180° reverse
if (gamekeydown[key_reverse] || mousebuttons[mousebreverse])
{
angle += ANG180 >> FRACBITS;
gamekeydown[key_reverse] = false;
mousebuttons[mousebreverse] = false;
if(!keyrevstate)
{
angle += ANG180 >> FRACBITS;
keyrevstate = true;
}
}
else
{
keyrevstate = false;
}

// [crispy] toggle "always run"
Expand Down
13 changes: 10 additions & 3 deletions src/heretic/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic)

static unsigned int mbmlookctrl = 0; // [crispy]
static unsigned int kbdlookctrl = 0; // [crispy]
static boolean keyrevstate = false; // [crispy]

// haleyjd: removed externdriver crap

Expand Down Expand Up @@ -466,9 +467,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic)
// [crispy] add quick 180° reverse
if (gamekeydown[key_reverse] || mousebuttons[mousebreverse])
{
angle += ANG180 >> FRACBITS;
gamekeydown[key_reverse] = false;
mousebuttons[mousebreverse] = false;
if(!keyrevstate)
{
angle += ANG180 >> FRACBITS;
keyrevstate = true;
}
}
else
{
keyrevstate = false;
}

// [crispy] toggle "always run"
Expand Down
13 changes: 10 additions & 3 deletions src/hexen/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic)

static unsigned int mbmlookctrl = 0; // [crispy]
static unsigned int kbdlookctrl = 0; // [crispy]
static boolean keyrevstate = false; // [crispy]

// haleyjd: removed externdriver crap

Expand Down Expand Up @@ -364,9 +365,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic)
// [crispy] add quick 180° reverse
if (gamekeydown[key_reverse] || mousebuttons[mousebreverse])
{
angle += ANG180 >> FRACBITS;
gamekeydown[key_reverse] = false;
mousebuttons[mousebreverse] = false;
if(!keyrevstate)
{
angle += ANG180 >> FRACBITS;
keyrevstate = true;
}
}
else
{
keyrevstate = false;
}

// [crispy] toggle "always run"
Expand Down

0 comments on commit ba920ff

Please sign in to comment.