Minggu, 17 Oktober 2010

Membuat Game Sederhana dengan Macromedia Flash

  1. Pertama buka aplikasi macromedia flash yang sudah di instal tentunya lalu pilih creat flash document setelah itu akan muncul tampilam seperti di bawah ini

  1. Lalu pada pada layar pertama beri nama backgrund setelah itu anda beri background yang anda ingikan tapi disini saya akan memberi contoh background seperti di bawah ini

  1. setelah itu jadikan awan yang ada pada contoh di atas menjadi sebuah symbol dengan cara klik awan yang akan di jadikan symbol lalu pilih insert setelah itu pilih new symbol dan akan muncul tampilan symbol lalu pilih movie clip dan masukan script di bawah ini


onClipEvent(load){

speed = 10;

borderLeft = -100;

borderRight = 650;

}

onClipEvent(enterFrame){

this._x -= speed;

if(this._x <>

this._x = borderRight;

}

}


Dengan cara pilih awan yang akan di masukan script lalu tekan F9 dan masukan script di atas

  1. Lalu buatlah kapal sesuai dengan keinginan anda atau anda bis mencontoh gambar berikut

Setelah itu agar kapal tersebut bisa bergerak masukan script di bawah ini :

onClipEvent(load){

speed = 10;

shot_level = 50;

xb = _x;

yb = _y;

canShoot = true;

limitShoot = 0;

reload = 0;

}

onClipEvent(enterFrame){

if(Key.isDown(Key.RIGHT) and this._x <>

xb += speed;

}else if(Key.isDown(Key.LEFT) and this._x > 150){

xb -= speed;

}

if(Key.isDown(Key.DOWN) and this._y <>

yb += speed;

}else if(Key.isDown(Key.UP) and this._y > 150){

yb -= speed;

}

this._x = _x + (xb - _x) / speed;

this._y = _y + (yb - _y) / speed;

if(Key.isDown(Key.SPACE) and canShoot == true){

limitShoot += 1;

if(limitShoot >= 2){

canShoot = false;

reload = 0;

}

duplicateMovieClip(_root.bullet,"bullet"+shot_level,shot_level);

_root["bullet"+shot_level]._x = this._x + 45;

_root["bullet"+shot_level]._y = this._y + 5;

if(shot_level > 150){

shot_level = 50; }

}

if(canShoot == false){

reload += 1;

if(reload > 5){

limitShoot = 0;

canShoot = true;

}

}

}


  1. Langkah berikutnya buatlah layer untuk peluru lalu buat bentuk peluru yyang anda hendaki setelah itu simpanlah gambar peluru tersebut di samping seperti tampilan di bawah ini

Setelah peluru ber hasil dibuat jadikan gambar itu menjadi symbol lalu masukan script di bawah ini

onClipEvent(load){

speed = 20;

}

onClipEvent(enterFrame){

if(_name <> "bullet"){

this._x += speed;

if(this.hitTest(_root.enemyNew)){

removeMovieClip(_root.enemyNew);

_root.enemyOut = 0;

removeMovieClip(this);

}

}

}

  1. buatlah satu buah kapal lagi untuk di jadikan musuh dan anda juga dapat menyajikan inspirasi anda sendiri ke dalam game ini,setelah anda selesai membuat kapal musuh masukan script di bawah ini

onClipEvent(load){

if(_name <> "enemy"){

this._y = Math.round(random(250)) + 100;

this._x = 650;

speed = 10;

step = 10;

}

}

onClipEvent(enterFrame){

if(_name <> "enemy"){

this._x -= speed;

if(this._y <>

this._y = 100;

}else if(this._y > 350){

this._y = 350;

}

if(Math.floor (random(50)) == 5){

down=1;

}else if(Math.floor(random(50)) == 35){

up=1;

}

if(down == 1){

up=0;

this._y += step;

}

if(up == 1){

down=0;

this._y -= step;

}

if(this._x < -50){

removeMovieClip(this);

_root.enemyOut = 0;

}

}

}

  1. Dan yang terakhir buat layer yang berbeda lalu pada frame pertama masukanscrip ini

enemyOut = 0;

_root.onEnterFrame=function(){

if(enemyOut == 0){

duplicateMovieClip(_root.enemy, "enemyNew", 10);

enemyOut = 1;

}

}