*Press Space to fly
and some of the variabel in it using indonesian language xD.
i'd rather called it flappy line.
here is the code:
#include <iostream>
#include <windows.h> //handle
#include <conio.h>
#include <stdlib.h>
#include <time.h>
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); // untuk statement Gotoxy
COORD CursorPosition;
void gotoXY(int x, int y)
{
CursorPosition.X = x;
CursorPosition.Y = y;
SetConsoleCursorPosition(console,CursorPosition);
}
using namespace std;
int tx=40,ty=1,titik=0,garis,score;
void mati();
void engine();
void batas()
{
for (garis=0;garis<=23;garis++)
{
gotoXY(46,garis);
cout<<"|";
}
}
void scoretampil()
{
gotoXY(55,5);
cout<<"Score = "<<score;
}
void reset()
{
srand (time(NULL)); //untuk membuat titik kosong
titik=rand() % 14;
titik+=6;
}
void tembokgambar()
{
for (garis=0;garis<=23;garis++)
{
gotoXY(tx,garis);
if (garis>=titik-2 && garis<=titik+2) //untuk membuat jarak sebanyak 3 garis dari titik gosong
cout<<" ";
else
cout<<"|";
}
}
void benda(int y)
{
gotoXY(14,y); //untuk garis lompat
cout<<"|";
if (y==24) mati(); //untuk mati saat dibawah
if (tx==14) //untuk flappy mati saat nabrak tembok
{
if (y != titik-2 && y != titik-1 && y != titik && y!=titik+1 && y != titik+2)
{
mati();
}
score+=1;
}
system("cls");
}
int gravitasi(int y) //untuk membuat jatuh lebih cepat jika spasi tidak ditekan
{
if (y==0)
{
Sleep(50);
}
else if(y==1)
{
Sleep(30);
}
else if(y==2)
{
Sleep(20);
}
else
{
Sleep(5);
}
}
void activisiongambar()
{
system("Color 02");
gotoXY(3,6); cout<<" ******************* ************************";
gotoXY(3,7); cout<<" * ********************* **************************";
gotoXY(3,8); cout<<" *** ** ** **\n";
gotoXY(3,9); cout<<" ***** ******* ** ** ** ** ** ****** ** ** **";
gotoXY(3,10);cout<<" *** *** ** ** ** ** ** ** ** ** ** ****** *** **";
gotoXY(3,11);cout<<" ********* ** ** ** ***** ** ****** ** ** ** ******";
gotoXY(3,12);cout<<" *** *** ** ** ** ** *** ** ** ** ** ** ** ***";
gotoXY(3,13);cout<<" ** ** ******* ** ** * ** ****** ** ****** ** **";
}
void activision()
{
activisiongambar();
Sleep(20);
system("cls");
Sleep(20);
activisiongambar();
Sleep(40);
system("cls");
Sleep(40);
activisiongambar();
Sleep(60);
system("cls");
Sleep(60);
activisiongambar();
Sleep(80);
system("cls");
Sleep(80);
activisiongambar();
Sleep(110);
system("cls");
Sleep(110);
activisiongambar();
Sleep(350);
system("cls");
Sleep(350);
activisiongambar();
Sleep(1000);
gotoXY(20,18);
cout<<" in association with";
Sleep(1000);
}
void namco()
{
system("cls");
system("Color 0C");
gotoXY(2,6); cout<<"*********** *********** ****************** *********** **********";
gotoXY(2,7); cout<<"************ ************ ******************* ************ ************";
gotoXY(2,8); cout<<"*** *** *** *** *** *** *** *** **";
gotoXY(2,9); cout<<"*** *** *********** *** *** *** *** *** **";
gotoXY(2,10);cout<<"*** *** ************ *** *** *** *** *** **";
gotoXY(2,11);cout<<"*** *** ***** *** *** *** *** *** *** **";
gotoXY(2,12);cout<<"*** *** ***** *** *** *** *** ************ ************";
gotoXY(2,13);cout<<"*** *** *********** *** *** *** *********** **********";
Sleep(1000);
system("cls");
}
void konami()
{
system("cls");
system("Color 0C");
gotoXY(2,6); cout<<"*** ** ***** *** ** * ** ** ****";
gotoXY(2,7); cout<<" ** ** ******* *** ** *** *** **** ***";
gotoXY(2,8); cout<<" ** ** ** ** **** ** ***** **** ***** ***";
gotoXY(2,9); cout<<" ** ** ** ** ** ** ** *** *** ** ** ** ** ***";
gotoXY(2,10);cout<<" **** ** ** ** ***** *** *** ** ** ** ** ***";
gotoXY(2,11);cout<<" ** ** ** ** ** **** *********** ** ** ** ** ***";
gotoXY(2,12);cout<<" ** ** ** ** ** *** ************* ** ** ** ** ***";
gotoXY(2,13);cout<<" ** ** ******* ** ** *** *** ** **** ** ***";
gotoXY(2,14);cout<<" ** ** ***** ** ** *** *** ** ** ** ***";
Sleep(1000);
}
int b=10;
string ab[100];
void loading()
{
b=10;
system("Color 07");
system("cls");
ab[0]=" Donate to keep this game alive";
ab[1]=" Eat in the right time okay";
ab[2]=" Say no to Marijuana";
ab[3]=" Be a good student";
ab[4]=" Study hard !!";
ab[5]=" Life is not fair so be calm with it -Patrick-";
ab[6]=" Even rope can be broken, why u dont ? Wait u are ugly u dnt have girlfriend";
ab[7]=" No bacod Skill Only !!";
gotoXY(1,9);
srand (time(NULL));
cout<<ab[rand() % 8];
gotoXY(10,21);cout<<"________________________________________";
gotoXY(10,23);cout<<"----------------------------------------";
gotoXY(66,22);cout<<"%";
for(int i=1;i<=40;i=(i+4))
{
gotoXY(9+i,22);
cout<<"////";
gotoXY(63,22);
cout<<b;
b=b+10;
Sleep(200);
}
gotoXY(58,22);cout<<"Press any button";
getch();
engine();
}
void easport()
{
system("cls");
system("Color 09");
cout<<"\n ";
cout<<" \n";
cout<<" \n";
cout<<" oooooooooooo\n";
cout<<" oooooooooooo \n";
cout<<" \n";
cout<<" \n";
cout<<" oooooooooooo \n";
cout<<" oooooooooooo \n";
cout<<" oooo \n";
cout<<" oooo \n";
cout<<" oooooooooooooooo\n";
cout<<" ooooooooooooooooo\n";
cout<<" ";
Sleep(800);
gotoXY(47,3);cout<<"o";
gotoXY(46,4);cout<<"ooo";
gotoXY(45,5);cout<<"ooooo";
gotoXY(44,6);cout<<"ooooooo";
gotoXY(43,7);cout<<"oooo oooo";
gotoXY(42,8);cout<<"oooo oooo";
gotoXY(41,9);cout<<"oooo oooo";
gotoXY(40,10);cout<<"oooo ooooooo";
gotoXY(39,11);cout<<"oooo ooooooooo";
gotoXY(39,12);cout<<"ooo oooo ";
gotoXY(39,13);cout<<"oo oooo \n\n\n";
Sleep(800);
gotoXY(20,15);cout<<" ooooooo ooooooo ooooooo ooooo oooooooo ";
gotoXY(20,16);cout<<" o o o o o o o o ";
gotoXY(20,17);cout<<" o ooooooo o o ooooo o ";
gotoXY(20,18);cout<<" o o o o o o o ";
gotoXY(20,19);cout<<" oooooo o ooooooo o oo o ";
gotoXY(20,20);cout<<" ";
gotoXY(20,21);cout<<" I T S I N T H E G A M E ";
Sleep(1000);
}
void engine()
{
tx=40;
ty=1;
titik=0;
int a=14,b=0;
bool repeat = true; //perulangan
reset();
while (repeat)
{
if(a<0) a=0;
benda(a);
if (tx==1)
{
tx=40;
reset();
}
tx-=1;
tembokgambar();
gravitasi(b);
++b;
if (kbhit())
{
char ch = getch();
switch (ch)
{
case 27: //tekan esc untuk berhenti
repeat = false;
break;
case 32: //tekan spasi untuk lompat
a=a-3;
b=0;
break;
}
}
a++; //flappy turun
batas();
scoretampil();
}
}
void mati()
{
system("cls");
gotoXY(20,10);
cout<<" You are Dead \n";
gotoXY(20,11);
cout<<" Your score is = "<<score;
score=0;
Sleep(2000);
getch();
loading();
}
int main()
{
activision();
easport();
namco();
loading();
engine();
return 0;
}
Wah, bahasa pemrograman saya blm nyampe C++ sob.. hehe.. keren ah.. skrg udh ada penerus game ini sob, namanya swing copters, coba cari codenya lg sob
BalasHapussalam
penghuni60.blogspot.com