#include <iostream.h>
#include <conio.h>
#include <windows.h>
void begr (void);
void begr2 (void);
void leicht (void);
void mittel (void);
void schwer (void);
int main ()
{
int abbr;
char stufe;
begr();
getchar();
clrscr();
begr2();
getchar();
clrscr();
do
{
cout << "\t\t -----------------------------------\n";
cout << "\t\t | Sie befinden sich im Startmenue |\n";
cout << "\t\t -----------------------------------\n\n\n";
cout << " Waehlen Sie Ihre Schwierigkeitsstufe: \n\n";
cout << " <1> Leicht (8x8)\n <2> Mittel (10x10)\n <3> Schwer (12x12)";
cout << " \n Zum Abbrechen druecken Sie 0";
cout << "\n\n Eingabe: ";
cin >> stufe;
switch (stufe)
{
case '1': clrscr();
abbr =1;
leicht ();
getchar();
clrscr();
break;
case '2': clrscr();
abbr=1;
mittel();
getchar();
clrscr();
break;
case '3': clrscr();
abbr=1;
schwer();
getchar();
clrscr();
break;
case '0': abbr=0;
break;
default: abbr=1;
clrscr();
cout << "\n\n\n\t\t Sie haben keine Schwierigkeitsstufe gewaehlt!";
cout << "\n\n\t\t Geben Sie bitte eine der genannten Stufen ein!";
getchar();
clrscr();
}
} while (abbr != 0);
}
void begr (void)
{
cout << "\n\n\n\n";
cout << " -------------------------------------------------------------------\n";
cout << " | |\n";
cout << " | |\n";
cout << " | ######## ## ### ## ## ## ## ### ## ####### |\n";
cout << " | ## ## ## ## ## ## ## ## ## ## ## ## |\n";
cout << " | ######## ## ## ## ## ### ## ## ## ## ## ### |\n";
cout << " | ## ## ## ### ## ## ## ## ### ## ## |\n";
cout << " | ######## ## ## ## ## ## ## ## ## ####### |\n";
cout << " | |\n";
cout << " | |\n";
cout << " | ######## ## ## ## ####### ######## |\n";
cout << " | ## ## ## ## ## ## ## |\n";
cout << " | ######## ####### ## ####### ######## |\n";
cout << " | ## ## ## ## ## ## |\n";
cout << " | ######## ## ## ## ## ######## |\n";
cout << " | |\n";
cout << " | |\n";
cout << " -------------------------------------------------------------------\n";
}
void begr2 (void)
{
cout << "\n\n\n\n\n";
cout << "\n\t ____________________________________________________";
cout << "\n\t " <<char(186)<<"\t\t\t\t\t\t\t "<<char(186);
cout << "\n\t " <<char(186)<<"\t\t\t\t\t\t\t "<<char(186);
cout << "\n\t " <<char(186)<<"\t\t\tHerzlich Willkommen zu\t\t "<<char(186);
cout << "\n\t " <<char(186)<<"\t\t\t\t\t\t\t "<<char(186);
cout << "\n\t " <<char(186)<<"\t\t\t SINKING SHIPS "<<char(184)<<"\t\t "<<char(186);
cout << "\n\t " <<char(186)<<"\t\t\t\t\t\t\t "<<char(186);
cout << "\n\t " <<char(186)<<"____________________________________________________"<<char(186);
cout << "\n\n\n\n\n\n\n\n\n\n\t\t Ein Spiel von Julian Moehrlein und Florian Schmitt";
}
//------------ leichte Spielstufe ------------------
void leicht (void)
{
int x,y,ab,schuss;
x=9, y=11, schuss=0;
cout << "\n\t\t ----------------------------------";
cout << "\n\t\t | Gewaehlte Spielstufe: leicht |";
cout << "\n\t\t ----------------------------------";
cout << "\n\n\n Druecken Sie <ENTER> um mit dem Spiel zu beginnen.";
getchar();
clrscr();
char spielfeld[8][8];
memset(spielfeld, char (126) ,64);
const char space3[] = {32,32,32,'\0'};
const char space6[] = {32,32,32,32,32,32,'\0'};
cout << "\n\n\n";
cout << space3 << "Sinking Ships";
cout << "\n\n\n\n";
cout << space6 << " 1 2 3 4 5 6 7 8\n";
cout << space6 << " ---------------\n\n";
for(int i = 0; i < 8; i++)
{
cout << space3 << (char)(i + 65) << " | \t";
for(int j = 0; j < 8; j++)
{
cout << spielfeld[i][j] << ' ';
}
cout << '\n';
}
cout << "\n\n\nDruecken Sie <q> und dann <ENTER> zum abbrechen";
gotoxy (x,y);
do
{
char ch=0;
if (kbhit()) ch=getch ();
{
if (ch==72)
{
if (y>11)
{
y=y-1;
}
gotoxy (x,y);
ab=1;
} ;
if (ch==80)
{
if (y<18)
{
y=y+1;
}
gotoxy (x,y);
ab=1;
}
if (ch==77)
{
if (x<22)
{
x=x+2;
}
gotoxy (x,y);
ab=1;
}
if (ch==75)
{
if (x>=11)
{
x=x-2;
}
gotoxy (x,y);
ab=1;
}
if (ch==13)
{
cout << "x";
schuss=schuss+1;
gotoxy (x=x,y);
}
if (ch=='q')
{
ab=0;
clrscr();
cout << "\n\n\n\n\t Sie haben " << schuss << " mal geschossen.";
break;
}
}
}while (ab=1);
return ;
}
void mittel (void)
{
int x,y,ab,schuss;
x=9,y=11,schuss=0;
int steuer;
cout << "\n\t\t ----------------------------------";
cout << "\n\t\t | Gewaehlte Spielstufe: mittel |";
cout << "\n\t\t ----------------------------------";
cout << "\n\n\n Druecken Sie <ENTER> um mit dem Spiel zu beginnen.";
getchar();
clrscr();
char spielfeld[10][10];
memset(spielfeld, char (126) ,100);
const char space3[] = {32,32,32,'\0'};
const char space6[] = {32,32,32,32,32,32,'\0'};
cout << "\n\n\n";
cout << space3 << "Sinking Ships";
cout << "\n\n\n\n";
cout << space6 << " 1 2 3 4 5 6 7 8 9 10\n";
cout << space6 << " --------------------\n\n";
for(int i = 0; i < 10; i++)
{
cout << space3 << (char)(i + 65) << " | \t";
for(int j = 0; j < 10; j++)
{
cout << spielfeld[i][j] << " ";
}
cout << '\n';
}
cout << "\n\n\nDruecken Sie <q> zum abbrechen";
gotoxy (x,y);
do
{
char ch=0;
if (kbhit()) ch=getch ();
{
if (ch==72)
{
if (y>11)
{
y=y-1;
}
gotoxy (x,y);
ab=1;
}
if (ch==80)
{
if (y<20)
{
y=y+1;
}
gotoxy (x,y);
ab=1;
}
if (ch==77)
{
if (x<26)
{
x=x+2;
}
gotoxy (x,y);
ab=1;
}
if (ch==75)
{
if (x>=11)
{
x=x-2;
}
gotoxy (x,y);
ab=1;
}
if (ch==13)
{
cout << "x";
schuss=schuss+1;
gotoxy (x=x,y);
}
if (ch=='q')
{
ab=0;
clrscr();
cout << "\n\n\n\n\t Sie haben "<<schuss<<" mal geschossen.";
break;
}
}
} while (ab=1);
return;
}
//------------ schwere Spielstufe ------------------
void schwer (void)
{
int x,y,ab,schuss;
x=9,y=11,schuss=0;
cout << "\n\t\t ----------------------------------";
cout << "\n\t\t | Gewaehlte Spielstufe: schwer |";
cout << "\n\t\t ----------------------------------";
cout << "\n\n\n Druecken Sie <ENTER> um mit dem Spiel zu beginnen.";
getchar();
clrscr();
char spielfeld[12][12];
memset(spielfeld, char (126) ,144);
const char space3[] = {32,32,32,'\0'};
const char space6[] = {32,32,32,32,32,32,'\0'};
cout << "\n\n\n";
cout << space3 << "Sinking Ships";
cout << "\n\n\n\n";
cout << space6 << " 1 2 3 4 5 6 7 8 9 101112\n";
cout << space6 << " ------------------------\n\n";
for(int i = 0; i < 12; i++)
{
cout << space3 << (char)(i + 65) << " | \t";
for(int j = 0; j < 12; j++)
{
cout << spielfeld[i][j] << ' ';
}
cout << '\n';
}
cout << "\n\n\nDruecken Sie <q> zum abbrechen";
gotoxy (x,y);
do
{
char ch=0;
if (kbhit()) ch=getch ();
{
if (ch==72)
{
if (y>11)
{
y=y-1;
}
gotoxy (x,y);
ab=1;
}
if (ch==80)
{
if (y<22)
{
y=y+1;
}
gotoxy (x,y);
ab=1;
}
if (ch==77)
{
if (x<30)
{
x=x+2;
}
gotoxy (x,y);
ab=1;
}
if (ch==75)
{
if (x>=11)
{
x=x-2;
}
gotoxy (x,y);
ab=1;
}
}
if (ch==13) // enter
{
cout << "x";
schuss = schuss+1;
gotoxy (x=x,y);
}
if (ch=='q')
{
ab=0;
clrscr();
cout << "\n\n\n\n\t Sie haben "<<schuss<<" mal geschossen.";
break;
}
}while (ab=1); //ende do-while
return;
}