Anda di halaman 1dari 15

Lampiran 2 Listing Program 1. Scirpt awal frame fscommand("fullscreen",true) 2.

Script membuat variable shared object untuk highscore //membuat variable shared object skortinggi=SharedObject.getLocal("game_data"); //menetukan skor awal skor1=0; skor2=0 skor3=0; 3.Script frame menu utama stop(); Mouse.show(); energi=100; musik.stop(); onEnterFrame();{ hati=new Sound; hati.attachSound("ding"); win=new Sound; win.attachSound("win"); musik=new Sound; musik.attachSound("BGM"); musik.setVolume(60); musik.start(1,200); tabrak=new Sound; tabrak.attachSound("tabrak"); } clearInterval(val); 4. Script Tombol Main on (release) { nextFrame(); } 5. Script Tombol Tentang on (release) { gotoAndStop("about"); } 6. Script Tombol Keluar on (release) { fscommand("quit"); }

73

7. Script frame halaman input nama namapemain = player;

8. Script tombol kembali pada halaman input nama on (release) { gotoAndStop("cover"); } 9. Script tombol main pada halaman input nama on (release) { gotoAndStop("satu",1); } 10.Script frame about stop(); clearInterval(val); 11. Script frame petunjuk misi satu stop(); win.stop(); musik.start(1,10); energi = 100; rumah = 7; skor1=0; skor2=0; skor3=0; 12.Script tombol Jalankan misi on (release) { nextFrame(); } 13. Script frame pada halaman game misi satu stop(); skor1=0; akhir = true; speed_bom = random(20)+8; speed_musuh = random(10)+20; speed_hati = random(9)+20; fps = 0; waktu = true; detik = 30; //mengilangkan mc hancur

74

hancur1._visible = 0; hancur2._visible = 0; hancur3._visible = 0; hancur4._visible = 0; hancur5._visible = 0; hancur6._visible = 0; hancur7._visible = 0; onEnterFrame = function () { //menambahkan angka 0 pada second jika detik kurang dari 10 if (detik<10) { second = "0"+detik; } else { second = detik; } if (waktu) { //fps ditambah 1 secara terus menerus fps++; //jika fps sama dengan 20 if (fps == 20) { //fps menjadi 0 fps = 0; //detik dikurangi 1 detik -= 1; } if (detik<0) { //menuju frame hasil1 gotoAndStop("hasil1"); //menghapus interval Int clearInterval(Int); //menghapus interval ter clearInterval(ter); //menghapus interval val clearInterval(val); } } if (akhir) { if (Key.isDown(Key.SPACE)) { gotoAndPlay("result", 1); clearInterval(val); } } }; //ketika mc darah memasuki frame darah.onEnterFrame = function() { //xscale mc darah adalah energi

75

this._xscale = energi; //jika energi kurang dari 50 if (energi<50) { //mc nyawa ke frame 2 nyawa.gotoAndStop(2); //jika tidak } else { //mc nyawa ke frame 1 nyawa.gotoAndStop(1); } }; physics = 0.30; kecepatanx = 0; kecepatany = 0; pemain.onEnterFrame = function() { kecepatanx = ((_root._xmouse-this._x)*physics)+(kecepatanx*physics); kecepatany = ((_root._ymouse-this._y)*physics)+(kecepatany*physics); this._x += kecepatanx; this._y += kecepatany; if (this._x>_xmouse) { pemain.gotoAndPlay("kiri"); } else { pemain.gotoAndPlay("kanan"); } }; function buathati() { animasi_hati = attachMovie("hati", "hati"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:random(450), _y:350}); animasi_hati.onEnterFrame = function() { this._y -= speed_hati; if (this.hitTest(pemain) && energi<100) { energi += 10; hati.start(0, 1); this.removeMovieClip(); } if (this.hitTest(pemain) && energi>=100) { skor1 += 10; hati.start(0, 1); this.removeMovieClip(); } }; } function buatmusuh() { //menempatkan movie clip berlinkage bom ke stage dengan posisi x di koordinat -50 dan posisi y di koordinat acak 310

76

animasi_musuh = attachMovie("musuh", "musuh"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:-50, _y:random(310)}); animasi_musuh.onEnterFrame = function() { //menentukan kecepatan perpindahan x this._x += speed_musuh; //jika ini menabrak mc pemain maka if (this.hitTest(pemain)) { //energi berkurang 10 energi -= 10; //sound tabrak dimainkan tabrak.start(0, 1); } //jika energi kurang dari 0 if (energi<0) { //mc ini ke dan stop di frame 2 this.gotoAndStop(2); //pergi ke scene result, frame 1 gotoAndStop("result", 1); //menghentikan interval clearInterval(Int); clearInterval(ter); clearInterval(val); } }; } function buatbom() { //menempatkan movie clip berlinkage bom ke stage dengan posisi x di koordinat acak 300 dan posisi y di koordinat -50 animasi_bom = attachMovie("bom", "bom"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:random(450), _y:30}); animasi_bom.onEnterFrame = function() { //kecepatan turun this._y += speed_bom; //jika menabrak mc pemain if (this.hitTest(pemain)) { //mc ini dihapus this.removeMovieClip(); //mc asep pada pemain di mainkan dari frame 2 pemain.asep.gotoAndPlay(2); //skor bertambah 10 skor1 = Number(skor1)+10; } //jika menabrak mc h1 maka if (this.hitTest(h1)) {

77

h1.gotoAndPlay(2); hancur1._visible = 1; hancur1.gotoAndPlay(1); this.removeMovieClip(); rumah = Number(rumah)-1; } if (this.hitTest(h2)) { h2.gotoAndPlay(2); hancur2._visible = 1; hancur2.gotoAndPlay(1); this.removeMovieClip(); rumah = Number(rumah)-1; } if (this.hitTest(h3)) { h3.gotoAndPlay(2); hancur3._visible = 1; hancur3.gotoAndPlay(1); this.removeMovieClip(); rumah = Number(rumah)-1; } if (this.hitTest(h4)) { h4.gotoAndPlay(2); hancur4._visible = 1; hancur4.gotoAndPlay(1); this.removeMovieClip(); rumah = Number(rumah)-1; } if (this.hitTest(h5)) { h5.gotoAndPlay(2); hancur5._visible = 1; hancur5.gotoAndPlay(1); this.removeMovieClip(); rumah = Number(rumah)-1; } if (this.hitTest(h6)) { h6.gotoAndPlay(2); hancur6._visible = 1; hancur6.gotoAndPlay(1); this.removeMovieClip(); rumah = Number(rumah)-1; } if (this.hitTest(h7)) { h7.gotoAndPlay(2); hancur7._visible = 1; hancur7.gotoAndPlay(1);

78

this.removeMovieClip(); rumah = Number(rumah)-1; } if (this.hitTest(line)) { this.removeMovieClip(); } //jika posisi y movieclip ini lebih dari atau sama dengan 410 if (this._y>=390) { //hapus movie clip ini removeMovieClip(this); } if (rumah == 0) { gotoAndStop("result", 1); clearInterval(Int); clearInterval(ter); clearInterval(val); } }; } //jalankan function buatbom setiap hitungan 450 Int = setInterval(buatbom, 700); ter = setInterval(buatmusuh, 3000); val = setInterval(buathati, 5000); 14. Script pada movieclip rumah frame 1 stop(); 15. Script pada movieclip rumah frame 2 this.unloadMovie(); 16.Script pada halaman misi satu sukses stop(); waktu=false; akhir=false; bonus1=rumah*100; total1=bonus1+skor1; Mouse.show(); musik.stop(); win.start(1,20); 17. Script pada tombol akhiri misi on (release) { gotoAndStop("result",1); }

