First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing! | Flash Jobs
Search tutorials
Author: Jesse
function checkGame(){
	if(powerUpTimerGo==true){
		powerUpTimer -= 1
	}
	if(powerUpTimer<=0){
		powerUpTimerGo = false
		powers[currentPower] = false
		currentPower = undefined
	}
	if(myBullet._y<=0){
		firing = false
	}
	if(energy<=0){
		gotoAndStop("gameOver")
	}
	if(energy>100){
		energy = 100
	}
	if(defeated==levels[levelName].baddys){
		loadLevel()
	}
	if(helperClip._x>=550){
		helperSpeed = 0
		helperClip._visible = false
		helperClip._x = 0
	}
	energyClip._width = energy
	powerUpClip._width = (250/levels[levelName].powerUpTimer)*powerUpTimer
	currentPowerClip.gotoAndStop(currentPowerNum)
	myBullet._y -= bulletSpeed
	helperClip._x += helperSpeed
	if(currentPower==undefined){
		currentPowerClip.gotoAndStop("X")
	}
}

That is ALOT of code. Basically it just moves around all the variables and movie clips. First, we make the powerUpTimer subtract one if powerUpTimerGo is set to true. If powerUpTimer is less than zero, we set powerUpTimerGo to false and make sure that no powers are in use anymore. Then we check to see if the bullet's y position is less than zero. If it is, you can fire another bullet. That's not exactly a trick, but it stops you from having to duplicate the bullet over and over again! Then, if the player's energy is less than zero, we go to the gameOver frame. Then, if the player defeated all the baddys in that level, the game loads another level. Then, we check to see if the helper has reached the end of the screen. This isn't really needed for the game to work, but if you wanted to do something else,(like move the helper backwards) this would be needed. Then we set the energyClip's width(a little rectangle) to equal the player's energy. Then we set the powerUpClip's width to equal 250 divided by the maximum powerUpTimer, times the power UpTimer. This gives the game a cool effect. Instead of being equal to the variable itself, it goes faster in each level. This can make a game look much better. Then, we make the game show the current power, instead of the player not caring what the powerUp is. This is a MUST in games. Then, we make the bullet and helper move according to their speeds. Finally, if there is no power in use, the clip that displays the current power goes to a frame that displays an X. Now let's move the baddys so that they follow the player. You can take a break if you want. (This is ALOT of code)

» Level Intermediate

Added: 2004-12-18
Rating: 6.14 Votes: 21
(10 being the highest)
» Author
Just started working with flash and now i can't stop!
» 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.