News Update :

Maze Double Player

Friday, February 15, 2013

Here is the development of basic maze game tutorial. In this game we are going to move 2 players at once in a maze.

Follow this step :
1. Make a Flash document.
2. Draw a square line, 300 x 297

3. Draw some lines then paint as shown below : 
4. Selection of the entire object, and then press F8. In the panel that appears enter a name and the Wall movie clip as the type and press ok. 
5. Selection of Wall movie clip and press Ctrl + F3. In the Properties pane that appears in the box type wall instance name. 
6. Put a movie clip in the middle of the stage walls. 
7. Draw a red circle and press F8. In the panel that appears enter a name Pemain1 movie clip as the type and then press ok.
 
8. Selection Pemain1 movie clip and then on the Properties panel, type in the box pemain1 instance name. 
9. Draw a blue circle and press F8. In the panel that appears enter a name pemain2 movie clip as the type and then press ok.
10. Selection pemain2 movie clip and then on the Properties panel, type in the box pemain2 instance name.
11. Put a movie clip and pemain2 Pemain1 as shown below  :
12. Click on frame 1 and press F9. In the actions pane that appears enter the following script :

stop(); //jari-jari pemain jarijari1 = pemain1._width/2; jarijari2 = pemain2._width/2; //kecepatan pemain bergerak kecepatan = 5; onEnterFrame = function() { //jika tombol panah kiri ditekan if (Key.isDown(Key.LEFT)) { //pemain1 dan pemain2 bergerak ke kiri pemain1._x -= kecepatan; pemain2._x -= kecepatan; } //jika tombol panah kanan ditekan if (Key.isDown(Key.RIGHT)) { //pemain1 dan pemain2 bergerak ke kanan pemain1._x += kecepatan; pemain2._x += kecepatan; } //jika tombol panah atas ditekan if (Key.isDown(Key.UP)) { //pemain1 dan pemain2 bergerak ke atas pemain1._y -= kecepatan; pemain2._y -= kecepatan; } //jika tombol panah bawah ditekan if (Key.isDown(Key.DOWN)) { //pemain1 dan pemain2 bergerak ke bawah pemain1._y += kecepatan; pemain2._y += kecepatan; } //membuat pemain1 tidak dapat melewati dinding while (dinding.hitTest(pemain1._x, pemain1._y+jarijari1, true)) { pemain1._y--; } while (dinding.hitTest(pemain1._x, pemain1._y-jarijari1, true)) { pemain1._y++; } while (dinding.hitTest(pemain1._x-jarijari1, pemain1._y, true)) { pemain1._x++; } while (dinding.hitTest(pemain1._x+jarijari1, pemain1._y, true)) { pemain1._x--; } while (dinding.hitTest(pemain1._x-jarijari1, pemain1._y+jarijari1, true)) { pemain1._x++; pemain1._y--; } while (dinding.hitTest(pemain1._x+jarijari1, pemain1._y-jarijari1, true)) { pemain1._x--; pemain1._y++; } while (dinding.hitTest(pemain1._x-jarijari1, pemain1._y-jarijari1, true)) { pemain1._x++; pemain1._y++; } while (dinding.hitTest(pemain1._x+jarijari1, pemain1._y+jarijari1, true)) { pemain1._x--; pemain1._y--; } //membuat pemain2 tidak dapat melewati dinding while (dinding.hitTest(pemain2._x, pemain2._y+jarijari2, true)) { pemain2._y--; } while (dinding.hitTest(pemain2._x, pemain2._y-jarijari2, true)) { pemain2._y++; } while (dinding.hitTest(pemain2._x-jarijari2, pemain2._y, true)) { pemain2._x++; } while (dinding.hitTest(pemain2._x+jarijari2, pemain2._y, true)) { pemain2._x--; } while (dinding.hitTest(pemain2._x-jarijari2, pemain2._y+jarijari2, true)) { pemain2._x++; pemain2._y--; } while (dinding.hitTest(pemain2._x+jarijari2, pemain2._y-jarijari2, true)) { pemain2._x--; pemain2._y++; } while (dinding.hitTest(pemain2._x-jarijari2, pemain2._y-jarijari2, true)) { pemain2._x++; pemain2._y++; } while (dinding.hitTest(pemain2._x+jarijari2, pemain2._y+jarijari2, true)) { pemain2._x--; pemain2._y--; } };

13. Press Ctrl + Enter to see the result:

Credit : Warung Flash

If you think this Article useful, Please leave a Comment. Don't forget to follow this Blog to know the latest update.Thank You !! [Blank XPDC]
Share this Article on :

0 komentar:

Post a Comment

 

© Copyright Blank XPDC 2010 -2011 | Design by Blank XPDC