Skip to content

Commit

Permalink
Add help screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyp committed Jan 28, 2009
1 parent a5bbd27 commit ec3d4d8
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -3,6 +3,7 @@
Warning free build. (Still ugly code, but split into smaller pieces.)
Can now pause.
Added a new colour scheme.
Added help screen.

1.0.2
Added Makefile.
Expand Down
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -2,6 +2,7 @@
OSRCS = \
colourScheme.c \
graphics.c \
help.c \
keys.c \
main.c \
random.c \
Expand Down
3 changes: 3 additions & 0 deletions snipes.6.in
Expand Up @@ -74,6 +74,9 @@ Sets colour scheme.
This page and the program by Cyp.
Original DOS game of same name by someone else.

.SH HOMEPAGE
http://cyp.github.com/snipes/

.SH COPYRIGHT
Copyright \(co 2005-2009, this software is licensed under the GPL version 2 or later,
as published by the Free Software Foundation.
Expand Down
2 changes: 2 additions & 0 deletions snipes.kdevelop.filelist
Expand Up @@ -5,6 +5,8 @@ src/colourScheme.c
src/colourScheme.h
src/graphics.c
src/graphics.h
src/help.c
src/help.h
src/keys.c
src/keys.h
src/main.c
Expand Down
45 changes: 45 additions & 0 deletions src/help.c
@@ -0,0 +1,45 @@
#include "help.h"

#include <string.h>


static int const helpWidth = 50;
static int const helpHeight = 29;
static char const helpText[50*29] =
"| |"
"| Welcome to Snipes. |"
"| |"
"|To open/close this help screen, press F3. |"
"| |"
"|Move around the maze, avoiding the snipe \x10\x11|"
"|bullets \x88, looking for the snipe generators, \x12\x13|"
"|shooting all the snipes \x80\x88 and snipe generators.|"
"| |"
"| \x17\x18\x19 |"
"|This is you: \x1A\x1B\x1C \x82 \x83 \x82 \x83 |"
"| \x1D\x1E\x1F |"
"| |"
"|Movement: Arrow keys, hold Space to go faster. |"
"|Shooting: Q\x8D,W\x8E,E\x8F, A\x8C,S\x8A,D\x88, Z\x8B,X\x8A,C\x89 |"
"| |"
"|Pause: P or Pause/Break key |"
"| |"
"|Fullscreen: Alt+Enter |"
"|Change resolution: F8, Up/Down, Enter |"
"|Change colours: F9, Up/Down, Enter |"
"| |"
"|Sound off: F1 Sound on: F2 |"
"| |"
"|Quit: Escape, N, Enter |"
"| |"
"| |"
"|http://cyp.github.com/snipes/ |"
"| |"
;

void renderHelp(unsigned char *disp, int width, int height)
{
int y;
for(y = 0; y < helpHeight; ++y)
memcpy(disp + (width-helpWidth)/2 + ((height-helpHeight)/2 + y)*width, helpText + y*helpWidth, helpWidth);
}
6 changes: 6 additions & 0 deletions src/help.h
@@ -0,0 +1,6 @@
#ifndef HELP_H_
#define HELP_H_

void renderHelp(unsigned char *disp, int width, int height);

#endif //HELP_H_
1 change: 1 addition & 0 deletions src/keys.c
Expand Up @@ -56,6 +56,7 @@ int getKey(Key key)
keyb[101]// Right Control
)
);
case KeyHelp: return keyb[61]; // F3


case KeyAccel: return keyb[15]| // Tab
Expand Down
1 change: 1 addition & 0 deletions src/keys.h
Expand Up @@ -19,6 +19,7 @@ typedef enum

KeyQuit,
KeyPause,
KeyHelp,

KeyAccel,
KeyMoveUp,
Expand Down
6 changes: 6 additions & 0 deletions src/main.c
Expand Up @@ -20,6 +20,7 @@ int main(int aa, char **bb)
{
int ll;
char chr[10] = "P8aS0@@@@@";
char currentVersionCharacter = 'A';
int newmode = 0;

// Find "$HOME/.snipesettings".
Expand Down Expand Up @@ -57,6 +58,11 @@ int main(int aa, char **bb)
if(chr[2]>='A'&&chr[2]<='H') newmode=chr[2]-'A'+100;
if(chr[3]=='S') enableSound(1); else if(chr[3]=='Q') enableSound(0); //Sound/Quiet//
if(chr[4]>='0'&&chr[4]<='0'+NUMCOLSS-1) { curcols=chr[4]-'0'; }
if(chr[5] < currentVersionCharacter)
{
chr[5] = currentVersionCharacter;
initialHelp = 1;
}

// Parse command line arguments.
char ch;
Expand Down
1 change: 1 addition & 0 deletions src/settings.c
Expand Up @@ -5,5 +5,6 @@ int curcols = 0;
int saidtoquit = 0;
int lcurd[18];
int newmode=-1;
int initialHelp = 0;

unsigned char disp[80*60];
3 changes: 3 additions & 0 deletions src/settings.h
Expand Up @@ -5,7 +5,10 @@ extern int curcols; // Current colour scheme.
extern int saidtoquit; // Should quit main loop.
extern int lcurd[18]; // TODO: Remember/figure out what this variable was for.
extern int newmode; // If this is set, change display mode/resolution on next tick.
extern int initialHelp;

static int const dispWidth = 80;
static int const dispHeight = 60;
extern unsigned char disp[80*60]; // The screen buffer. Doesn't belong here, but putting here for now...

#endif //SETTINGS_H_
15 changes: 14 additions & 1 deletion src/snipes.c
Expand Up @@ -16,6 +16,7 @@
#include "skillLevel.h"
#include "settings.h"
#include "keys.h"
#include "help.h"


void drawgame();
Expand Down Expand Up @@ -54,6 +55,7 @@ enum
unsigned char *maze=0;
int gametime=0, gametime2=0, gamescore=0, gamelives=0, gamestate = GameUninit;
int gamePaused = 0;
int gameDisplayHelp = 0;
int nummotd=0, nummot=0, numsnid=0, numsni=0, numhapd=0, numhap=0;

int maxsni, abulbounce, sbulbounce, sniprod, shootrate, targbounce, scanprob, killwall, snikilmot, snikilsni, antkilant, makehappy;
Expand Down Expand Up @@ -190,8 +192,17 @@ void tickgame()
gamePaused &= ~2;
else if(!(gamePaused & 2))
gamePaused ^= 3;
if(!getKey(KeyHelp))
gameDisplayHelp &= ~2;
else if(!(gameDisplayHelp & 2))
gameDisplayHelp ^= 3;
if(initialHelp)
{
initialHelp = 0;
gameDisplayHelp |= 1;
}

if(!gamePaused || gamestate != GameRunning)
if((!gamePaused || gamestate != GameRunning) && !gameDisplayHelp)
{
mzlx=(mzlx+lkx+mzx)%mzx; //if(rndr(100)==0) lkx=rndr(3)*2-2;
mzly=(mzly+lky+mzy)%mzy; //if(rndr(100)==0) lky=rndr(3)*2-2;
Expand All @@ -200,6 +211,8 @@ void tickgame()
tickobj();
}
drawgame();
if(gameDisplayHelp)
renderHelp(disp, 80, 60);

if(gamestate == GameRunning && getKey(KeyQuit)) gamestate = GameOverAborted;
if(gamestate != GameUninit && gamestate != GameRunning) {
Expand Down

0 comments on commit ec3d4d8

Please sign in to comment.