News Button Separator General Button Separator   Tutorials Page Side Products Page Side Gallery   Button Forum Button About
Tutorials


GamerTheGreat.com - The Best Flash Games/Animations Portal for Great Gamers. Are you Great enough?



 
 

Basic Game Development in Flash 8 - Part 1

 by VirusFree
 

 

1. Introduction
 
Welcome to the first part of the Basic Game Development tutorial series.
This tutorial will explain the basic principles about game development using Adobe Flash 8.
 
My name is George Papadopoulos ( or VirusFree ) and i have been using Flash some time now to create web graphics
and lately for game development. You can see some of my Flash games at the general projects section.
Basically i wanted to write these tutorial to help anyone who just started with game development and try to make your
life easier by sharing some of my knowledge on this matter so you won't go crazy trying to figure things out
by yourself (like i did).
 
Now as title says, these tutorial will teach you the basic stuff you need to know about game development in general and about
game development when it comes to flash...
 

 
 
2. Flash Basics

2.1 Some history
Flash started as a web multimedia tool, so web developers could create animations for their websites. Then after it got more
popular it also got more powerful , fast and complicated , allowing the developer to do much more stuff than just a simple
animation. Flash was created by macromedia and was bought by adobe some time ago. The latest flash version is
Adobe Flash 8 , and you can download a trial from here. The Flash CS3 is the version to come and it is not that far away
from publishing. The next version will introduce many new cool features and tools , but you can use almost everything you know
from version 8 ( flash has always been easy to move from version to version )

 
2.1 Actionscript
Flash uses Actionscript for it's scripting (programming) language, so when you write a game you will write it in Actionscript.
The latest version of Actionscript is 2.0. Actionscript 3.0 is on it's way , and from what i read Actionscript compiler will go
open source ( well done adobe ). Actionscript is the scripting language you will use to control the movie/game and it's pretty
much like Javascript and c++ . It's an OOP ( Object Oriented Language ) so it has classes and stuff. If you already know a
C++ kind of language it will be very helpful
 


 
 
3. The First Interactive Animation
 
3.1 Creating the character
First we will create our character. In this example we will create a Circle for your character. Our mission is to be able to
move this circle in the Flash screen using the keyboards left/right arrow keys

To create the character just pick the oval tool from the toolbar and draw a circle.
 



 
Then select the circle and right click on it. Choose the "Convert to Symbol" option form the popup menu
 




 

 
The name the new symbol 'Ball' and make sure you have the Type : Movie Clip selected
 




 

Now that you have created the new symbol, select it and names it's instance also 'Ball' , you can find this in the Properties tab
( this one really troubled when i tried this for the first time )
 




 

3.2 Writing the Code
No in order to make the ball move according to the keystrokes we must write the script.
To write these action script just select the symbol and open the actions tab


The Code :

onClipEvent
(enterFrame) {
       if (Key.isDown(Key.LEFT)){
             _x-=3;
       }
       if (Key.isDown(Key.RIGHT)){
             _x+=3;
       }
}

 

 
and the screenshot :



 

Code explanation
Ok first of all , remember that we have selected the movie clip, and the code that we wrote is for the movie clip ball

