Skip to content

Commit

Permalink
More tweaks to the beginner's help screen.
Browse files Browse the repository at this point in the history
First of all, we should only ever show help on the first level.

Secondly, make the help screen appear less often in novice mode. It's not
necessary to keep showing it after the player has demonstrated that they know
the controls.  We identify this by tracking how long the player manages to keep
the plane in the air; if they manage to successfully fly it for at least 8
seconds without crashing, that's considered a successful flight and we won't
show help again.

Third, show the help screen as a hint in the other single player modes as well:
but only if they appear to be really struggling to get the plane off the
ground. We identify this if they crash the plane three times without managing a
single successful flight. This seems like a reasonably conservative metric that
shouldn't annoy experienced players by putting a bunch of text on the screen
that they won't care about.

To support the latter, also move the help text onto the left hand side of the
screen. This is because the right side is the side from which the enemy plane
will flying from to attack the player in "vs. computer" mode. We don't want the
text to obscure this.
  • Loading branch information
fragglet committed May 16, 2023
1 parent 7b25957 commit 5c72726
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/sw.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

/* Constants */

#define FPS 10 /* How fast the game runs */

#define MAX_Y 200 /* Maximum Y coordinate */
#define MIN_SPEED 4 /* Minimum plane speed */
#define MAX_SPEED 8 /* Maximum plane speed */
Expand Down
26 changes: 23 additions & 3 deletions src/swgrpha.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "swgrpha.h"
#include "swinit.h"
#include "swmain.h"
#include "swmove.h"
#include "swsplat.h"
#include "swstbar.h"
#include "swtext.h"
Expand Down Expand Up @@ -72,15 +73,31 @@ static void print_help(void)
{ "Fly Home", KEY_HOME },
};

// We usually only show the help text in novice mode. However, in
// other single player modes, we do show the help text if the
// player seems to be really struggling.
switch (playmode) {
case PLAYMODE_NOVICE:
break;
case PLAYMODE_SINGLE:
case PLAYMODE_COMPUTER:
if (consoleplayer->ob_crashcnt < 3) {
return;
}
break;
default:
return;
}

swcolor(2);
swposcur(20, 1);
swposcur(1, 2);
swputs("BEGINNER'S HELP");
swcolor(3);
for (i = 0; i < arrlen(items); i++) {
char buf[64];
snprintf(buf, sizeof(buf), "%-11s- %s",
items[i].name, Vid_KeyName(keybindings[items[i].key]));
swposcur(20, i + 2);
swposcur(1, i + 3);
swputs(buf);
}
}
Expand All @@ -102,7 +119,10 @@ void swdisp(void)
// "the end"
dispendmessage();

if (consoleplayer->ob_athome && playmode == PLAYMODE_NOVICE) {
// Display help text if the player is just starting off. We only
// show this on the first level, and stop showing it once the
// player demonstrates the ability to take off successfully.
if (consoleplayer->ob_athome && !successful_flight && gamenum == 0) {
print_help();
}

Expand Down
4 changes: 3 additions & 1 deletion src/swinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,11 @@ void swinitlevel(void)
// to keep netgames in sync if we have already played

countmove = 0;
successful_flight = false;

for (i=0; i<num_players; ++i)
for (i=0; i<num_players; ++i) {
latest_player_time[i] = 0;
}
}

void swrestart(void)
Expand Down
4 changes: 0 additions & 4 deletions src/swmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
#include "swsound.h"
#include "swtitle.h"

// sdh: framerate control

#define FPS 10

// sdh 28/10/2001: game options

bool conf_missiles = 0; // allow missiles: replaces missok
Expand Down
11 changes: 11 additions & 0 deletions src/swmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@
#include "swsymbol.h"
#include "swtitle.h"

// If the player manages to keep the plane in the air this long, they
// have got the hang of the controls and don't need any more help.
#define SUCCESSFUL_FLIGHT_TIME (8 /* seconds */ * FPS)

static bool movepln(OBJECTS *ob);
static void interpret(OBJECTS *ob, int key);

static bool quit;
static int last_ground_time = 0;
bool successful_flight = false;

void swmove(void)
{
Expand All @@ -55,6 +61,11 @@ void swmove(void)
}

++countmove;
if (consoleplayer->ob_athome) {
last_ground_time = countmove;
} else if (countmove - last_ground_time > SUCCESSFUL_FLIGHT_TIME) {
successful_flight = true;
}
}


Expand Down
2 changes: 2 additions & 0 deletions src/swmove.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include "sw.h"

extern bool successful_flight;

extern void swmove(void);
extern bool moveplyr(OBJECTS *obp);
extern bool movecomp(OBJECTS *obp);
Expand Down

0 comments on commit 5c72726

Please sign in to comment.