OJOSO Forum Community
Selamat datang di Forum OJOSO.
Silahkan Mendaftar untuk Mengakses Forum ini

Selamat bergabung

Join the forum, it's quick and easy

OJOSO Forum Community
Selamat datang di Forum OJOSO.
Silahkan Mendaftar untuk Mengakses Forum ini

Selamat bergabung
OJOSO Forum Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Meski kami bukan yang terbesar dan terlengkap,tapi kami mencoba memberikan yang terbaik untuk anda


You are not connected. Please login or register

Game Mencari Jalan Keluar Dengan Turbo C (C++)

Go down  Message [Halaman 1 dari 1]

KEYMAKER

KEYMAKER

Game ini dapat diimajinasikan dengan lorong" untuk keluar...
Game ini dapat dijalankan dengan Turbo C...
Berikut adalah source code nya...

//memasukkan header file
#include "constream.h"
#include "dos.h"
#include "string.h"

constream disp; //membuat object bernamaa disp

void main() {
int array[12][12] = {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1},
{1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1},
{1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0},
{1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1},
{1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
{1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1},
{1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
}; //untuk mengisi angka2 ke dalam array

int i, j, x, y, tekan; // mendeklarasikan variable
x = 0, y = 2;

disp.clrscr();
disp<<<"Mulai ->"; //mencetak kata mulai di koordinat 19,8
disp<
do {
for(i = 0; i < 12; i++) {
for(j = 0; j < 12; j++) {
disp<if(array[i][j]) cout<<"#";
else cout<<".";
}
}// looping untuk mencetak map

disp<tekan = getch(); // mengetahui penekanan di keyboard
disp<
// validasi gerak
switch(tekan) {
case 72: if(y > 0 && !array[y - 1][x]) y--; break;
case 75: if(x > 0 && !array[y][x - 1]) x--; break;
case 77: if(x < 11 && !array[y][x + 1]) x++; break;
case 80: if(y < 11 && !array[y + 1][x]) y++; break;
}

} while(tekan != 27 && (x != 11 || y != 4)); // program berhenti apabila tekan ESC atau berhasil mencapai titik finish

//mencetak map
for(i = 0; i < 12; i++) {
for(j = 0; j < 12; j++) {
disp<if(array[i][j]) cout<<"#"; else cout<<".";
}
}
disp<disp<if(x == 11 && y == 4) cout<<"Anda HEBAT!"; //apabila finish, cetak ini
else cout<<" Anda CUPU "; // apabila tidak finish, cetak ini
disp<getch(); //untuk menampilkan layar output.
}


Untuk program selengkapnya, silahkan download DI SINI...

Semoga bermanfaat...
: )

Kembali Ke Atas  Message [Halaman 1 dari 1]

Permissions in this forum:
Anda tidak dapat menjawab topik