Movie Clip Events
Now , every movie clip has the onClipEvent which gets executed depending on the argument in it's brackets.
In this case we have onClipEvent (enterFramegets executed every time a new frame starts. Also you will probably use
the onClipEvent (load) event which gets executed only one time after the clip is loaded .

Keyboard functions
To get the keyboard keys that are pressed we use theKey.isDown function. theKey.LEFT is just to check for the left arrow
key. if the players is holding the left key down then theKey.isDown(Key.LEFT) will be true , so the code inside the if will be
executed.

Changing MovieClip's parameters
Now we want to move the ball to the left. To do this we have to change it's X coordinate on the screen. To move it left we
must decrease the X coordinate and to move it right we must increase the X coordinate.
(That is because the left side of the screen is the Zero of our X-axis and as we move to the right the X values
 increases until we reach the right side of the screen that will be X = screen resolutions (in pixels ) )
To change a movieclips x value we doMovieClipName._x= thevalue;.
Other useful parameters are : _x , _y , _alpha , ._width , _height , _visible ....

Now because we write the code in the movieclip we don't need to write the movieclip name.. but just the parameter will do, so
_x-=3; Will decrease the _x value by 3 ( so it will move the ball 3 pixels to the left )
 
 
 

3.3 Testing the Movie
Ok now it's time for the test. Press Ctrl+Enter to test the movie...
You can also test the flash i made ... click on the flash bellow and use the right / left keys to control the ball
 


Flash Demonstration
( Press the Left/Right Keys to control the ball )

 
 
3.4 Fixing the Frame Rate
If your version of the game not that smooth then you must change the frame rate of the movie.. the default value is 12 fps.
Setting is to 30 fps will do just fine. You can change it from the movie properties



 

 


    Download Tutorial Source file ( .fla )    


 


 
This concludes the first part of the tutorial

 

Go to Part 2 : Making a character jump, adding gravity , bouncing ball and screen limits


 


This tutorial was written by VirusFree.

Thank you for reading  it and please excuse my English

For any problems or question please don't hesitate to post them in our forums
and i ( or anyone else who can answer them ) will reply as soon as possible

Keywords : flash , tutorial , flash tutorial , online tutorial , Actionscript , game , game development , game tutorial , flash game tutorial
 




    Comments
 

 VirusFree - 4/13/2007 6:24:27 AM
   
 Post here any comments about the tutorial
 
 
   
 

 krow789 - 5/24/2007 9:57:58 PM
   
 hey wow im like really confused tho i am only 15 but i would really love to make my own game so does any one think they could help me out a little because i dont get alot of it but it would be greatly apprechated
 
 
   
 

 VirusFree - 5/25/2007 1:32:48 AM
   
 sure... if you have any question don't hesitate to ask.
Although if you are totally new to programming i suggest that
you leave the games for now and try to understand how programming
works and what is the general concept behind it before starting to learn
about games...
 
 
   
 

 ronak - 5/29/2007 5:04:48 PM
   
 When I insert the script into the action place and try to play it it says,


**Error** Symbol=ball, layer=Layer 1, frame=1:Line 1: Clip events are permitted only for movie clip instances
onClipEvent (enterFrame) {

Total ActionScript Errors: 1 Reported Errors: 1


and i don't know what to do and when i press ctrl enter and the circle dosent move when i press the keys. Do i need to add frames or something? I know the basics of the software.
 
 
   
 

 VirusFree - 5/31/2007 5:37:52 AM
   
 yeah the problem is that you try to write the code
at frame 1 but this is a clip code since it has the onClipEvent

see screenshot at the 3.2 part of the tutorial

what you must do is to select the ball clip and make sure you are
writting the code for that clip and not for any frame
 
 
   
 

 notalther - 6/18/2007 7:01:03 AM
   
 i followed your guide, and added the up and down movement as well, but when i play the movie (ctrl enter) the ball wont move anywhere. i took the up and down code out, and it still wouldn't move anywhere. there's the errors in the code, so i don't know what i'm doing wrong.
do you know why this might be happening?
thanks for any help.

~James
 
 
   
 

 notalther - 6/18/2007 8:02:58 AM
   
 alright, i don't know what i did differently, but i redid the whole project, and now it works. i put the up and down in as well, but for some reason the down doesn't work..oh well, can't win 'em all.

~James
 
 
   
 

 games1com - 7/15/2007 8:04:25 AM
   
 Do i need to buy anything to make a mmorpg games? like a server computer or something? cause i am 16 =D and interested in making games online. but firstly, can i ask how you program other things besides character?
like maps? weapons?
and does bot programmings- the same as game programming?
i only know bot programming.. =D
 
 
   
 

 VirusFree - 7/20/2007 10:27:25 AM
   
 [quote:7945af86ac="games1com"]...[/quote:7945af86ac]

Yes you must become an experienced programmer before trying to
do a big project like this. And even then it's still hard if you try it on
own ( instead with a team )

You also do need to have servers if the game will be online

Don't try to swim too deep... take it one step at a time from the
begging and you might get there some day
 
 
   
 

 games1com - 7/21/2007 10:54:42 AM
   
 ok.. i know some codes.. but the way they wrote the code seems weird. a lot of different style , why is this so? like http://www.gamedev.net/reference/list.asp?categoryid=45 (click the first river making)
and the ones i read on book is so different, but same to making a mmorpg. keys should be around the same and not far off and different
 
 
   
 
 
 
 
Post Comment
You need to be a registered user to post a comment
 


Your Comment :

Your post may only
contain the [url],[img]
[quote] tags and smiles.

Syntax :
[url]address[/url]
[url=address]anchor[/url]
[img]address[/img]
[quote="nick"]text[/quote]

You are NOT logged in. You can Login or Register to phoenixbit.com


 
 

 
 


Tutorial Top Sites - The Best Free Tutorial Sites!



Tags : software, computer security , software developers , software programming , freeware programs , online games
.
 Copyright © 2007 PhoenixBit. All rights reserved
.