First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing! | Flash Jobs
Search tutorials
Author: Imtiazur Rahman | Website: http://www.flashbangla.net

Creating a fishing game using actionscript

1. Introduction:

one of the most stunning applications of Macromedia Flash is that you can create your very own game, i found it marvelous back when i made my first one. its worth sharing the easy tricks i took making one of my games, "Fishing Season". the name says it all, its a fishing game. the necessary steps to make any game are: 1. to design & target aims about the game 2. Find animation goodies & sound 3. coding 4. test & publishing 5. relax! one after another, we will discuss every steps (not the last one though, its up to you how you will do that!).

2. Game design:

this is, to me, the toughest & crucial part of the entire game making process. you must determine who will play the games, how they will like it, what will be the objectives, what will be the player strategy & so on. lets start it. first of all, here i decided that it would be a fishing game. so, naturally, it would be a fish cathing contest. the question was, how? will there be many other players with whom i did have to catch fish so that the one catching the most fishes win? i decided not to do that, because it would be harder to make the application. rather, i took a simple strategy. every player would be given one minute each, fishes will be running through the water...now go ahead & catch as many fish as you can. every successful catch will make the score high, & finally after one minute the game finishes & the score is shown. simple isn't it?

3. Find animation goodies & sound:

now to gather inputs to make the game. we will need: 1. a background scene having a river 2. a fisherman picture 3. fish picture (i took two, one fish & one shark) 4. a clipart showing when the game is over. 5. a cool background sound these all were the choice elements i made, all the necessary graphics were taken from clipart collection. if you are a champion artist then go ahead & draw the pictures yourself cap'n! now the real part, arrange the goodies & impliment them along with codes to make a solid application. good luck!

4.1 Coding:

lets open up the flash MX & make the stage 640X500 pixels. the first layer, we call it "bckgrnd", here we paste the background picture having a river. layer 2. we name it "fisherman". we paste our fisherman clipart here. this clipart contains a hook with a rope. this rope will go up & down with arrow keys (i hope!) the next layer, we will name it "fishMask". there will be a mask on the river part of the scene, so that the fishes can only be seen in the river part (it would be absurd if the fishes floated in the land!), here under this layer we put the fishes picture in two layers. in one layer, we put the fish pic. in another layer we put the shark pic. now time to put some coding. its very easy you will see. in the fish movieClip, we add this code: onClipEvent (enterFrame) { this._x = this._x - 10; if (this._x<0) { this._x = 640; } } in the shark movieClip, we add this code: onClipEvent (enterFrame) { this._x = this._x - 15; if (this._x<0) { this._x = 640; } } this code will do nothing but add some motion in the fishbodies so that the fishes float endlessly. thats all to generate motion...easy right? now we will put some tricky codes okay?

4.2 Coding...continued:

now we will put the scoring system. lets add a layer named "score". here we will put a dynamic textbox. in the variable box (lower right at properties) put the name "score". this will be the scoreboard for us(i hope!) lets go back to the fish & sharks. double click the fish movie clip. here is the fish animation. ok, make it another movieclip. now in the movieClip, make the 2nd frame into a keyFrame. assign a code in the first frame: stop(); in the 2nd keyframe, delete the fish animation & add frames till 20. i have kept the framerate as 10 fps. in the first frame, click the fish movieClip & open Action panel. add this code here: onClipEvent (enterFrame) { if (this.hitTest(_root.hook)) { _root.score= _root.score + 10; _parent.play (); } } what is "hook"? good question. it will be the hook of the fishing stick we will make later. so in this code we see that whenever we hit the hook of the fisherman, 10 number is added in the scoreboard. hooray! wait, what does _parent.play(); mean? another good question. well, we do not want the fish to be seen after we catch it. so we made the code so that the fish "disaoppears" after catching. clever huh? we will do the same thing with the shark movieclip, but the code assigning inside the shark is like this: onClipEvent (enterFrame) { if (this.hitTest(_root.hook)) { _root.score= _root.score - 10; _parent.play(); } } whats the difference? well, when the hook hits the fish 10 numbers add, & when it hits the shark 10 numbers are deducted. so the user will try to catch the fishes only, not the sharks because it will lower his scores. now time to start talking about fishing gears & times.

4.3 Coding...continued:

in the fishing gears, there are two important parts. one is the hook. this will go up & down with the arrow keys. make the name of the hook as "hook" in the instance name box. now the other part is "rope". it will be longer & shorter with the arrow keys. now in the rope movieClip, add this code: onClipEvent (enterFrame) { if(Key.isDown(Key.DOWN)) { this._yscale+=100; _root.hook._y+=8.6; } if (Key.isDown(Key.UP)) { this._yscale-=100; _root.hook._y-=8.6; } if (this._y < 272) { this._y = 272; _root.hook._y = 282; } } here when the down key is pressed, the rope gets long & shorter when up key is pressed. pretty simple. now we will add a timer. its a separate movieClip where after 1 minute the game will be over. at the last frame of the movieClip this code is added: _parent.gotoAndPlay("gameOver", 1); so after a minute, we will be at the "gameOver" scene where the scores are shown. ok main part of game finito!

5. Conclusion:

now the finishing part. make a new scene & name it "gameOver". here a clipart is placed. then, put a dynamic textbox & name its var as "greeting". in one frame put this code: greeting = "Fishing over. You got " + score + " points!"; so after one minute of fishing the user gets his score & the game ends. thats all, folks! check out the fla file to see what actually i have meant the whole time! & in the fla file a scene is there at first which is nothing but a brief explanation of the game. just check it out to get some idea on game description. i guess that should be it. if you have further questions you can email me anytime. thanks for reading out the whole thing, chao!
» Level Intermediate

Added: 2005-12-28
Rating: 5.23 Votes: 22
(10 being the highest)
» Author
Flash freelancer.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.