Leave a comment

Listing Program Game Battle Dor dengan Game Engine Strawberry Prolog

Listing Program

% Game ini menceritakan tentang perang militer antara kesatuan infanteri dengan kavaleri

% Developer : ANDRI FIRMAN CAHYANTO

% ———————————BATTLE DOR—————————————————%

% ———————————ANDRI FIRMAN CAHYANTO—————————————-%

% ———————————3IA12/50412835———————————————–%

%———–deklarasi variable, impor gambar, dan pembuatan jendela permainan———%

?-

G_darah1:=350,

G_darah2:=200,

G_aksi_red:=0,

G_aksi_blue:=0,

G_level:=1,

G_life_red:=10,

G_life_blue:=10,

G_zero:=0,

G_bg is bitmap_image(“image//opening1.bmp”,_),

G_How is bitmap_image(“images//how2.bmp”,_),

G_Tentaranembak1 is bitmap_image(“image//Tentaranembak1.bmp”,_),

G_Tentaranunduk1 is bitmap_image(“image//Tentaranunduk1.bmp”,_),

G_Tentaraketembak1 is bitmap_image(“image//Tentaraketembak1.bmp”,_),

G_Tentaranembak2 is bitmap_image(“image//Tentaranembak2.bmp”,_),

G_Tentaranunduk2 is bitmap_image(“image//Tentaranunduk2.bmp”,_),

G_Tentaraketembak2 is bitmap_image(“image//Tentaraketembak2.bmp”,_),

G_Pelurubiru is bitmap_image(“image//pelurubiru.bmp”,_),

G_Pelurumerah is bitmap_image(“image//pelurumerah.bmp”,_),

G_Dorblue is bitmap_image(“image//dor_blue.bmp”,_),

G_Dorred is bitmap_image(“image//dor_red.bmp”,_),

G_Tembok is bitmap_image(“image//Tembok.bmp”,_),

G_Timeup is bitmap_image(“image//timeup.bmp”,_),

G_white is bitmap_image(“image//white.bmp”,_),

G_timeblock is bitmap_image(“image//timeblock.bmp”,_),

G_cleantime is bitmap_image(“image//cleantimeup.bmp”,_),

%——————————-SPLASH——————————–

%============================== TIMER ====================================%

window(G_splash2,_,window_splash2(_),”BATTLE DOR”,(150,50,800,500)).

window_splash2(paint):-

draw_bitmap(0,0,G_bg,_,_).

window_splash2(init):-

G_batas := 1,

G_waktu is set_timer(_,0.01,fungsi_timer).

fungsi_timer(end):-

text_out(350,300,print(“Loading : ” + G_batas)),

G_batas := G_batas +1,

(G_batas = 100 -> close_window(G_splash2),

window(G_form1,_,window1(_),”BATTLE DOR”,150,50,800,500)).

%—————————- WINDOW 1 ——————————%

window(G_form1,_,window1(_),”BATTLE DOR”,150,50,800,500).

window1(paint):-

draw_bitmap(0,0,G_bg,_,_),

fail.

window1(init):-

execute(“musik//bb.exe”),

button(_,_,mulai(_),”Start Game”,500,150,200,40),

button(_,_,help(_),”How To Play”,500,200,200,40),

button(_,_,about(_),”About Me”,500,250,200,40),

button(_,_,keluar(_),”Exit”,500,300,200,40),

fail.

keluar(press):-

execute(“musik\\gg.bat”),

message(“BATTLE DOR”, “Jangan Lupa Memainkannya lagi ya “,!),

close_window(G_form1).

about(press):-

shell_execute(“AboutMe.html”).

help(press):-

shell_execute(“help.html”).

mulai(press):-

window(G_form2,_,window2(_),”BATTLE DOR”,100,50,800,420),

close_window(G_form1).

%—————-menggambar posisi awal dengan menggunakan fungsi paint——————–

%—————-mendeklarasikan fungsi inisialisasi yang berisi menu dan timer———————

window2(paint):-

G_aksi_red:=0,

G_aksi_blue:=0,

G_life_red:=99,

G_life_blue:=99,

draw_bitmap( 0, 140, G_Tentaranunduk1, _, _),

draw_bitmap( 610, 140, G_Tentaranunduk2, _, _),

draw_bitmap( 170, 220, G_Tembok, _, _),

draw_bitmap( 550, 220, G_Tembok, _, _),

font(10,20,”Times New Roman”),

text_out(10, 20, “infantri”),

text_out(680, 20, “kalvaleri”),

pen(20,rgb(100,0,0)),

line(20,50,G_darah1,50),%——-darah infantri

line(G_darah2+200,50,750,50),%———– kalvaleri

fail.

window2(init):-

menu( pop_up, _, _, menu_pilihan(_),”&Pilihan”),

menu( pop_up, G_Menu, _, menu_level(_), “&Level”),

menu( normal, _, _, menu_bantuan(_), “&Help”),

menu( normal, _, _, menu_tentang(_), “&About”),

message(“BATTLE DOR”, “Untuk Memulai Tekan Pilihan > Mulai”,!).

window2(close):-

execute(“musik\\gg.bat”),

close_window(G_form2).

menu_pilihan(init):-

menu(normal,_,_,mulai_game(_),”&Mulai”),

menu(normal,_,_,main_menu(_),”&Main Menu”),

menu(normal,_,_,menu_exit(_),”&Exit”).

menu_exit(press):-

message(“”, “Sering Main yak “,!),

close_window(_).

main_menu(press):-

close_window(G_form2),

window(G_form1,_,window1(_),”BATTLE DOR”,150,50,800,500).

menu_level(init):-

menu(normal,_,_,mudah(_),”&Easy”),

menu(normal,_,_,normal(_),”&Normal”),

menu(normal,_,_,susah(_),”&Hard”).

menu_bantuan(press):-

shell_execute(“help.html”).

menu_tentang(press):-

shell_execute(“AboutMe.html”).

%—-mendeklarasikan inisialisasi per level (mudah, normal, dan susah)——-%

%———————inisiasi level default (mudah) ————————%

mulai_game(press):-

G_time is set_timer(_,1,time_func),

fail.

%–Penerapan untuk level mudah

mudah(press):-

message(“level”,”Anda memilih level mudah”,i),

G_aksi_red:=0,

G_aksi_blue:=0,

G_life_red:=99,

G_life_blue:=99,

G_level:=1,

G_time:=30,

draw_bitmap( 0, 140, G_Tentaranunduk1, _, _),

draw_bitmap( 610, 140, G_Tentaranunduk2, _, _),

draw_bitmap( 170, 220, G_Tembok, _, _),

draw_bitmap( 550, 220, G_Tembok, _, _).

%– Penerapan untuk level normal

normal(press):-

message(“level”,”Anda memilih level normal”,i),

G_aksi_red:=0,

G_aksi_blue:=0,

G_life_red:=99,

G_life_blue:=99,

G_level:=2,

G_time:=30,

draw_bitmap( 0, 140, G_Tentaranunduk1, _, _),

draw_bitmap( 610, 140, G_Tentaranunduk2, _, _),

draw_bitmap( 170, 220, G_Tembok, _, _),

draw_bitmap( 550, 220, G_Tembok, _, _).

%– Penerapan untuk level susah

susah(press):-

message(“level”,”Anda memilih level susah”,i),

G_aksi_red:=0,

G_aksi_blue:=0,

G_life_red:=99,

G_life_blue:=99,

G_level:=3,

G_time:=30,

draw_bitmap( 0, 140, G_Tentaranunduk1, _, _),

draw_bitmap( 610, 140, G_Tentaranunduk2, _, _),

draw_bitmap( 170, 220, G_Tembok, _, _),

draw_bitmap( 550, 220, G_Tembok, _, _).

%————-menjalankan fungsi timer—————-%

time_func(end):-

G_time=0->

G_time:=0

else

G_time:=G_time-1,

T:=printq(G_time),

font(20,40,”Arial”),

text_out(350,280,T),

%—Penerapan fungsi AI dari komputer dalam satuan detik

(G_time=29->

G_level=3-> musuhcek(_)),

(G_time=29->

G_level=2-> musuhnunduk(_)),

(G_time=29->

G_level=1-> musuhberdiri(_)),

(G_time=28->

G_level=3-> musuhcek(_)),

(G_time=28->

G_level=2-> musuhberdiri(_)),

(G_time=28->

G_level=1-> musuhberdiri(_)),

(G_time=27->

G_level=3-> musuhcek(_)),

(G_time=27->

G_level=2-> musuhcek(_)),

(G_time=27->

G_level=1-> musuhnunduk(_)),

(G_time=26->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=26->

G_level=2-> musuhcek(_)),

(G_time=26->

G_level=1-> musuhcek(_)),

(G_time=25->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=25->

G_level=2-> musuhcek(_)),

(G_time=25->

G_level=1-> musuhberdiri(_)),

(G_time=25->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=25->

G_level=2-> musuhcek(_)),

(G_time=25->

G_level=1-> musuhberdiri(_)),

(G_time=24->

G_level=3-> musuhnunduk(_)),

(G_time=24->

G_level=2-> musuhcek(_)),

(G_time=24->

G_level=1-> musuhberdiri(_)),

(G_time=23->

G_level=3-> musuhcek(_)),

(G_time=23->

G_level=2-> musuhcek(_)),

(G_time=23->

G_level=1-> musuhberdiri(_)),

(G_time=22->

G_level=3-> musuhcek(_)),

(G_time=22->

G_level=2-> musuhcek(_)),

(G_time=22->

G_level=1-> musuhberdiri(_)),

(G_time=21->

G_level=3-> musuhnunduk(_)),

(G_time=21->

G_level=2-> musuhcek(_)),

(G_time=21->

G_level=1-> musuhberdiri(_)),

(G_time=20->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=20->

G_level=2-> musuhcek(_)),

(G_time=20->

G_level=1-> musuhberdiri(_)),

(G_time=19->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=19->

G_level=2-> musuhcek(_)),

(G_time=19->

G_level=1-> musuhberdiri(_)),

(G_time=18->

G_level=3-> musuhcek(_)),

(G_time=18->

G_level=2-> musuhcek(_)),

(G_time=18->

G_level=1-> musuhberdiri(_)),

(G_time=17->

G_level=3-> musuhcek(_)),

(G_time=17->

G_level=2-> musuhcek(_)),

(G_time=17->

G_level=1-> musuhberdiri(_)),

(G_time=16->

G_level=3-> musuhnunduk(_)),

(G_time=16->

G_level=2-> musuhcek(_)),

(G_time=16->

G_level=1-> musuhberdiri(_)),

(G_time=15->

G_level=3-> musuhcek(_)),

(G_time=15->

G_level=2-> musuhcek(_)),

(G_time=15->

G_level=1-> musuhberdiri(_)),

(G_time=14->

G_level=3-> musuhcek(_)),

(G_time=14->

G_level=2-> musuhcek(_)),

(G_time=14->

G_level=1-> musuhberdiri(_)),

(G_time=13->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=13->

G_level=2-> musuhcek(_)),

(G_time=13->

G_level=1-> musuhberdiri(_)),

(G_time=12->

G_level=3-> musuhnunduk(_)),

(G_time=12->

G_level=2-> musuhcek(_)),

(G_time=12->

G_level=1-> musuhberdiri(_)),

(G_time=11->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=11->

G_level=2-> musuhcek(_)),

(G_time=11->

G_level=1-> musuhberdiri(_)),

(G_time=10->

G_level=3-> musuhnunduk(_)),

(G_time=10->

G_level=2-> musuhcek(_)),

(G_time=10->

G_level=1-> musuhberdiri(_)),

(G_time=9->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=9->

G_level=2-> musuhcek(_)),

(G_time=9->

G_level=1-> musuhberdiri(_)),

(G_time=8->

G_level=3-> musuhnunduk(_)),

(G_time=8->

G_level=2-> musuhcek(_)),

(G_time=8->

G_level=1-> musuhberdiri(_)),

(G_time=7->

G_level=3-> musuhcek(_)),

(G_time=7->

G_level=2-> musuhcek(_)),

(G_time=7->

G_level=1-> musuhberdiri(_)),

(G_time=6->

G_level=3-> musuhcek(_)),

(G_time=6->

G_level=2-> musuhcek(_)),

(G_time=6->

G_level=1-> musuhberdiri(_)),

(G_time=5->

G_level=3-> musuhcek(_)),

(G_time=5->

G_level=2-> musuhcek(_)),

(G_time=5->

G_level=1-> musuhberdiri(_)),

(G_time=4->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=4->

G_level=2-> musuhcek(_)),

(G_time=4->

G_level=1-> musuhberdiri(_)),

(G_time=3->

G_level=3-> musuhberdiri(_), musuhcek(_)),

(G_time=3->

G_level=2-> musuhcek(_)),

(G_time=3->

G_level=1-> musuhberdiri(_)),

(G_time=2->

G_level=3-> musuhnunduk(_)),

(G_time=2->

G_level=2-> musuhcek(_)),

(G_time=2->

G_level=1-> musuhberdiri(_)),

(G_time=1->

G_level=3-> musuhcek(_)),

(G_time=1->

G_level=2-> musuhcek(_)),

(G_time=1->

G_level=1-> musuhberdiri(_)),

(G_time=0 ->

G_time:=0,

draw_bitmap( 310, 20, G_Timeup, _, _),

(G_life_bluemessage(“Kalah”,”Anda kalah, Sebaiknya latih dulu cara respon anda ya”,i),beep(“sound//kalah”)),

(G_life_blue>G_life_red->message(“Menang”,”Selamat Anda Menang, kemampuan anda untuk menembak begitu hebat!”,i),beep(“sound//clap”)),

(G_life_blue=G_life_red->message(“Seri”,”Seimbang, , latih terus kemampuan nembak anda”,i),beep(“sound//clap”)),

close_window(_)).

%–Statement untuk memberikan fungsi respon pada komputer

musuhberdiri(_):-

G_aksi_red:=1,

draw_bitmap( 610, 150, G_Tentaranembak2, _, _).

musuhnunduk(_):-

G_aksi_red:=0,

draw_bitmap( 610, 140, G_Tentaranunduk2, _, _).

musuhcek(_):-

G_aksi_blue=1->

G_aksi_red:=1,

draw_bitmap( 610, 150, G_Tentaranembak2, _, _),

wait(0.1),

draw_bitmap(550,197,G_Dorred,_,_),

G_aksi_red:=2,

afterfire_red(_).

%——————-peluru keluar dari senapan————–

afterfire_blue(_):-

wait(0.1),

beep(“sound//shoot”),

draw_bitmap( 360, 195, G_Pelurubiru, _, _),

efektembak1(_),

wait(0.2),

draw_bitmap( 0, 140, G_Tentaranunduk1, _, _),

draw_bitmap( 168, 192, G_white, _, _),

G_aksi_blue:=0.

afterfire_red(_):-

wait(0.1),

beep(“sound//shoot2”),

draw_bitmap( 370, 192, G_Pelurumerah, _, _),

efektembak2(_),

wait(0.2),

draw_bitmap( 610, 140, G_Tentaranunduk2, _, _),

draw_bitmap( 295, 193, G_white, _, _),

G_aksi_red:=0.

%——————Efek Tembak (kena atau tidak)—————————————–

efektembak1(_):-

G_aksi_red=1->

wait(0.2),

draw_bitmap( 610, 150, G_Tentaraketembak2, _, _),

draw_bitmap( 240, 192, G_white, _, _),

wait(1),

draw_bitmap( 610, 140, G_Tentaranunduk2, _, _),

G_life_red:=G_life_red-5,

G_darah2:=G_darah2+30, %<<<<

pen(20,rgb(255,128,128)),

line(G_darah2+200,50,400,50),%<<<< G_aksi_red:=0. efektembak2(_):- G_aksi_blue=1->

wait(0.2),

draw_bitmap( 0, 150,G_Tentaraketembak1, _, _),

draw_bitmap( 235, 192, G_white, _, _),

wait(1),

draw_bitmap( 0, 140,G_Tentaranunduk1, _, _),

G_life_blue:=G_life_blue-1,

G_darah1:=G_darah1-30, %<<<<

pen(20,rgb(255,128,128)),

line(G_darah1,50,350,50),%<<<< G_aksi_blue:=0. %——————membuat tentara player berdiri, menunduk, menembak——————— window2(key_down(38,_)):- G_aksi_blue:=1, draw_bitmap( 0, 150,G_Tentaranembak1, _, _). window2(key_down(40,_)):- wait(0.8), G_aksi_blue:=0, draw_bitmap( 0, 140, G_Tentaranunduk1, _, _). window2(key_down(32,_)):- G_aksi_blue=1-> draw_bitmap(165,197,G_Dorblue,_,_),

G_aksi_blue:=2,

afterfire_blue(_),

wait(0.6).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

wawan's blog dunitro

tempat belajar dan mempelajari

andrifirmanc

A fine WordPress.com site

%d bloggers like this: