Saturday, June 13, 2015

Listing Program


Nama  : ERNY RAHMAWATI
NPM    : 52412546
Kelas   : 3IA12


LISTING PROGRAM
?-
  G_X=10, G_Y=5, G_score:=0, G_waktu:=201,
  X1 is 95*G_X+8, Y1 is 95*G_Y+28,
  retractall(ico(_,_,_)),
  set(click(1|_)),
  add_icon2("gambar\\c1.ico"),
  add_icon2("gambar\\c2.ico"),
  add_icon2("gambar\\c3.ico"),
  add_icon2("gambar\\c4.ico"),
  add_icon2("gambar\\c5.ico"),
  add_icon2("gambar\\c6.ico"),
  add_icon2("gambar\\c7.ico"),
  add_icon2("gambar\\c8.ico"),
  add_icon2("gambar\\c9.ico"),
  add_icon2("gambar\\c10.ico"),
  add_icon2("gambar\\c11.ico"),
  add_icon2("gambar\\c12.ico"),
  add_icon2("gambar\\c13.ico"),
  add_icon2("gambar\\c14.ico"),
  add_icon2("gambar\\c15.ico"),
  add_icon2("gambar\\c16.ico"),
  add_icon2("gambar\\c17.ico"),
  add_icon2("gambar\\c18.ico"),
  add_icon2("gambar\\c19.ico"),
  add_icon2("gambar\\c20.ico"),
  add_icon2("gambar\\c21.ico"),
  add_icon2("gambar\\c22.ico"),
  add_icon2("gambar\\c23.ico"),
  add_icon2("gambar\\c24.ico"),
  add_icon2("gambar\\c25.ico"),
  window(G_layarutama, _, win_utama(_), "Mencocoki Gambar", 10, 10, 1200, 520),
  beep("sound\\opening.wav").

win_utama(init):-
button(_,_,blayargame(_),"Mulai Permainan",50,50,150,50),
button(_,_,blayarabout(_),"Tentang",50,110,150,50),
button(_,_,blayarhelp(_),"Petunjuk",50,170,150,50),
button(_,_,blayarexit(_),"Exit",50,360,150,50).

win_utama(paint):-
G_bg is bitmap_image("gambar\\bgutama.bmp",_),         
draw_bitmap(0,0,G_bg,_,_).

blayarabout(press):-
beep("sound\\tombol.wav"),
message("About","Nama      : ERNY RAHMAWATI\nNPM           : 52412546\nKelas   : 3IA12",_).

blayarhelp(press):-
beep("sound\\tombol.wav"),
message("Petunjuk","Untuk memulai permainan silahkan klik menu Mulai Permainan,\nsetelah menekannya maka kamu diharuskan mencari pasangan (gambar yang sama) dari setiap gambar yang terbuka dengan cara mengklik pada kotak yang tersedia,\ncarilah pasangan gambar tersebut secepat mungkin,\nsetiap menemukan pasangan gambar kamu mendapatkan score 4.\nKamu akan menang jika mencapai score 100 sebelum waktu habis.",_).

blayarexit(press):-
beep("sound\\lose.wav"),
close_window(G_layarutama).

blayargame(press):-
close_window(G_layarutama),
beep("sound\\tombol.wav"),
window(G_layargame, _, win_func(_), "Mencocoki Gambar", 10, 10, 1200, 520),
G_timer is set_timer(_,1,time_func).

win_func(paint) :-
  G_bg is bitmap_image("gambar\\bggame.bmp",_),        
  draw_bitmap(0,0,G_bg,_,_),
  pen(2, rgb(55, 195, 235)),
  putVline,
  for(X, 1, G_X),
  line(95*X, 0, 95*X, 95*G_Y),
  fail.
putVline:-
  for(Y,1,G_Y),
  line(0,95*Y,95*G_X,95*Y).
  fail.
putVline.

win_func(mouse_click(X, Y)) :-
  click(C|_),
  mouse_click(X, Y, C).
mouse_click(X, Y, 1):-
  X1 is X//95,
  Y1 is Y//95,
  ico(X1,Y1,Ico),
  X2 is X1*95 +15,
  Y2 is Y1*95 +15,
  icon( H, _, fail(_), Ico, X2, Y2),
  set(click(2, H, Ico, X1, Y1)).
mouse_click(X, Y, 2):-
  X1 is X//95,
  Y1 is Y//95,
  click(_, H1, Ico1, X3, Y3),
  (X1\=X3; Y1\=Y3),
  ico(X1,Y1,Ico2),
  X2 is X1*95 +15,
  Y2 is Y1*95 +15,
  icon( H2, _, fail(_), Ico2, X2, Y2),
  if_equal(Ico1, Ico2, H1, H2).
mouse_click(X, Y, 3):-
  click(_, H1, H2|_),
  close_window(H1),
  close_window(H2),
  set(click(1|_)).
if_equal(Ico1, Ico2, H1, H2) :-
  Ico1=Ico2,
  set(click(1|_)),
  G_score:=G_score+4,
  S:= printq(G_score),
  text_out(1030,310,S),
  message("Score", "Score kamu "+S, _),
  (G_score=100-> kill_timer(_, G_timer), beep("sound\\opening.wav"), message("Score Complate","Kamu Menang!!",i), close_window(G_layargame)).
if_equal(Ico1, Ico2, H1, H2) :-
  set(click(3, H1, H2|_)).
add_icon(Ico):-
  X is random(G_X),
  Y is random(G_Y),
  not(ico(X,Y,_)),
  assert(ico(X,Y,Ico)), !.
add_icon(Ico):-
  add_icon(Ico).
add_icon2(Ico):-
  add_icon(Ico),
  add_icon(Ico).

time_func(end):-
            G_waktu:=G_waktu-1,
            W:= printq(G_waktu),
            font(28,60,"Times New Roman"),
            text_out(1030,130,W),
            (G_waktu=0->  kill_timer(_, G_timer),beep("sound\\lose.wav"),
     message("Waktu Habis","Kamu Kurang Cepat!!",_), close_window(G_layargame)).

No comments:

Post a Comment