03-19-2011, 10:51 AM
I made this game last summer. Its just about my best project I've ever made.
Code:
Code:
Code:
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <ctime>
using namespace std;
HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE);
int main() {
Gen:
int Hp = 5;
int color = 15;
int score = 0;
COORD POS1;
POS1.X = 15;
POS1.Y = 23;
COORD POS2;
POS2.X = 16;
POS2.Y = 23;
COORD POS3;
POS3.X = 17;
POS3.Y = 23;
COORD POS4;
POS4.X = 18;
POS4.Y = 23
;COORD POS5;
POS5.X = 19;
POS5.Y = 23;
goto Gen2
;Gen2:
time_t t;
time(&t);
srand(t);
int ASTotal1 = rand() % 75;
int ASTotal2 = rand() % 74;
int ASTotal3 = rand() % 73;
int ASTotal4 = rand() % 72;
int ASTotal5 = rand() % 75;
int ASTotal6 = rand() % 67;
int ASTotal7 = rand() % 74;
int ASTotal8 = rand() % 73;
int ASTotal9 = rand() % 74;
int ASTotal10 = rand() % 72;
goto randomize
;randomize:
;COORD AST;
AST.X = ASTotal1;
COORD AST2;
AST2.X = ASTotal2;
COORD AST3;
AST3.X = ASTotal3;
COORD AST4;
AST4.X = ASTotal4;
COORD AST5;
AST5.X = ASTotal5;
COORD AST6;
AST6.X = ASTotal6;
AST6.Y = 1;
COORD AST7;
AST7.X = ASTotal7;
AST7.Y = 1;
COORD AST8;
AST8.X = ASTotal8;
AST8.Y = 1;
COORD AST9;
AST9.X = ASTotal9;
AST9.Y = 1;
COORD AST10;
AST10.X = ASTotal10;
AST10.Y = 1;
goto DGen
;DGen:
AST.Y = 1;
AST2.Y = 1;
AST3.Y = 1;
AST4.Y = 1;
AST5.Y = 1;
AST6.Y = 1;
AST7.Y = 1;
AST8.Y = 1;
AST9.Y = 1;
AST10.Y = 1;
goto Game
;Game:
score += 1;
if(Hp <= 0)
{
system("cls");
cout << "You Lost!" << endl;
cout << "Your Score was: " << score;
system("pause>nul");
goto Gen
;}
if(POS1.Y == AST.Y && POS1.X == AST.X || POS2.Y == AST.Y && POS2.X == AST.X || POS3.Y == AST.Y && POS3.X == AST.X || POS4.Y == AST.Y && POS4.X == AST.X || POS5.Y == AST.Y && POS5.X == AST.X
){
color = 12;
Sleep(5);
Hp -= 1;
color = 15;
}
if(POS1.Y == AST2.Y && POS1.X == AST2.X || POS2.Y == AST2.Y && POS2.X == AST2.X || POS3.Y == AST2.Y && POS3.X == AST2.X || POS4.Y == AST2.Y && POS4.X == AST2.X || POS5.Y == AST.Y && POS5.X == AST2.X
){
color = 12;
Sleep(5);
Hp -= 1;
color = 15;
}
if(POS1.Y == AST3.Y && POS1.X == AST3.X || POS2.Y == AST3.Y && POS2.X == AST3.X || POS3.Y == AST3.Y && POS3.X == AST3.X || POS4.Y == AST3.Y && POS4.X == AST3.X || POS5.Y == AST3.Y && POS5.X == AST3.X
){
color = 12;
Sleep(5);
Hp -= 1;
color = 15;
}
if(POS1.Y == AST4.Y && POS1.X == AST4.X || POS2.Y == AST4.Y && POS2.X == AST4.X || POS3.Y == AST4.Y && POS3.X == AST4.X || POS4.Y == AST4.Y && POS4.X == AST4.X || POS5.Y == AST4.Y && POS5.X == AST4.X
){
color = 12;
Sleep(5);
Hp -= 1;
color = 15;
}
if(POS1.Y == AST5.Y && POS1.X == AST5.X || POS2.Y == AST5.Y && POS2.X == AST5.X || POS3.Y == AST5.Y && POS3.X == AST5.X || POS4.Y == AST5.Y && POS5.X == AST5.X || POS5.Y == AST5.Y && POS5.X == AST5.X
){
color = 12;
Hp -= 1;
color = 15;
}
if(POS1.Y == AST6.Y && POS1.X == AST6.X || POS2.Y == AST6.Y && POS2.X == AST6.X || POS3.Y == AST6.Y && POS3.X == AST6.X || POS4.Y == AST6.Y && POS5.X == AST6.X || POS5.Y == AST6.Y && POS5.X == AST6.X
){
color = 12;
Sleep(5);
Hp -= 1;
color = 15;
}
if(POS1.Y == AST7.Y && POS1.X == AST7.X || POS2.Y == AST7.Y && POS2.X == AST7.X || POS3.Y == AST7.Y && POS3.X == AST7.X || POS4.Y == AST7.Y && POS5.X == AST7.X || POS5.Y == AST7.Y && POS5.X == AST7.X
){
color = 12;
Sleep(5);
Hp -= 1;
color = 15;
}
if(POS1.Y == AST8.Y && POS1.X == AST8.X || POS2.Y == AST8.Y && POS2.X == AST8.X || POS3.Y == AST8.Y && POS3.X == AST8.X || POS4.Y == AST8.Y && POS5.X == AST8.X || POS5.Y == AST8.Y && POS5.X == AST8.X
){
color = 12;
Sleep(5);
Hp -= 1;
color = 15;
}
if(POS1.Y == AST9.Y && POS1.X == AST9.X || POS2.Y == AST9.Y && POS2.X == AST9.X || POS3.Y == AST9.Y && POS3.X == AST9.X || POS4.Y == AST9.Y && POS5.X == AST9.X || POS5.Y == AST9.Y && POS5.X == AST9.X
){
color = 12;
Sleep(5);
Hp -= 1;
color = 15;
}
if(POS1.Y == AST10.Y && POS1.X == AST10.X || POS2.Y == AST10.Y && POS2.X == AST10.X || POS3.Y == AST10.Y && POS3.X == AST10.X || POS4.Y == AST10.Y && POS5.X == AST10.X || POS5.Y == AST10.Y && POS5.X == AST10.X
){
color = 12;
Sleep(5);
Hp -= 1;
color = 15;
}
AST.Y += 1;
AST2.Y += 1;
AST3.Y += 1;
AST4.Y += 1;
AST5.Y += 1;
AST6.Y += 1;
AST7.Y += 1;
AST8.Y += 1;
AST9.Y += 1;
AST10.Y += 1;
if(AST.Y >= 25 || AST2.Y >= 25 || AST3.Y >= 25 || AST4.Y >= 25 || AST5.Y >= 25)
{
goto Gen2
;}
if(POS5.X >= 70)
{
POS1.X -= 1;
POS2.X -= 1;
POS3.X -= 1;
POS4.X -= 1;
POS5.X -= 1;
}
if(POS1.X <= 1)
{
POS1.X += 1;
POS2.X += 1;
POS3.X += 1;
POS4.X += 1;
POS5.X += 1;
}
system("cls");
SetConsoleCursorPosition(hconsole,AST);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,AST2);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,AST3);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,AST4);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,AST5);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,AST6);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,AST7);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,AST8);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,AST9);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,AST10);
SetConsoleTextAttribute(hconsole,12);
cout << "*" << endl;
SetConsoleCursorPosition(hconsole,POS1);
SetConsoleTextAttribute(hconsole,color);
cout << "<" << endl;
SetConsoleCursorPosition(hconsole,POS2);
SetConsoleTextAttribute(hconsole,color);
cout << "[" << endl;
SetConsoleCursorPosition(hconsole,POS3);
SetConsoleTextAttribute(hconsole,color);
cout << "&" << endl;
SetConsoleCursorPosition(hconsole,POS4);
SetConsoleTextAttribute(hconsole,color);
cout << "]" << endl;
SetConsoleCursorPosition(hconsole,POS5);
SetConsoleTextAttribute(hconsole,color);
cout << ">" << endl;
cout << "Score: " << score;
cout << "Hp: " << Hp;
;if(GetAsyncKeyState(VK_RIGHT)
){
POS1.X += 1;
POS2.X += 1;
POS3.X += 1;
POS4.X += 1;
POS5.X += 1;
goto Game
;}
if(GetAsyncKeyState(VK_LEFT)
){
POS1.X -= 1;
POS2.X -= 1;
POS3.X -= 1;
POS4.X -= 1;
POS5.X -= 1;
goto Game
;}
goto Game
;return 0;
}