You are on page 1of 34

#include

#include
#include
#include
#include
#include
#include
#include

<iostream>
<stdio.h>
<conio.h>
<stdlib.h>
<string.h>
<math.h>
<time.h>
<windows.h>

//=========================== prototipe fungsi ================================


void tampilan();
void menu();
void papan_1();
void papan_2();
void reset();
int about();
int ending();
int instruction();
int database();
int pengecekan_1();
int pengecekan_2();
int kolom();
int score();
//======================== Deklarasi Variable Global ==========================
char nama[2][6];
char name[10];
char kata[20] = { '\0' };
char msg[200];
char kosong = '\0';
char papan1[15][17] = { { '\0' } };
char papan2[15][17] = { { '\0' } };
char loker[5][10];
char nol[5] = { 0 };
int nilai[5];
int sedia1[26] = { 10, 5, 5, 6, 10, 4, 5, 5, 10, 6, 6, 6, 5, 7, 10, 4, 3, 7, 6,
6, 6, 4, 4, 3, 4, 3 };
int sedia2[26] = { 10, 5, 5, 6, 10, 4, 5, 5, 10, 6, 6, 6, 5, 7, 10, 4, 3, 7, 6,
6, 6, 4, 4, 3, 4, 3 };
int poin1[26] = { 1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1
, 4, 4, 8, 4, 10 };
int poin2[26] = { 1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1
, 4, 4, 8, 4, 10 };
FILE *in;
char kolom_awal, kolom_akhir, konfirmasi, keluar, convert[1], masukan[1], pilih_
an[1], chose[1];
int k_awal, k_akhir, baris_awal, baris_akhir, awal, akhir, input, pilih, pil, pi
lihan, indx, i, j, xy, poin_1 = 0, poin_2 = 0, play1 = 1, play2 = 1;
int key, len_b, len_k, a = 1, b = 0, c = 0, d = 0, e = 0;
time_t satu, dua;
struct pemain{
char nama[30];
int score;
};
pemain p1[5], p2[5];
struct highscore{
char nama[30];

int score;
};
void gotoxy(int x, int y)
{
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
//======================= ini adalah program utama ============================
int main(void)
{
//------------------------------------------------------------------------- untuk mereset kata.txt
in = fopen("kata1.txt", "w");
fputs("kata\n", in);
fclose(in);
in = fopen("kata2.txt", "w");
fputs("kata\n", in);
fclose(in);
//------------------------------------------------------------------------- untuk menampilkan kata runing
char apple[12] = { 'S', 'C', 'R', 'A', 'B', 'B', 'L', 'E', 'G', 'A', 'M'
, 'E' };
tampilan();
PlaySound(TEXT("suara1.wav"), NULL, SND_FILENAME);
gotoxy(30, 12); textcolor(14); cprintf("%c%c", 7, apple[0]); Sleep(250);
gotoxy(32, 12); textcolor(14); cprintf("%c%c", 7, apple[1]); Sleep(250);
gotoxy(34, 12); textcolor(14); cprintf("%c%c", 7, apple[2]); Sleep(250);
gotoxy(36, 12); textcolor(14); cprintf("%c%c", 7, apple[3]); Sleep(250);
gotoxy(38, 12); textcolor(14); cprintf("%c%c", 7, apple[4]); Sleep(250);
gotoxy(40, 12); textcolor(14); cprintf("%c%c", 7, apple[5]); Sleep(250);
gotoxy(42, 12); textcolor(14); cprintf("%c%c", 7, apple[6]); Sleep(250);
gotoxy(44, 12); textcolor(14); cprintf("%c%c", 7, apple[7]); Sleep(250);
gotoxy(36, 10); textcolor(14); cprintf("%c%c", 7, apple[8]); Sleep(250);
gotoxy(36, 12); textcolor(14); cprintf("%c%c", 7, apple[9]); Sleep(250);
gotoxy(36, 14); textcolor(14); cprintf("%c%c", 7, apple[10]); Sleep(250)
;
gotoxy(36, 16); textcolor(14); cprintf("%c%c", 7, apple[11]); Sleep(250)
;
Sleep(500);
menu();
}
//========================= ini adalah fungsi menu ============================
void menu()
{
clrscr();
for (i = 60; i >= 34; i--){
gotoxy(i, 4); textattr(10); cputs("== P L A Y =="); Sleep(20); g
otoxy(i + 13, 4); printf(" ");
}
for (i = 60; i >= 33; i--){
gotoxy(i, 6); textattr(10); cputs("== HIGHSCORE =="); Sleep(20);
gotoxy(i + 15, 6); printf(" ");
}
for (i = 60; i >= 32; i--){
gotoxy(i, 8); textattr(10); cputs("== INSTRUCTION =="); Sleep(20

); gotoxy(i + 17, 8); printf(" ");


}
for (i = 60; i >= 33; i--){
gotoxy(i, 10); textattr(10); cputs("== A B O U T =="); Sleep(20)
; gotoxy(i + 15, 10); printf(" ");
}
for (i = 60; i >= 36; i--){
gotoxy(i, 12); textattr(10); cputs("== EXIT =="); Sleep(20); got
oxy(i + 10, 12); printf(" ");
}
PlaySound(TEXT("music.wav"), NULL, SND_FILENAME);
menu:
gotoxy(34, 3); textattr(10); textbackground(0); cputs("");
gotoxy(34, 4); textattr(10); textbackground(a); cputs("<= P L A Y =>");
gotoxy(33, 6); textattr(10); textbackground(b); cputs("<= HIGHSCORE =>")
;
gotoxy(32, 8); textattr(10); textbackground(c); cputs("<= INSTRUCTION =>
");
gotoxy(33, 10); textattr(10); textbackground(d); cputs("<= A B O U T =>"
);
gotoxy(36, 12); textattr(10); textbackground(e); cputs("<= EXIT =>");
for (i = 0; i<2; i++){
key = getch();
if (key == 13){
if (e == 1){
gotoxy(1, 25); cprintf("Exit SCRABBLE? [exit] pr
ess <Enter> [menu] press <Esc> :");
PlaySound(TEXT("voice-please-confirm.wav"), NULL
, SND_FILENAME);
key = getch();
if (key == 13){
PlaySound(TEXT("voice-closing.wav"), NUL
L, SND_FILENAME);
_exit(1);
}
else{
delline();
goto menu;
}
}
else if (a == 1){
goto pilihan;
}
else if (b == 1){
clrscr();
score();
cprintf("\n\n\n Press Anykey Back to Menu ");
getch();
clrscr();
goto menu;
}
else if (c == 1){
clrscr();
instruction();
getch();
clrscr();
goto menu;
}
else if (d == 1){

atas:
clrscr();
gotoxy(18, 3); textcolor(14); cprintf(" 1. Reset
High Score ");
gotoxy(18, 5); textcolor(14); cprintf(" 2. About
");
gotoxy(18, 7); textcolor(14); cprintf(" 3. Back
");
printf("\n\n\t\t Press key ");
gets(chose);
pil = atoi(chose);
if (pil == 1){
if ((in = fopen("score.txt", "wb")) == N
ULL){
fprintf(stderr, "Cannot open inp
ut file.\n");
//return 1;
}
for (i = 0; i<5; i++){
fread(&p2, sizeof(p2), 1, in);
strcpy(loker[i], p2[i].nama);
nilai[i] = p2[i].score;
}
for (i = 0; i<5; i++){
p1[i].score = 0;
strcpy(p1[i].nama, nol);
fwrite(&p1, sizeof(p1), 1, in);
}
fclose(in);
goto atas;
}
else if (pil == 2){
clrscr();
about();
cprintf("\n\n\n");
cprintf(" Press Anykey ");
getch();
goto atas;
}
else if (pil == 3){
clrscr();
goto menu;
}
else{
goto atas;
}
}
else {
clrscr();
goto menu;
}
}
else if (key == 80){
PlaySound(TEXT("WHOOSH.wav"), NULL, SND_FILENAME);
if (b == 1){ b = 0; c = 1; a = 0; d = 0; e = 0; goto men
u; }
if (c == 1){ b = 0; c = 0; a = 0; d = 1; e = 0; goto men
u; }
if (d == 1){ b = 0; c = 0; a = 0; d = 0; e = 1; goto men
u; }

if (e == 1){ b = 0; c = 0; a = 1; d = 0; e = 0; goto men


u; }
a = 0; b = 1; c = 0; d = 0; e = 0; goto menu;
}
else if (key == 72){
PlaySound(TEXT("WHOOSH.wav"), NULL, SND_FILENAME);
if (e == 1){ a = 0; b = 0; c = 0; d = 1; e = 0; goto men
u; }
if (d == 1){ a = 0; b = 0; c = 1; d = 0; e = 0; goto men
u; }
if (c == 1){ c = 0; b = 1; c = 0; d = 0; e = 0; goto men
u; }
if (b == 1){ a = 1; b = 0; c = 0; d = 0; e = 0; goto men
u; }
a = 0; b = 0; c = 0; d = 0; e = 1; goto menu;
}
else{
goto menu;
}
}
//------------------------------------------------------------------------- pilihan mode pemain
pilihan:
clrscr();
gotoxy(18, 3); textcolor(14); cprintf("1. Single Player");
gotoxy(18, 5); textcolor(14); cprintf("2. Multi player");
gotoxy(18, 7); textcolor(14); cprintf("3. Time Attack");
gotoxy(18, 9); textcolor(14); cprintf("4. Back");
printf("\n\n\t\t Press Key ");
gets(convert);
pilih = atoi(convert);
//---------------------------------------------------------------------- pilihan database kata
if (pilih == 1){
PlaySound(TEXT("WHOOSH.wav"), NULL, SND_FILENAME);
pilih_kata1:
clrscr();
gotoxy(18, 3); textcolor(14); cprintf(" Anda Telah Memilih 1 Pla
yer");
gotoxy(18, 4); textcolor(14); cprintf(" ========================
====");
gotoxy(18, 6); textcolor(14); cprintf(" Pilih Perbendaharaan Kat
a");
gotoxy(18, 8); textcolor(14); cprintf(" 1. Nama Hewan(Animal)");
gotoxy(18, 10); textcolor(14); cprintf(" 2. Kata Sifat(adjective
)");
gotoxy(18, 12); textcolor(14); cprintf(" 3. Kata Kerja(verb)");
gotoxy(18, 14); textcolor(14); cprintf(" 4. Back");
printf("\n\n\t\t Press key ");
gets(masukan);
input = atoi(masukan);
if (input == 1){
clrscr();
goto input_nama;
}
else if (input == 2){
clrscr();
goto input_nama;
}

else if (input == 3){


clrscr();
goto input_nama;
}
else if (input == 4){
PlaySound(TEXT("WHOOSH.wav"), NULL, SND_FILENAME);
goto pilihan;
}
else{
clrscr();
goto pilih_kata1;
}
}
//---------------------------------------------------------------------- pilihan database kata
else if (pilih == 2){
PlaySound(TEXT("WHOOSH.wav"), NULL, SND_FILENAME);
pilih_kata2:
clrscr();
gotoxy(18, 3); textcolor(14); cprintf(" Anda Telah Memilih 2 Pla
yer");
gotoxy(18, 4); textcolor(14); cprintf(" ========================
====");
gotoxy(18, 6); textcolor(14); cprintf(" Pilih Perbendaharaan Kat
a");
gotoxy(18, 8); textcolor(14); cprintf(" 1. Nama Hewan(Animal)");
gotoxy(18, 10); textcolor(14); cprintf(" 2. Kata Sifat(adjective
)");
gotoxy(18, 12); textcolor(14); cprintf(" 3. Kata Kerja(verb)");
gotoxy(18, 14); textcolor(14); cprintf(" 4. Back");
printf("\n\n\t\t Press key ");
gets(masukan);
input = atoi(masukan);
if (input == 1){
clrscr();
goto input_nama;
}
else if (input == 2){
clrscr();
goto input_nama;
}
else if (input == 3){
clrscr();
goto input_nama;
}
else if (input == 4){
PlaySound(TEXT("WHOOSH.wav"), NULL, SND_FILENAME);
goto pilihan;
}
else{
clrscr();
goto pilih_kata2;
}
}
if (pilih == 3){
PlaySound(TEXT("WHOOSH.wav"), NULL, SND_FILENAME);
pilih_kata:
clrscr();
gotoxy(18, 3); textcolor(14); cprintf(" Anda Telah Memilih Time
Attack");

gotoxy(18, 4); textcolor(14); cprintf(" ========================


====");
gotoxy(18, 6); textcolor(14); cprintf(" Pilih Perbendaharaan Kat
a");
gotoxy(18, 8); textcolor(14); cprintf(" 1. Nama Hewan(Animal)");
gotoxy(18, 10); textcolor(14); cprintf(" 2. Kata Sifat(adjective
)");
gotoxy(18, 12); textcolor(14); cprintf(" 3. Kata Kerja(verb)");
gotoxy(18, 14); textcolor(14); cprintf(" 4. Back");
printf("\n\n\t\t Press key ");
gets(masukan);
input = atoi(masukan);
if (input == 1){
clrscr();
goto input_nama;
}
else if (input == 2){
clrscr();
goto input_nama;
}
else if (input == 3){
clrscr();
goto input_nama;
}
else if (input == 4){
PlaySound(TEXT("WHOOSH.wav"), NULL, SND_FILENAME);
goto pilihan;
}
else{
clrscr();
goto pilih_kata;
}
}
else if (pilih == 4){
PlaySound(TEXT("WHOOSH.wav"), NULL, SND_FILENAME);
clrscr();
goto menu;
}
else{
clrscr();
goto pilihan;
}
//------------------------------------------------------------------------- memasukkan nama pemain
input_nama:
clrscr();
if (pilih == 1 || pilih == 3){
gotoxy(18, 3); textcolor(14); cprintf(" Masukkan Nama Player Max
5 Karakter : ");
PlaySound(TEXT("voice-piy.wav"), NULL, SND_FILENAME);
gets(name);
for (i = 0; i<5; i++){
nama[0][i] = name[i];
}
PlaySound(TEXT("voice-accepted.wav"), NULL, SND_FILENAME);
if (pilih == 3){
satu = time(NULL);
}
papan_1();

}
if (pilih == 2){
gotoxy(18, 3); textcolor(14); cprintf("\n Masukkan Nama Player 1
Max 5 Karakter : ");
PlaySound(TEXT("voice-piy.wav"), NULL, SND_FILENAME);
gets(name);
for (i = 0; i<5; i++){
nama[0][i] = name[i];
}
gotoxy(18, 5); textcolor(14); cprintf("\n Masukkan Nama Player 2
Max 5 Karakter : ");
gets(name);
for (i = 0; i<5; i++){
nama[1][i] = name[i];
}
PlaySound(TEXT("voice-accepted.wav"), NULL, SND_FILENAME);
papan_1();
}
}
//======================= ini adal fungsi tampilan awal =======================
void tampilan()
{
for (i = 2; i<8; i++){
gotoxy(20, 1); textcolor(i); textbackground(0); cprintf("
** ");
gotoxy(20, 2); textcolor(i); textbackground(0); cprintf("
**** ");
gotoxy(20, 3); textcolor(i); textbackground(0); cprintf("
***** ");
gotoxy(20, 4); textcolor(i); textbackground(0); cprintf("
**** ");
gotoxy(20, 5); textcolor(i); textbackground(0); cprintf("
*
*******
**
******** ");
gotoxy(20, 6); textcolor(i); textbackground(0); cprintf("
***
************ *************** ");
gotoxy(20, 7); textcolor(i); textbackground(0); cprintf(" ****
******************************* ");
gotoxy(20, 8); textcolor(i); textbackground(0); cprintf(" *****
******************************** ");
gotoxy(20, 9); textcolor(i); textbackground(0); cprintf(" *****
******************************** ");
gotoxy(20, 10); textcolor(i); textbackground(0); cprintf(" *****
********************************** ");
gotoxy(20, 11); textcolor(i); textbackground(0); cprintf(" *****
********************************** ");
gotoxy(20, 12); textcolor(i); textbackground(0); cprintf(" *****
********************************** ");
gotoxy(20, 13); textcolor(i); textbackground(0); cprintf(" *****
********************************** ");
gotoxy(20, 14); textcolor(i); textbackground(0); cprintf(" ****
********************************* ");
gotoxy(20, 15); textcolor(i); textbackground(0); cprintf(" ***
******************************** ");
gotoxy(20, 16); textcolor(i); textbackground(0); cprintf("
**
******************************* ");
gotoxy(20, 17); textcolor(i); textbackground(0); cprintf("
*
****************************** ");
gotoxy(20, 18); textcolor(i); textbackground(0); cprintf("
***************************** ");
gotoxy(20, 19); textcolor(i); textbackground(0); cprintf("

************************* ");
gotoxy(20, 20); textcolor(i); textbackground(0); cprintf("
********
******** ");
Sleep(500);
}
clrscr();
gotoxy(20, 1); textcolor(2); textbackground(0); cprintf("
** ");
gotoxy(20, 2); textcolor(2); textbackground(0); cprintf("
**** ");
gotoxy(20, 3); textcolor(2); textbackground(0); cprintf("
***** ");
gotoxy(20, 4); textcolor(2); textbackground(0); cprintf("
**** ");
gotoxy(20, 5); textcolor(2); textbackground(0); cprintf("
********
**
******** ");
gotoxy(20, 6); textcolor(2); textbackground(0); cprintf("
***********
**** *************** ");
gotoxy(20, 7); textcolor(2); textbackground(0); cprintf(" ************
********************* ");
gotoxy(20, 8); textcolor(2); textbackground(0); cprintf(" *************
******************* ");
gotoxy(20, 9); textcolor(2); textbackground(0); cprintf(" *************
****************** ");
gotoxy(20, 10); textcolor(2); textbackground(0); cprintf(" *************
******************* ");
gotoxy(20, 11); textcolor(2); textbackground(0); cprintf(" *************
******************* ");
gotoxy(20, 12); textcolor(2); textbackground(0); cprintf(" *************
******************** ");
gotoxy(20, 13); textcolor(2); textbackground(0); cprintf(" *************
*********************** ");
gotoxy(20, 14); textcolor(2); textbackground(0); cprintf(" ************
************************* ");
gotoxy(20, 15); textcolor(2); textbackground(0); cprintf(" ***********
************************ ");
gotoxy(20, 16); textcolor(2); textbackground(0); cprintf("
**********
*********************** ");
gotoxy(20, 17); textcolor(2); textbackground(0); cprintf("
*********
********************** ");
gotoxy(20, 18); textcolor(2); textbackground(0); cprintf("
********
********************* ");
gotoxy(20, 19); textcolor(2); textbackground(0); cprintf("
******
******************* ");
gotoxy(20, 20); textcolor(2); textbackground(0); cprintf("
****
****
******** ");
}
//============================ fungsi Membuat Papan ============================
void papan_1()
{
awal:
clrscr();
if (play1 == 0 && play2 == 0){
ending();
}
if (play1 == 0){
papan_2();
}
if (play1 == 1){
//--------------------------------------------------------------

------------ ini adalah pembuat papan


gotoxy(15, 1); printf("==========<(S C R A B B L E - G A M E)>==
========\n");
printf(" a b c d e f g h i j k l m n o \n");
for (i = 0; i<15; i++){
for (j = 0; j<15; j++){
if (*(*(papan1 + i) + j) == '\0'){
textcolor(14); cprintf("[ ]", *(*(papan1
+ i) + j));
}
else{
printf("[%c]", *(*(papan1 + i) + j));
}
}
printf(" %d", i);
if (i<1){
strupr(nama[0]);
textcolor(2); cprintf("
Player1 = [%s]", na
ma[0]);
}
else if (i == 1){
textcolor(2); cprintf("
Poin
= [%d]", po
in_1);
}
else if (i>1 && i<3){
printf("\t 1 A = %d 1 N = %d", sedia1[0], sedi
a1[13]);
}
else if (i>2 && i<4){
printf("\t 3 B = %d 1 O = %d", sedia1[1], sedi
a1[14]);
}
else if (i>3 && i<5){
printf("\t 3 C = %d 3 P = %d", sedia1[2], sedi
a1[15]);
}
else if (i>4 && i<6){
printf("\t 2 D = %d 10 Q = %d", sedia1[3], sed
ia1[16]);
}
else if (i>5 && i<7){
printf("\t 1 E = %d 1 R = %d", sedia1[4], sedi
a1[17]);
}
else if (i>6 && i<8){
printf("\t 4 F = %d 1 S = %d", sedia1[5], sedi
a1[18]);
}
else if (i>7 && i<9){
printf("\t 2 G = %d 1 T = %d", sedia1[6], sedi
a1[19]);
}
else if (i>8 && i<10){
printf("\t 4 H = %d 1 U = %d", sedia1[7], sedi
a1[20]);
}
else if (i>9 && i<11){
printf("\t 1 I = %d 4 V = %d", sedia1[8], sedi
a1[21]);
}

else if (i>10 && i<12){


printf("\t 8 J = %d

4 W = %d", sedia1[9], sedi

}
else if (i>11 && i<13){
printf("\t 5 K = %d

8 X = %d", sedia1[10], sed

}
else if (i>12 && i<14){
printf("\t 1 L = %d

4 Y = %d", sedia1[11], sed

}
else if (i>13 && i<15){
printf("\t 3 M = %d

10 Z = %d", sedia1[12], se

a1[22]);

ia1[23]);

ia1[24]);

dia1[25]);
}
printf("\n");
}
//------------------------------------------------------------------------- menu next atau end game
if (pilih == 1 || pilih == 3){
textcolor(14); cprintf("\n[1]Next

[2]End

[3]Help -->

");
gets(pilih_an);
pilihan = atoi(pilih_an);
if (pilihan == 1){
goto lanjut;
}
else if (pilihan == 2){
ending();
}
else if (pilihan == 3){
system("help.exe");
goto awal;
}
else{
goto awal;
}
}
if (pilih == 2){
textcolor(14); cprintf("\n[1]Next
4]Help --> ");
gets(pilih_an);
pilihan = atoi(pilih_an);
if (pilihan == 1){
goto lanjut;
}
else if (pilihan == 2){
papan_2();
}
else if (pilihan == 3){
play1 = 0;
papan_2();
}
else if (pilihan == 4){
system("help.exe");
goto awal;
}
else{

[2]Skip

[3]End

goto awal;
}
}
//------------------------------------------------------------------------- opsi pemilihan baris dan kolom
lanjut:
textcolor(2); cprintf("Masukkan batas awal (baris) = ");
scanf(" %d", &baris_awal);
textcolor(2); cprintf("Masukkan batas awal (kolom) = ");
scanf(" %c", &kolom_awal);
fflush(stdin);
textcolor(2); cprintf("Masukkan batas akhir (baris) = ");
scanf(" %d", &baris_akhir);
textcolor(2); cprintf("Masukkan batas akhir (kolom) = ");
scanf(" %c", &kolom_akhir);
printf("Apakah Anda Sudah Yakin? (Y/T) = ");
konfirmasi = getche();
if (konfirmasi == 'Y' || konfirmasi == 'y'){
kolom();
}
else{
goto awal;
}
printf("");
if (kolom() == 0){
goto awal;
}
//------------------------------------------------------------------------- masukkan kata dari user
gotoxy(1, 24); textcolor(2); cprintf("\nMasukkan kata = ");
scanf("%s", kata);
xy = strlen(kata);
if (baris_awal == baris_akhir){
len_k = k_akhir - k_awal + 1;
if (len_k != xy){
gotoxy(30, 25); textcolor(4); cprintf("Maaf Panj
ang Kata Tidak Sesuai");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;
}
}
if (kolom_awal >= kolom_akhir || kolom_awal <= kolom_akhir){
if (baris_awal < baris_akhir){
len_b = baris_akhir - baris_awal + 1;
if (len_b != xy){
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Panjang Kata Tidak Sesuai");
PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
if (baris_awal > baris_akhir){
len_b = baris_awal - baris_akhir + 1;
if (len_b != xy){
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Panjang Kata Tidak Sesuai");

PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
//------------------------------------------------------------------------- pengecekan database
if (database() == 1){
gotoxy(30, 25); textcolor(4); cprintf("Kata Tidak Ada di
Dalam Database");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FIL
ENAME);
Sleep(1000);
}
if (database() == 0 && pengecekan_1() == 0){
gotoxy(30, 25); textcolor(4); cprintf("Maaf kata sudah A
nda inputkan");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FIL
ENAME);
Sleep(1000);
}
//------------------------------------------------------------------------- pengecekan kata harus tersambung
if (database() == 0 && pengecekan_1() == 1){
if (papan1[7][7] != '\0'){
if (baris_awal == baris_akhir){
for (i = 0; i<xy; i++){
if (papan1[baris_awal][k_awal +
i] == '\0'){}
if (papan1[baris_awal][k_awal +
i] != '\0'){
if (papan1[baris_awal][k
_awal + i] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25);
textcolor(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("
voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Kata Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
if (kolom_awal == kolom_akhir && baris_awal>bari
s_akhir){
for (i = 0; i<xy; i++){
if (papan1[baris_awal - i][k_awa
l] == '\0'){}
if (papan1[baris_awal - i][k_awa

l] != '\0'){
if (papan1[baris_awal i][k_awal] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25);
textcolor(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("
voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Kata Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
if (kolom_awal == kolom_akhir && baris_awal<bari
s_akhir){
for (i = 0; i<xy; i++){
if (papan1[baris_awal + i][k_awa
l] == '\0'){}
if (papan1[baris_awal + i][k_awa
l] != '\0'){
if (papan1[baris_awal +
i][k_awal] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25);
textcolor(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("
voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Kata Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
if (baris_awal<baris_akhir && kolom_awal>kolom_a
khir){
for (i = 0; i<xy; i++){
if (papan1[baris_awal + i][k_awa
l - i] == '\0'){}
if (papan1[baris_awal + i][k_awa
l - i] != '\0'){
if (papan1[baris_awal +
i][k_awal - i] == kata[i]){
goto cek_sedia;

}
else{
gotoxy(30, 25);
textcolor(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("
voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Kata Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
if (baris_awal>baris_akhir && kolom_awal<kolom_a
khir){
for (i = 0; i<xy; i++){
if (papan1[baris_awal - i][k_awa
l + i] == '\0'){}
if (papan1[baris_awal - i][k_awa
l + i] != '\0'){
if (papan1[baris_awal i][k_awal + i] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25);
textcolor(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("
voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Kata Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
if (baris_awal<baris_akhir && kolom_awal<kolom_a
khir){
for (i = 0; i<xy; i++){
if (papan1[baris_awal + i][k_awa
l + i] == '\0'){}
if (papan1[baris_awal + i][k_awa
l + i] != '\0'){
if (papan1[baris_awal +
i][k_awal + i] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25);
textcolor(4); cprintf("Maaf Kata Tidak Cocok");

PlaySound(TEXT("
voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Kata Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
if (baris_awal>baris_akhir && kolom_awal>kolom_a
khir){
for (i = 0; i<xy; i++){
if (papan1[baris_awal - i][k_awa
l - i] == '\0'){}
if (papan1[baris_awal - i][k_awa
l - i] != '\0'){
if (papan1[baris_awal i][k_awal - i] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25);
textcolor(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("
voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Kata Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
//------------------------------------------------------------------------- cek persediaan kata
cek_sedia:
for (i = 0; i<xy; i++){
indx = kata[i] - 97;
if (sedia1[indx] == 0){
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Persediaan Huruf Anda Sudah Habis");
PlaySound(TEXT("voice-access-denied.wav"
), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
if (sedia1[indx] != 0){
sedia1[indx] -= 1;
poin_1 += poin1[indx];

}
}
if (baris_awal == baris_akhir){
for (i = 0; i<xy; i++){
papan1[baris_awal][k_awal + i] = kata[i]
;
}
}
if (kolom_awal == kolom_akhir && baris_awal>baris_akhir)
{
for (i = 0; i<xy; i++){
papan1[baris_awal - i][k_awal] = kata[i]
;
}
}
if (kolom_awal == kolom_akhir && baris_awal<baris_akhir)
{
for (i = 0; i<xy; i++){
papan1[baris_awal + i][k_awal] = kata[i]
;
}
}
if (baris_awal<baris_akhir && kolom_awal>kolom_akhir){
for (i = 0; i<xy; i++){
papan1[baris_awal + i][k_awal - i] = kat
a[i];
}
}
if (baris_awal>baris_akhir && kolom_awal<kolom_akhir){
for (i = 0; i<xy; i++){
papan1[baris_awal - i][k_awal + i] = kat
a[i];
}
}
if (baris_awal<baris_akhir && kolom_awal<kolom_akhir){
for (i = 0; i<xy; i++){
papan1[baris_awal + i][k_awal + i] = kat
a[i];
}
}
if (baris_awal>baris_akhir && kolom_awal>kolom_akhir){
for (i = 0; i<xy; i++){
papan1[baris_awal - i][k_awal - i] = kat
a[i];
}
}
//---------------------------------------------------------------------- pengecekan kata pertama harus di tengah
if (papan1[7][7] == '\0'){
for (i = 0; i<xy; i++){
if (baris_awal == baris_akhir){
papan1[baris_awal][k_awal + i] =
kosong;
}
if (kolom_awal == kolom_akhir && baris_a
wal>baris_akhir){
papan1[baris_awal - i][k_awal] =
kosong;
}
if (kolom_awal == kolom_akhir && baris_a

wal<baris_akhir){
papan1[baris_awal + i][k_awal] =
kosong;
}
if (baris_awal<baris_akhir && kolom_awal
>kolom_akhir){
papan1[baris_awal + i][k_awal i] = kosong;
}
if (baris_awal>baris_akhir && kolom_awal
<kolom_akhir){
papan1[baris_awal - i][k_awal +
i] = kosong;
}
if (baris_awal<baris_akhir && kolom_awal
<kolom_akhir){
papan1[baris_awal + i][k_awal +
i] = kosong;
}
if (baris_awal>baris_akhir && kolom_awal
>kolom_akhir){
papan1[baris_awal - i][k_awal i] = kosong;
}
}
poin_1 = 0;
gotoxy(30, 25); textcolor(4); cprintf("Maaf Kata
Harus di Tengah");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;
}
if (pilih == 3){
dua = time(NULL);
if (difftime(dua, satu) > 120){
gotoxy(30, 25); textcolor(4); cprintf("M
aaf Waktu Anda Sudah Habis");
PlaySound(TEXT("APPLAUSE.wav"), NULL, SN
D_FILENAME);
ending();
}
}
PlaySound(TEXT("APPLAUSE.wav"), NULL, SND_FILENAME);
//---------------------------------------------------------------------- penulisan kata yang sudah di input
if ((in = fopen("kata1.txt", "a")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
}
fflush(stdin);
fputs(kata, in);
fputc('\n', in);
fclose(in);
}
if (pilih == 1 || pilih == 3){
papan_1();
}
if (pilih == 2){
papan_2();
}

}
}
//============================ fungsi Membuat Papan ============================
void papan_2()
{
awal:
if (play2 == 0){
papan_1();
}
clrscr();
//------------------------------------------------------------------------- ini adalah pembuat papan
gotoxy(15, 1); printf("==========<(S C R A B B L E - G A M E)>==========
\n");
printf(" a b c d e f g h i j k l m n o \n");
for (i = 0; i<15; i++){
for (j = 0; j<15; j++){
if (*(*(papan2 + i) + j) == '\0'){
textcolor(14); cprintf("[ ]", *(*(papan2 + i) +
j));
}
else{
printf("[%c]", *(*(papan2 + i) + j));
}
}
printf(" %d", i);
if (i<1){
strupr(nama[1]);
textcolor(2); cprintf("
Player2 = [%s]", nama[1]);
}
else if (i == 1){
textcolor(2); cprintf("
Poin
= [%d]", poin_2);
}
else if (i>1 && i<3){
printf("\t 1 A = %d 1 N = %d", sedia2[0], sedia2[13]);
}
else if (i>2 && i<4){
printf("\t 3 B = %d 1 O = %d", sedia2[1], sedia2[14]);
}
else if (i>3 && i<5){
printf("\t 3 C = %d 3 P = %d", sedia2[2], sedia2[15]);
}
else if (i>4 && i<6){
printf("\t 2 D = %d 10 Q = %d", sedia2[3], sedia2[16])
;
}
else if (i>5 && i<7){
printf("\t 1 E = %d 1 R = %d", sedia2[4], sedia2[17]);
}
else if (i>6 && i<8){
printf("\t 4 F = %d 1 S = %d", sedia2[5], sedia2[18]);
}
else if (i>7 && i<9){
printf("\t 2 G = %d 1 T = %d", sedia2[6], sedia2[19]);
}
else if (i>8 && i<10){
printf("\t 4 H = %d 1 U = %d", sedia2[7], sedia2[20]);
}
else if (i>9 && i<11){
printf("\t 1 I = %d 4 V = %d", sedia2[8], sedia2[21]);

}
else if (i>10 && i<12){
printf("\t 8 J = %d
}
else if (i>11 && i<13){
printf("\t 5 K = %d

4 W = %d", sedia2[9], sedia2[22]);


8 X = %d", sedia2[10], sedia2[23])

;
}
else if (i>12 && i<14){
printf("\t 1 L = %d

4 Y = %d", sedia2[11], sedia2[24])

}
else if (i>13 && i<15){
printf("\t 3 M = %d

10 Z = %d", sedia2[12], sedia2[25]

);
}
printf("\n");
}
//------------------------------------------------------------------------- menu next atau end game
textcolor(14); cprintf("\n[1]Next [2]Skip [3]End [4]Help --> ");
scanf("%d", &pilihan);
if (pilihan == 1){
goto lanjut;
}
else if (pilihan == 2){
papan_1();
}
else if (pilihan == 3){
play2 = 0;
papan_1();
}
else if (pilihan == 4){
system("help.exe");
goto awal;
}
else{
goto awal;
}
//------------------------------------------------------------------------- opsi pemilihan baris dan kolom
lanjut:
textcolor(2); cprintf("Masukkan batas awal (baris) = ");
scanf(" %d", &baris_awal);
textcolor(2); cprintf("Masukkan batas awal (kolom) = ");
scanf(" %c", &kolom_awal);
fflush(stdin);
textcolor(2); cprintf("Masukkan batas akhir (baris) = ");
scanf(" %d", &baris_akhir);
textcolor(2); cprintf("Masukkan batas akhir (kolom) = ");
scanf(" %c", &kolom_akhir);
printf("Apakah Anda Sudah Yakin? (Y/T) = ");
konfirmasi = getche();
if (konfirmasi == 'Y' || konfirmasi == 'y'){
kolom();
}
else{
goto awal;

}
printf("");
if (kolom() == 0){
goto awal;
}
//------------------------------------------------------------------------- masukkan kata dari user
gotoxy(1, 24); textcolor(2); cprintf("\nMasukkan kata = ");
scanf("%s", kata);
xy = strlen(kata);
if (baris_awal == baris_akhir){
len_k = k_akhir - k_awal + 1;
if (len_k != xy){
gotoxy(30, 25); textcolor(4); cprintf("Maaf Panjang Kata
Tidak Sesuai");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FIL
ENAME);
Sleep(1000);
goto awal;
}
}
if (kolom_awal == kolom_akhir){
len_b = baris_akhir - baris_awal + 1;
if (len_b != xy){
gotoxy(30, 25); textcolor(4); cprintf("Maaf Panjang Kata
Tidak Sesuai");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FIL
ENAME);
Sleep(1000);
goto awal;
}
}
//------------------------------------------------------------------------- pengecekan database
if (database() == 1){
gotoxy(30, 25); textcolor(4); cprintf("Kata Tidak Ada di Dalam D
atabase");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
}
if (database() == 0 && pengecekan_2() == 0){
gotoxy(30, 25); textcolor(4); cprintf("Maaf kata sudah Anda inpu
tkan");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
}
//------------------------------------------------------------------------- pengecekan kata harus tersambung
if (database() == 0 && pengecekan_2() == 1){
if (papan2[7][7] != '\0'){
if (baris_awal == baris_akhir){
for (i = 0; i<xy; i++){
if (papan2[baris_awal][k_awal + i] == '\
0'){}
if (papan2[baris_awal][k_awal + i] != '\
0'){
if (papan2[baris_awal][k_awal +
i] == kata[i]){
goto cek_sedia;
}

else{
gotoxy(30, 25); textcolo
r(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("voice-ac
cess-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("Maaf Kata
Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;
}
if (kolom_awal == kolom_akhir && baris_awal>baris_akhir)
{
for (i = 0; i<xy; i++){
if (papan2[baris_awal - i][k_awal] == '\
0'){}
if (papan2[baris_awal - i][k_awal] != '\
0'){
if (papan2[baris_awal - i][k_awa
l] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25); textcolo
r(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("voice-ac
cess-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("Maaf Kata
Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;
}
if (kolom_awal == kolom_akhir && baris_awal<baris_akhir)
{
for (i = 0; i<xy; i++){
if (papan2[baris_awal + i][k_awal] == '\
0'){}
if (papan2[baris_awal + i][k_awal] != '\
0'){
if (papan2[baris_awal + i][k_awa
l] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25); textcolo
r(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("voice-ac

cess-denied.wav"), NULL, SND_FILENAME);


Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("Maaf Kata
Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;
}
if (baris_awal<baris_akhir && kolom_awal>kolom_akhir){
for (i = 0; i<xy; i++){
if (papan2[baris_awal + i][k_awal - i] =
= '\0'){}
if (papan2[baris_awal + i][k_awal - i] !
= '\0'){
if (papan2[baris_awal + i][k_awa
l - i] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25); textcolo
r(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("voice-ac
cess-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("Maaf Kata
Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;
}
if (baris_awal>baris_akhir && kolom_awal<kolom_akhir){
for (i = 0; i<xy; i++){
if (papan2[baris_awal - i][k_awal + i] =
= '\0'){}
if (papan2[baris_awal - i][k_awal + i] !
= '\0'){
if (papan2[baris_awal - i][k_awa
l + i] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25); textcolo
r(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("voice-ac
cess-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}

gotoxy(30, 25); textcolor(4); cprintf("Maaf Kata


Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;
}
if (baris_awal<baris_akhir && kolom_awal<kolom_akhir){
for (i = 0; i<xy; i++){
if (papan2[baris_awal + i][k_awal + i] =
= '\0'){}
if (papan2[baris_awal + i][k_awal + i] !
= '\0'){
if (papan2[baris_awal + i][k_awa
l + i] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25); textcolo
r(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("voice-ac
cess-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("Maaf Kata
Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;
}
if (baris_awal>baris_akhir && kolom_awal>kolom_akhir){
for (i = 0; i<xy; i++){
if (papan2[baris_awal - i][k_awal - i] =
= '\0'){}
if (papan2[baris_awal - i][k_awal - i] !
= '\0'){
if (papan2[baris_awal - i][k_awa
l - i] == kata[i]){
goto cek_sedia;
}
else{
gotoxy(30, 25); textcolo
r(4); cprintf("Maaf Kata Tidak Cocok");
PlaySound(TEXT("voice-ac
cess-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
goto awal;
}
}
}
gotoxy(30, 25); textcolor(4); cprintf("Maaf Kata
Harus Menyambung");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;

}
}
//------------------------------------------------------------------------- cek persediaan kata
cek_sedia:
for (i = 0; i<xy; i++){
indx = kata[i] - 97;
if (sedia2[indx] == 0){
gotoxy(30, 25); textcolor(4); cprintf("Maaf Pers
ediaan Huruf Anda Sudah Habis");
PlaySound(TEXT("voice-access-denied.wav"), NULL,
SND_FILENAME);
Sleep(1000);
goto awal;
}
if (sedia2[indx] != 0){
sedia2[indx] -= 1;
poin_2 += poin2[indx];
}
}
if (baris_awal == baris_akhir){
for (i = 0; i<xy; i++){
papan2[baris_awal][k_awal + i] = kata[i];
}
}
if (kolom_awal == kolom_akhir && baris_awal>baris_akhir){
for (i = 0; i<xy; i++){
papan2[baris_awal - i][k_awal] = kata[i];
}
}
if (kolom_awal == kolom_akhir && baris_awal<baris_akhir){
for (i = 0; i<xy; i++){
papan2[baris_awal + i][k_awal] = kata[i];
}
}
if (baris_awal<baris_akhir && kolom_awal>kolom_akhir){
for (i = 0; i<xy; i++){
papan2[baris_awal + i][k_awal - i] = kata[i];
}
}
if (baris_awal>baris_akhir && kolom_awal<kolom_akhir){
for (i = 0; i<xy; i++){
papan2[baris_awal - i][k_awal + i] = kata[i];
}
}
if (baris_awal<baris_akhir && kolom_awal<kolom_akhir){
for (i = 0; i<xy; i++){
papan2[baris_awal + i][k_awal + i] = kata[i];
}
}
if (baris_awal>baris_akhir && kolom_awal>kolom_akhir){
for (i = 0; i<xy; i++){
papan2[baris_awal - i][k_awal - i] = kata[i];
}
}
//---------------------------------------------------------------------- pengecekan kata pertama harus di tengah
if (papan2[7][7] == '\0'){
for (i = 0; i<xy; i++){

if (baris_awal == baris_akhir){
papan2[baris_awal][k_awal + i] = kosong;
}
if (kolom_awal == kolom_akhir && baris_awal>bari
s_akhir){
papan2[baris_awal - i][k_awal] = kosong;
}
if (kolom_awal == kolom_akhir && baris_awal<bari
s_akhir){
papan2[baris_awal + i][k_awal] = kosong;
}
if (baris_awal<baris_akhir && kolom_awal>kolom_a
khir){
papan2[baris_awal + i][k_awal - i] = kos
ong;
}
if (baris_awal>baris_akhir && kolom_awal<kolom_a
khir){
papan2[baris_awal - i][k_awal + i] = kos
ong;
}
if (baris_awal<baris_akhir && kolom_awal<kolom_a
khir){
papan2[baris_awal + i][k_awal + i] = kos
ong;
}
if (baris_awal>baris_akhir && kolom_awal>kolom_a
khir){
papan2[baris_awal - i][k_awal - i] = kos
ong;
}
}
poin_2 = 0;
gotoxy(30, 25); textcolor(4); cprintf("Maaf Kata Harus d
i Tengah");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FIL
ENAME);
Sleep(1000);
goto awal;
}
PlaySound(TEXT("APPLAUSE.wav"), NULL, SND_FILENAME);
//---------------------------------------------------------------------- penulisan kata yang sudah di input
if ((in = fopen("kata2.txt", "a")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
}
fflush(stdin);
fputs(kata, in);
fputc('\n', in);
fclose(in);
}
papan_1();
}
//======================= ini adalah pengecekan kolom =========================
int kolom()
{
if (kolom_awal == 'a' || kolom_awal == 'A'){
k_awal = 0;
}
else if (kolom_awal == 'b' || kolom_awal == 'B'){

k_awal = 1;
}
else if (kolom_awal == 'c' || kolom_awal == 'C'){
k_awal = 2;
}
else if (kolom_awal == 'd' || kolom_awal == 'D'){
k_awal = 3;
}
else if (kolom_awal == 'e' || kolom_awal == 'E'){
k_awal = 4;
}
else if (kolom_awal == 'f' || kolom_awal == 'F'){
k_awal = 5;
}
else if (kolom_awal == 'g' || kolom_awal == 'G'){
k_awal = 6;
}
else if (kolom_awal == 'h' || kolom_awal == 'H'){
k_awal = 7;
}
else if (kolom_awal == 'i' || kolom_awal == 'I'){
k_awal = 8;
}
else if (kolom_awal == 'j' || kolom_awal == 'J'){
k_awal = 9;
}
else if (kolom_awal == 'k' || kolom_awal == 'K'){
k_awal = 10;
}
else if (kolom_awal == 'l' || kolom_awal == 'L'){
k_awal = 11;
}
else if (kolom_awal == 'm' || kolom_awal == 'M'){
k_awal = 12;
}
else if (kolom_awal == 'n' || kolom_awal == 'N'){
k_awal = 13;
}
else if (kolom_awal == 'o' || kolom_awal == 'O'){
k_awal = 14;
}
else{
gotoxy(30, 25); textcolor(4); cprintf("Maaf Anda Melebihi Batas
Kolom Maksimal");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FILENAME);
return 0;
}
printf("");
if (kolom_akhir == 'a' || kolom_akhir == 'A'){
k_akhir = 0;
}
else if (kolom_akhir == 'b' || kolom_akhir == 'B'){
k_akhir = 1;
}
else if (kolom_akhir == 'c' || kolom_akhir == 'C'){
k_akhir = 2;
}
else if (kolom_akhir == 'd' || kolom_akhir == 'D'){
k_akhir = 3;
}

else if (kolom_akhir == 'e' || kolom_akhir == 'E'){


k_akhir = 4;
}
else if (kolom_akhir == 'f' || kolom_akhir == 'F'){
k_akhir = 5;
}
else if (kolom_akhir == 'g' || kolom_akhir == 'G'){
k_akhir = 6;
}
else if (kolom_akhir == 'h' || kolom_akhir == 'H'){
k_akhir = 7;
}
else if (kolom_akhir == 'i' || kolom_akhir == 'I'){
k_akhir = 8;
}
else if (kolom_akhir == 'j' || kolom_akhir == 'J'){
k_akhir = 9;
}
else if (kolom_akhir == 'k' || kolom_akhir == 'K'){
k_akhir = 10;
}
else if (kolom_akhir == 'l' || kolom_akhir == 'L'){
k_akhir = 11;
}
else if (kolom_akhir == 'm' || kolom_akhir == 'M'){
k_akhir = 12;
}
else if (kolom_akhir == 'n' || kolom_akhir == 'N'){
k_akhir = 13;
}
else if (kolom_akhir == 'o' || kolom_akhir == 'O'){
k_akhir = 14;
}
else{
gotoxy(30, 25); textcolor(4); cprintf("Maaf Anda Melebihi Batas
Kolom Maksimal");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FILENAME);
return 0;
}
printf("");
if (baris_awal > 14 || baris_akhir > 14){
gotoxy(30, 25); textcolor(4); cprintf("Maaf Anda Melebihi Batas
Kolom Maksimal");
PlaySound(TEXT("voice-access-denied.wav"), NULL, SND_FILENAME);
Sleep(1000);
return 0;
}
return 1;
}
//====================== ini adalah pengecekan data base ======================
int database()
{
char word[20];
int size;
size = strlen(kata);
if (input == 1){
if ((in = fopen("a_hewan.txt", "r")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
return 1;

}
}
if (input == 2){
if ((in = fopen("a_sifat.txt", "r"))
fprintf(stderr, "Cannot open
return 1;
}
}
if (input == 3){
if ((in = fopen("a_kerja.txt", "r"))
fprintf(stderr, "Cannot open
return 1;
}
}
while (!feof(in)){
fgets(word, 20, in);
word[size] = '\0';
bah jadi \0

== NULL){
input file.\n");

== NULL){
input file.\n");

//enter(\n) diru

if (strcmp(word, kata) == 0){


fclose(in);
return 0;
}
}
fclose(in);
return 1;
}
//============== ini adalah pengecekan kata yang sudah di input ===============
int pengecekan_1()
{
char word[20];
int size;
size = strlen(kata);
if ((in = fopen("kata1.txt", "r")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
while (!feof(in)){
fgets(word, 20, in);
word[size] = '\0';
bah jadi \0

//enter(\n) diru

if (strcmp(word, kata) == 0){


fclose(in);
return 0;
}
}
fclose(in);
return 1;
}
//============== ini adalah pengecekan kata yang sudah di input ===============
int pengecekan_2()
{
char word[20];
int size;
size = strlen(kata);
if ((in = fopen("kata2.txt", "r")) == NULL){
fprintf(stderr, "Cannot open input file.\n");

return 1;
}
while (!feof(in)){
fgets(word, 20, in);
word[size] = '\0';
bah jadi \0

//enter(\n) diru

if (strcmp(word, kata) == 0){


fclose(in);
return 0;
}
}
fclose(in);
return 1;
}
//========================= ini adalah fungsi about ===========================
int about()
{
if ((in = fopen("about.txt", "r")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
while (!feof(in)){
fgets(msg, 200, in);
printf("%s", msg);
}
fclose(in);
return 0;
}
//====================== ini adalah fungsi instruction ========================
int instruction()
{
if ((in = fopen("cara.txt", "r")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
while (!feof(in)){
fgets(msg, 200, in);
printf("%s", msg);
}
fclose(in);
return 0;
}
//======================= ini adalah fungsi High Score ========================
int score()
{
highscore score[5];
char tempNama[30];
int tempScore;
if ((in = fopen("score.txt", "rb")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
for (i = 0; i<5; i++){
fread(&p2, sizeof(p2), 1, in);
strcpy(score[i].nama, p2[i].nama);
score[i].score = p2[i].score;
}

for (i = 0; i<5; i++){


for (j = 0; j<5; j++){
if (score[i].score>score[j].score){
strcpy(tempNama, score[i].nama);
tempScore = score[i].score;
strcpy(score[i].nama, score[j].nama);
score[i].score = score[j].score;
strcpy(score[j].nama, tempNama);
score[j].score = tempScore;
}
}
}
gotoxy(10, 2); textcolor(14); cprintf("==<(H I G H - S C O R E)>==");
for (i = 0; i<5; i++){
gotoxy(15, 4 + i); printf("%d. %s \t %d", i + 1, score[i].nama,
score[i].score);
}
fclose(in);
return 0;
}
//================== ini adalah fungsi mengakhiri permainan ===================
int ending()
{
clrscr();
for (i = 0; i<12; i++){
gotoxy(1, 3); textcolor(i + 4); textbackground(0); cputs("
**
**
**
");
gotoxy(1, 4); textcolor(i + 4); textbackground(0); cputs(" ****
**** **
****** ******* **
** **
** ****** **
** ");
gotoxy(1, 5); textcolor(i + 4); textbackground(0); cputs("
**
*******
** **
** ** **
**
** **
** **
** ");
gotoxy(1, 6); textcolor(i + 4); textbackground(0); cputs("
**
**
** ******** **
** ****
** ** **
** **
** ");
gotoxy(1, 7); textcolor(i + 4); textbackground(0); cputs("
**
**
** **
** **
** ** **
****
**
** **
** ");
gotoxy(1, 8); textcolor(i + 4); textbackground(0); cputs("
**
**** **
** ******** **
** **
**
**
******** ****
");
gotoxy(1, 9); textcolor(i + 4); textbackground(0); cputs("
**
");
gotoxy(1, 10); textcolor(i + 4); textbackground(0); cputs("
**
");
Sleep(250);
}
PlaySound(TEXT("music.wav"), NULL, SND_FILENAME);
if (pilih == 1 || pilih == 3){
strupr(nama[0]);
gotoxy(25, 15); textcolor(14); cprintf("P O I N - A N D A <{ %d
}>", poin_1);
if (poin_1 == 0){
goto end;
}
if ((in = fopen("score.txt", "wb")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
for (i = 0; i<5; i++){
fread(&p2, sizeof(p2), 1, in);

strcpy(loker[i], p2[i].nama);
nilai[i] = p2[i].score;
}
for (i = 0; i<5; i++){
for (j = 0; j<5; j++){
if (strcmp(loker[j], nama[0]) == 0){
if (poin_1 >= nilai[j] || poin_1 <= nila
i[j]){
nilai[j] = nilai[j] + poin_1;
strcpy(loker[j], nama[0]);
goto a;
}
}
}
if (poin_1 >= nilai[i]){
for (j = 4; j >= i; j--){
nilai[j] = nilai[j - 1];
strcpy(loker[j], loker[j - 1]);
}
nilai[i] = poin_1;
strcpy(loker[i], nama[0]);
goto a;
}
}
a:
for (i = 0; i<5; i++){
p1[i].score = nilai[i];
strcpy(p1[i].nama, loker[i]);
fwrite(&p1, sizeof(p1), 1, in);
}
fclose(in);
}
if (pilih == 2){
strupr(nama[0]);
strupr(nama[1]);
if (poin_1 == 0 && poin_2 == 0){
goto end;
}
if (poin_1 >= poin_2){
gotoxy(30, 15); textcolor(14); cprintf("%s <{ %d }>", na
ma[0], poin_1);
if ((in = fopen("score.txt", "wb")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
for (i = 0; i<5; i++){
fread(&p2, sizeof(p2), 1, in);
strcpy(loker[i], p2[i].nama);
nilai[i] = p2[i].score;
}
for (i = 0; i<5; i++){
for (j = 0; j<5; j++){
if (strcmp(loker[j], nama[0]) == 0){
if (poin_1 >= nilai[j] || poin_1
<= nilai[j]){
nilai[j] = nilai[j] + po
in_1;
strcpy(loker[j], nama[0]
);
goto b1;

}
}
}
if (poin_1 >= nilai[i]){
for (j = 4; j >= i; j--){
nilai[j] = nilai[j - 1];
strcpy(loker[j], loker[j - 1]);
}
nilai[i] = poin_1;
strcpy(loker[i], nama[0]);
goto b1;
}
}
b1:
for (i = 0; i<5; i++){
p1[i].score = nilai[i];
strcpy(p1[i].nama, loker[i]);
fwrite(&p1, sizeof(p1), 1, in);
}
fclose(in);
}
if (poin_1 < poin_2){
gotoxy(30, 15); textcolor(14); cprintf("%s <{ %d }>", na
ma[1], poin_2);
if ((in = fopen("score.txt", "wb")) == NULL){
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
for (i = 0; i<5; i++){
fread(&p2, sizeof(p2), 1, in);
strcpy(loker[i], p2[i].nama);
nilai[i] = p2[i].score;
}
for (i = 0; i<5; i++){
for (j = 0; j<5; j++){
if (strcmp(loker[j], nama[1]) == 0){
if (poin_2 >= nilai[j] || poin_2
<= nilai[j]){
nilai[j] = nilai[j] + po
in_2;
strcpy(loker[j], nama[1]
);
goto b2;
}
}
}
if (poin_2 >= nilai[i]){
for (j = 4; j >= i; j--){
nilai[j] = nilai[j - 1];
strcpy(loker[j], loker[j - 1]);
}
nilai[i] = poin_2;
strcpy(loker[i], nama[1]);
goto b2;
}
}
b2:
for (i = 0; i<5; i++){
p1[i].score = nilai[i];
strcpy(p1[i].nama, loker[i]);

fwrite(&p1, sizeof(p1), 1, in);


}
fclose(in);
}
}
end:
printf("\n\n\n\n\t\t\t\t\t\t Press Anykey Back to Menu ");
getch();
reset();
menu();
return 0;
}
//======================= ini adalah fungsi reset data ========================
void reset()
{
for (i = 0; i<15; i++){
for (j = 0; j<15; j++){
papan1[i][j] = '\0';
papan2[i][j] = '\0';
}
}
poin_1 = 0;
poin_2 = 0;
play1 = 1;
play2 = 1;
int reset1[26] = { 10, 5, 5, 6, 10, 4, 5, 5, 10, 6, 6, 6, 5, 7, 10, 4, 3
, 7, 6, 6, 6, 4, 4, 3, 4, 3 };
int reset2[26] = { 10, 5, 5, 6, 10, 4, 5, 5, 10, 6, 6, 6, 5, 7, 10, 4, 3
, 7, 6, 6, 6, 4, 4, 3, 4, 3 };
for (i = 0; i<25; i++){
sedia1[i] = reset1[i];
sedia2[i] = reset2[i];
}
in = fopen("kata1.txt", "w");
fputs("kata\n", in);
fclose(in);
in = fopen("kata2.txt", "w");
fputs("kata\n", in);
fclose(in);
}

You might also like