cara membuat game sederhana dengan
macromedia flash 8
walaupun
terlihat sangat sederhana tapi sebagai sesama newbie bagus juga kok buat
coba-coba.
berikut langkah-langkahnya:
1.seperti biasa anda harus buka macromedia flash 8 terlebih dahulu
2.langkah selanjutnya anda bikin gambar tanah seperti di bawah ini.
berikut langkah-langkahnya:
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
-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;
}
//end finction player
//fungsi platform ketika dibawah player
function level_under_my_feet() {
return t.hitTest(player_mc._x, player_mc._y+player_mc._height/2, true);
}
seperti gambar di bawah ini:
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;
}
//end finction player
//fungsi platform ketika dibawah player
function level_under_my_feet() {
return t.hitTest(player_mc._x, player_mc._y+player_mc._height/2, true);
}
seperti gambar di bawah ini:

5.langkah terakhir hanya mencoba permainan.dengag pencet ctrl+enter.
selamat mencoba!!!!!!!!
hasilnya kira-kira sepeti ini.

Tidak ada komentar:
Posting Komentar