Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4941 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


Random Links | Add your own Flash Related Links
Flash Tutorials 1481 Tutorials 7 New Tutorials Added!
What's New | Top100

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Games

Categories Making a cool multi-level game
Author: Jesse

 
Page 10
«prev 1 2 3 4 5 6 7 8 9 10

Got all that? Now it's time to review some important tricks. First let's review the functions we used and how to re-use them. Use a loadLevel function to load in a new level. In some games, you should create the levels with a makeLevel function or alot of objects. You should to store all the levels in an object called levels, but you don't have to. Using levels in objects is a quicker way to do things in complex games because that way, instead of checking for everything with multiple if statements, you can use level objects and for loops to check for different things. Here is an example:

function checkEverything(){
 if(level==1){
 if(defeated==5){
 level = 2
 }
 } else if(level==2){
 if(defeated==10){
 level = 3
 }
 }
}
_root.onEnterFrame = function(){
 checkEverything()
}

That code is very hard to do with more than two levels and it is very hard to make new levels. Now, look at the easier code.

levels = {level1:{baddys:5}, level2:{baddys:10}}
level = 1
function checkEverything(){
 levelName = "level"+level
 if(defeated==levels[levelName].baddys){
 level += 1
 }
}
_root.onEnterFrame = function(){
 checkEverything()
}

As you can see, this code does everything in one if statement. This way is much faster and it is much easier to add more levels. The way i used to make games like these was by using different frames for each level. This is even worse! This way, you can't even use the same functions! Then, i made a game where there was a movie clip that had all the levels in different frames. In the root timeline, i would loop through everything in the game, but there were no level objects. this way, if the bad guys added up to 100, they would always be 100 in every level. This is also a bad way to do things because in Flash, you can't scroll to infinity graphically, but you can with code. With code, you can put a movie clip at an x position of 100,000,000,000! Anyway, let's review more tricks.

weaponNum = 1
weaponsList = ["rifle", "shotGun", "laser"]
weapons = {}
for(a=1; a<=weaponsList.length; ++a){
 name = weaponsList[a-1]
 weapons[name] = {}
 weapons[name].bullets = 5
}
function toggleWeapon(){
 if(weaponNum==weaponsList.length){
 weaponNum = 1
 weapon = weaponsList[0]
 return
 }
 weaponNum += 1
 weapon = weaponsList[weaponNum-1]
 if(weapons[weapon].bullets<=0){
 toggleWeapon()
 }
}
_root.onEnterFrame = function(){
 if(Key.isDown(Key.SHIFT)){
 toggleWeapon()
 trace(weapon)
 }
}

As you can see, this is a great way to toggle through a list of weapons and a great toy for babies who can't stop pressing those buttons. Paste the code into a new Flash Document and Test the Movie. Press the SHIFT key. In the Output window, it will say your current weapon. This is just another version of my cool weapon-toggling trick. You should also note the major functions you need in most games with more than one level. Repeat after the computer monitor!

loadLevel() checkForKeys() checkForCollisions() checkGame() moveEverything()

The last thing to note is that i didn't use any graphics on the stage in the tutorial. I attached them all with actionscript! This is just a nice way to make games like this(and to feel better about yourself) Now that you've downloaded the game, play it over and over again! Note that there is no winning screen. I thought you could make it yourself. Just remember not to overwrite my file. Happy game-making!

«prev 1 2 3 4 5 6 7 8 9 10

» Level Intermediate

Added: : 2004-12-18
Rating: 5.86 Votes: 20
Hits: 366
» Author
Just started working with flash and now i can't stop!
» Download
Download the files used in this tutorial.
Download (21 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments