4-gewinnt  1.0.0
Klassiker "4-gewinnt" als Konsolenanwendung
 Alle Datenstrukturen Dateien Funktionen Variablen Makrodefinitionen Seiten
rules.c
gehe zur Dokumentation dieser Datei
1 #pragma once
2 
6 void addFrame(char* word){
7  //25Chars+1line break per line
8  //3lines needed 3*26+1(null byte)=
9  char* framePart = calloc(79,sizeof(char));
10  if(framePart==NULL){
11 
12  framePart="________________________\n";
13  framePart=strcat("|",word);
14  //framePart=strcat(framePart);
15 
16 
17  framePart[51]='|';
18  framePart[52]='\n';
19  framePart[53]='\0';
20  //framePart+53="________________________\n\0";
21 
22  }else{
23  //malloc failed-->fallback approach just output the supplied String without any formating
24  output("%s",word);
25  }
26 
27  //clean up
28  flushBuffer();
29  free(framePart);
30 }
31 
35 void showRules(){
36  startBuffer(70);
37  setLineAlign(0);
38  output("[ RULES ]\n\n");
39  setLineAlign(-1);
40  output("This a implementation of the famous two player game \"Connect Four\".\nSo you'll need a friend to play this game :) To win you simply have to\nconnect four of your chips in a row. This row can be horizontal,\nvertical or diagonal,it doesn't matter as long as there are no \"enemy\"\nchips between your chips.\nThe game will automatically end if one you won and take you to the\n\"Hall of Shame\"\n\n");
41  setLineAlign(0);
42  output("[ Press any key to return to main menu ]\n");
43  flushBuffer();
44  getch();
45 }
void showRules()
Definition: rules.c:35
void setLineAlign(int align)
Definition: system.c:344
void flushBuffer()
Definition: system.c:188
void startBuffer(int maxTextLength)
Definition: system.c:319
void addFrame(char *word)
Definition: rules.c:6
int output(const char *input,...)
Definition: system.c:144