You are on page 1of 4

code as2.

txt
// Menggerakkan player

_root.player.onEnterFrame =
function() {
if (Key.isDown(Key.LEFT)) {//
menggerakan kekiri saat tombol kiri
dikeyboard ditekan
this._x -= 10;

}
if (Key.isDown(Key.RIGHT)) {//
menggerakan kekanan saat tombol
kanan dikeyboard ditekan
this._x += 10;

}
if (this.hitTest(_root.kanan)) {//
saat player menyentuh tembok kanan

this._x -= 10;
}

Page 1
code as2.txt
if (this.hitTest(_root.kiri)) {//
saat player menyentuh tembok kiri

this._x += 10;
}
};

speedx = 7;
speedy = 7;
awalx = bola._x;

awaly = bola._y;

// Menggerakkan bola
_root.bola.onEnterFrame = function()
{
this._x += speedx;
this._y += speedy;

if (this.hitTest(_root.player)) {//
ketika bola menyentuh player

Page 2
code as2.txt
speedy = -speedy;
}
if (this.hitTest(_root.kanan)) {//
ketika bola menyentuh temboh kanan
speedx = -speedx;

}
if (this.hitTest(_root.kiri)) {//
ketika bola menyentuh temboh kiri

speedx = -speedx;
}

if (this.hitTest(_root.atas)) {//
ketika bola menyentuh temboh atas

speedy = -speedy;
}
if (this.hitTest(_root.bawah)) {//
ketika bola menyentuh temboh bawah
this._x = awalx;
Page 3
code as2.txt
this._y = awaly;

};
};

Page 4

You might also like