int boats[9] = {1, 1, 1, 1, 2, 2, 3, 4, 0};
+char *help =
+ "<d> Rotate shirp\n"
+ "<i> Move up element\n"
+ "<j> Move left element\n"
+ "<k> Move down element\n"
+ "<l> Move right element\n"
+ "<p> Put ship or bomb\n"
+ "<q> Quit\n"
+ "<t> Toggle case legend\n"
+ ;
+
/* help message */
int usage (int ret)
{
displayboard (boardhuman, xhuman, yhuman, mode, 1);
displayboard (boardcomputer, xcomputer, ycomputer, mode, 0);
- displayhelp (whelp, xhelp, yhelp);
+ displayhelp (help, xhelp, yhelp, whelp);
displaylogs ("Welcome to Battle Ships", wlogs, hlogs, xlogs, ylogs);
displaylogs ("Put your ships on board", wlogs, hlogs, xlogs, ylogs);
setcolor (white);
}
-void displayhelp (int width, int xoffset, int yoffset)
+void displayhelp (char *msg, int xoffset, int yoffset, int length)
{
- char *message = "Battle Ships\n------------\n- arrow or i, j, k, l to move\n- p to put ship or bomb\n- d to rotate ship\n- q to quit";
-
- int i = 0, j = 0, l = 0;
- char c;
- while ((c = message[l++]) != 0) {
- if (c != '\n') {
- if (i == width) {
- i = 0;
- j++;
- }
- mvaddch (yoffset + j, xoffset + i, c);
- i++;
- } else {
+ char *title = "Help message";
+ int i, j;
+
+ for (i = 0; (i < length) && (title[i] != '\0'); i++) {
+ mvaddch (yoffset , xoffset + i, title[i]);
+ mvaddch (yoffset + 1, xoffset + i, ACS_HLINE);
+ }
+ i = j = 0;
+ yoffset += 2;
+ while ((msg) && (*msg != '\0')) {
+ if ((*msg == '\n') || (i == length)) {
i = 0;
j++;
}
+ if (*msg != '\n') {
+ mvaddch (yoffset + j, xoffset + i, *msg);
+ i++;
+ }
+ msg++;
}
}
void displayelement (int length, int x, int y, int orient, char symb, int show);
-void displayhelp (int width, int xoffset, int yoffset);
+void displayhelp (char *msg, int xoffset, int yoffset, int length);
void displaylogs (char *messages, int width, int height, int xoffset, int yoffset);