0% found this document useful (0 votes)
18 views3 pages

Script

This document contains code for a game with the following elements: - A BOLA object that moves around the screen bouncing off walls and a PERSEGI object, with its speed and direction randomly changing when it passes the bottom of the screen. - A PERSEGI object that can be moved left and right using keyboard controls to try to hit the BOLA object. - A KOTAK object that detects hits from the BOLA and plays an animation, increasing the score when fully animated. - Score and lives (hidup) variables that track progress, with the game restarting when lives are lost.

Uploaded by

iklan_anda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Script

This document contains code for a game with the following elements: - A BOLA object that moves around the screen bouncing off walls and a PERSEGI object, with its speed and direction randomly changing when it passes the bottom of the screen. - A PERSEGI object that can be moved left and right using keyboard controls to try to hit the BOLA object. - A KOTAK object that detects hits from the BOLA and plays an animation, increasing the score when fully animated. - Score and lives (hidup) variables that track progress, with the game restarting when lives are lost.

Uploaded by

iklan_anda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

15.

BOLA
onClipEvent(load){
dir=Math.round(Math.random()*1);
speed=10;
if(dir==1){
var Ang=45;
}else {
var Ang=135;
}
xspeed=speed*Math.cos((Ang)*Math.PI/180);
yspeed=speed*Math.sin((Ang)*Math.PI/180);
}
onClipEvent(enterFrame){
this._x+=xspeed;
this._y+=yspeed;
if((this._x<=5)||(this._x>=295)){
xspeed=-xspeed;
}
if((this._y<=5)||(_root.persegi.hitTest(this))){
yspeed=-yspeed;
removeMovieClip(this);
}
if(this._y>300){
_root.hidup-=1;
if(_root.hidup==0){
_root.play();
}
_x=150;
_y=100;
dir=Math.round(Math.random()*1);
speed=10;
if(dir==1){
var Ang=45;
}else{
var Ang=135;
}
xspeed=speed*Math.cos((Ang)*Math.PI/180);
yspeed=speed*Math.sin((Ang)*Math.PI/180);
}
}

14. PERSEGI
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
if(this._x<=275){
this._x+=10
}
}
if(Key.isDown(Key.LEFT)){
if(this._x>=25){
this._x-=10;
}
}
}
17. KOTAK
onClipEvent(enterFrame){
if((this.hitTest(_root.bola))){
_root.bola.yspeed=-_root.bola.yspeed;
this.play();
}
}
23. Kotak frame
stop();
27. Kotak frame
stop();
_root.score+=10;
if(_root.score==160){
_root.play();
}
15. Score
stop();
var score=0;
var hidup=5;
18. Score
stop();
scoreAkhir=score;
if(_root.hidup==0){

gameOver="<p align='center'> anda kalah!!! <br> nilai akhir anda adalah:</p>";


}

You might also like