A. TUJUAN
1. Mengetahui apa yang dimaksud dengan DMI
2. Mengetahui langkah-langkah untuk membuat multimedia interaktif
C. LANGKAH KERJA
1. Seperti biasa anda harus buka macromedia flash 8 terlebih dahulu
2. Langkah selanjutnya anda bikin gambar tanah seperti di bawah ini.
Blok semua gambar tanah tersebut lalu convert to symbol pilih movie clip.
Lalu ganti intance namenya dengan tanah,.,seperti gambar di bawah ini
3. Bikin sebuah gambar yang anda suka sebagai playernya.seperti gambar di bawah
ini.
Lalu convert to symbol,atau pencet f8,lalu pilih movie klip dan beri nama
player.
Lalu ganti instance namenya dengan player_mc,seperti gambar di bawah ini
4. Setelah selesai klik frame 1.Lalu copy script di bawah ini.
stop();
//deklarasi platform
t = _root.tanah;
//deklarasi player
p = _root.player_mc;
xspeed = 0;
yspeed = 0;
max_yspeed = 10;
walk_speed = 4;
// keadaan saat loncat ya
jumping = true;
// gravitasi & kekuatan loncat
gravity = 1;
jump_power = 10;
//fungsi player dalam frame
player_mc.onEnterFrame = function() {
//jika ditekan ke kiri
if (Key.isDown(Key.LEFT)) {
xspeed = -walk_speed;
}
//jika ditekan ke kanan
if (Key.isDown(Key.RIGHT)) {
xspeed = walk_speed;
}
//jika ditekan tombol ke atas dan tidak saat loncat
if ((Key.isDown(Key.UP)) and !jumping) {
yspeed -= jump_power;
jumping = true;
}
//--------script jatuh seakan2 terkena grafitasi-----------\\
// jika keadaan saat loncat
if (jumping) {
yspeed += gravity;
}
//jika yspeed>max_yspeed
if (yspeed>max_yspeed) {
yspeed = max_yspeed;
}
//--------akhir script seakan2 terkena gravitasi-----------------
\\
//jika platform dibawah kaki dan tidak saat loncat dan tidak saat
naik
if (level_under_my_feet() and !jumping) {
yspeed = 0;
}
// memerintahkan player untuk melakukan gerakan
// ->masukkan nilai-nilai x, y player ke dalam variabel forecast
forecast_x = this._x+xspeed;
forecast_y = this._y+yspeed;
// mengontrol platform
//ketika platform menyentuh bagian bawah player lakukan
while (t.hitTest(forecast_x, forecast_y+this._height/2-1, true)) {
forecast_y--;
xspeed = 0;
yspeed = 0;
jumping = false;
}
//ketika platform menyentuh bagian atas player lakukan
while (t.hitTest(forecast_x, forecast_y-this._height/2, true)) {
forecast_y++;
yspeed = 0;
}
//ketika platform menyentuh bagian kiri player lakukan
while (t.hitTest(forecast_x-this._width/2+1, forecast_y, true)) {
forecast_x++;
xspeed = 0;
}
//ketika platform menyentuh bagian kanan player lakukan
while (t.hitTest(forecast_x+this._width/2, forecast_y, true)) {
forecast_x--;
xspeed = 0;
}
//kembalikan nilai forecast ke player agar player begerak sesuai
event
this._x = forecast_x;
this._y = forecast_y;
// hentikan gerakan setelah event terjadi
xspeed = 0;
//membatasi lebar gerak karakter
if (p._x-(p._width/2)<=0) {
p._x = p._width/2;
} else if (p._x+(p._width/2)>=600) {
p._x = 600-(p._width/2);
}
if(p._x >= 340 && t._x >= -(t._width-605)) {
p._x = 339;
t._x -= walk_speed;
}
if(p._x <= 261 && t._x <= 0) {
p._x = 262;
t._x += walk_speed;
}
//jika player jatuh melebihi platform
if (p._y>=600) {
p._x = 80;
p._y = 180;
}
if (t.hitTest(player_mc._x, player_mc._y+player_mc._height/2,
true)) {
jumping = false;
} else {
jumping = true;
}
};
//jika player jatuh melebihi platform
if(p._y >= 600) {
p._x = 80;
p._y = 180;
}
Selamat mencoba!!!!!!!!
Hasilnya kira-kira sepeti ini.
D. EVALUASI