79

18. Script pada tombol misi selanjutnya on (release) { gotoAndPlay("dua",1); } 19.Script pada halaman petunjuk misi dua on (release) { gotoAndPlay("dua",1); } 20. Script pada halaman game misi dua stop(); akhir = true; jumlah = 2; energi = 100; skor2 = 0; time = 30; detik = true; fps = 0; i = 1; ufololos = 0; speed_hati = random(9)+20; win.stop(); musik.start(1, 10); onEnterFrame = function () { waktu = time; if (time<10) { waktu = "0"+time; } if (detik) { fps++; if (fps == 20) { time -= 1; fps = 0; } } if (waktu<=0) { gotoAndStop("hasil2"); clearInterval(val); } if (_root.ufololos<=5) { _root.bonus2 = 1000; } else if (ufololos>5) { _root.bonus2 = 0; }

80

if (_root.ufololos>=10) { gotoAndStop("result",1); clearInterval(val); } if (akhir) { if (Key.isDown(Key.SPACE)) { gotoAndPlay("result", 1); clearInterval(val); } } }; for (i=1; i<=jumlah; i++) { _root.ufo.duplicateMovieClip("ufonew"+i, i+700); } darah.onEnterFrame = function() { this._xscale = energi; if (energi<0) { gotoAndStop("result", 1); clearInterval(val); } }; function buathati() { animasi_hati = attachMovie("hati", "hati"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:random(450), _y:350}); animasi_hati.onEnterFrame = function() { this._y -= speed_hati; if (this.hitTest(pesawat) && energi<100) { energi += 10; hati.start(0, 1); this.removeMovieClip(); } if (this.hitTest(pesawat) && energi>=100) { skor1 += 10; hati.start(0, 1); this.removeMovieClip(); } }; } val = setInterval(buathati, 5000); 21.Script pada misil pesawat GaruJago onClipEvent (load) { misilspeed = 20; this._x = _root.pesawat._x-10;

81

this._y = _root.pesawat._y+10; } onClipEvent (enterFrame) { this._x = this._x+misilspeed; if (this._x>550) { removeMovieClip(this); } if (this.hitTest(_root.ufo)) { _root.ufo.gotoAndPlay(3); _root.skor2 += 10; this.removeMovieClip(); } for (i=1; i<=_root.jumlah; i++) { if (this.hitTest(_root["ufonew"+i])) { _root["ufonew"+i].gotoAndPlay(3); _root.skor2 += 10; this.removeMovieClip(); } } } 22. Script pada pesawat GaruJago onClipEvent(load) { Mouse.hide(); startDrag(this,true); _root.misil._visible=0; jumlahmisil=1; } onClipEvent(mouseDown) { jumlahmisil++; duplicateMovieClip(_root.misil,"misil"+jumlahmisil,jumlahmisil); _root.misil._visible=1; } 23.Script pada UFO onClipEvent (load) { function posisi() { this._x = 600; this._y = random(200)+50; ufospeed = random(20)+5; } posisi(); } onClipEvent (enterFrame) { if (random(20) == 11) {

82

this._x = this._x-ufospeed-_root.BG.awan; } else { this._x = this._x-ufospeed; } if (this.hitTest(_root.pesawat)) { this.gotoAndPlay(3); _root.energi -= 5; } if (this.hitTest(_root.line)) { _root.ufololos += 1; posisi(); } } 24. Script pada halaman misi dua sukses stop(); Mouse.show(); musik.stop(); win.start(1, 20); total2 = bonus2+skor2; detik = false; akhir=false; time =10; 25. Script tombol misi selanjutnya on (release) { gotoAndPlay("tiga",1); } 26. Script pada halaman game misi tiga energi = 100; akhir=true; energimusuh = 100; jumlah = 1; speed_roket = 10; jumlah = 5; skor3 = 0; win.stop(); musik.start(1, 10); speed_hati = random(9)+20; onEnterFrame = function () { if (akhir) { if (Key.isDown(Key.SPACE)) { gotoAndPlay("result", 1); clearInterval(val);

83

} } }; darahman.onEnterFrame = function() { this._xscale = energi; if (energi<=0) { gotoAndStop("result", 1); clearInterval(val); } }; darahUFO.onEnterFrame = function() { this._xscale = energimusuh; if (energimusuh<=0) { gotoAndStop("result", 2); clearInterval(val); } }; for (i=1; i<=jumlah; i++) { _root.roket.duplicateMovieClip("roketnew"+i, i+700); } function buathati() { animasi_hati = attachMovie("hati", "hati"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:random(450), _y:350}); animasi_hati.onEnterFrame = function() { this._y -= speed_hati; if (this.hitTest(pesawat) && energi<100) { energi += 10; hati.start(0, 1); this.removeMovieClip(); } if (this.hitTest(pesawat) && energi>=100) { skor1 += 10; hati.start(0, 1); this.removeMovieClip(); } }; } val = setInterval(buathati, 5000); 27. Script pada pesawat GaruJago halaman game misi tiga onClipEvent (load) { Mouse.hide(); startDrag(this, true); _root.misil._visible = 0; jumlahmisil = 1;

84

} onClipEvent (mouseDown) { jumlahmisil++; duplicateMovieClip(_root.misil, "misil"+jumlahmisil, jumlahmisil); _root.misil._visible = 1; } onClipEvent (enterFrame) { if (this.hitTest(_root.UFO.raja)) { _root.energi -= 10; } } 28. Script pada misil pesawat GaruJago onClipEvent (load) { misilspeed = 20; this._x = _root.pesawat._x-10; this._y = _root.pesawat._y+10; } onClipEvent (enterFrame) { this._x = this._x+misilspeed; if (this._x>550) { removeMovieClip(this); } if (this.hitTest(_root.UFO.raja)) { _root.energimusuh -=0.5; _root.skor3 += 10; this.removeMovieClip(); updateAfterEvent(); } } 29. Script Roket Raja UFO onClipEvent (load) { function posisiroket() { this._x = _root.UFO.raja._x-10; this._y = _root.UFO.raja._y; cepatroket = random(20)+5; } posisiroket(); } onClipEvent (enterFrame) { if (random(20) == 11) { this._x = this._x-cepatroket-_root.BG.awan; } else { this._x = this._x-cepatroket;

85

} if (this._x<-1) { posisiroket(); } if (this.hitTest(_root.pesawat)) { this.gotoAndPlay(2); _root.energi -= 5; } } 30.Script pada halaman misi gagal stop(); Mouse.show(); ufololos=0; score = false; rumah = false; waktu = false; detik = false; akhir = false; 31. Script tombol main lagi on (release) { gotoAndPlay("satu",1); } 32.Script pada halaman misi sukses stop(); Mouse.show(); clearInterval(val); akhir=false; musik.stop(); win.start(1, 20); stop(); totalskor = total1+total2+skor3; if (skortinggi.data.pemenang == undefined) { skortinggi.data.pemenang = "Super Man Tap"; } if (skortinggi.data.pemenang != null) { pemenang = skortinggi.data.pemenang; } if (skortinggi.data.nilaitinggi == undefined) { skortinggi.data.nilaitinggi = 0; } if (skortinggi.data.nilaitinggi != null) { highscore = skortinggi.data.nilaitinggi;

86

} if (totalskor>highscore) { skortinggi.data.pemenang = _root.player; skortinggi.data.nilaitinggi = totalskor; highscore = totalskor; pemenang = _root.player; } 33. Script tombol menu utama on (release) { gotoAndPlay("coverinfo","cover"); }

87

Anda mungkin juga menyukai