If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Creating a Penalty Shootout Game with Actionscript 3.0

I currently have three weeks left ony my degree and the last thing i have to do is build a penalty shootout game with Actionscript 3.0.

I thought i would be able to do this but im having trouble getting my head round this.

I understand that i need to have a player, a ball, goalposts, a crowd and i need a scoring system.

I know all the basics but i have no idea how to actually go about making this a fully functional game, is there any tutorials on making a penalty shootout game? Ive searched all over but cannot find anything?

I currently have three weeks left ony my degree and the last thing i have to do is build a penalty shootout game with Actionscript 3.0.

I thought i would be able to do this but im having trouble getting my head round this.

I understand that i need to have a player, a ball, goalposts, a crowd and i need a scoring system.

I know all the basics but i have no idea how to actually go about making this a fully functional game, is there any tutorials on making a penalty shootout game? Ive searched all over but cannot find anything?

I think the best way to do this is that you just get started with it and anywhere you feel you are confused and can't figure out, share your code here and ask for seniors to suggest.

I don't think its possible that you can find complete project done. Just start it and you will see it happening.

Just to reiterate my idea with a pinch just_started's input, from your wording it sounds like you may be trying to go about this using JUST Flash's animation engine (ie: without any coding). Although this might be theoretically possible (some combination of basic buttons and a little tweening) it won't give the results you want, and it would be a whole lot of hacking and cleverness to get a mediocre result.

As started said: give us a little more direction here, and possibly share a little bit about your own experience with computers, programming, and Flash, and we can give a little more back.

"...there were only two good books in the hotel gift shop and I had written both of them."
-Douglas Adams

Alright, so your code in itself isn't bad as AS3, it just has at least one glitche in it syntactically. After you've finished this I suggest you spend a little bit of time making indenting a habit, I caught this error just by throwing in tabs.

And now the problems I found!

First of all, I can't run this (I don't have objects for Player, Posts or Ball but I'll assume they're defined in the library as they only use properties native to Sprites and MC's) so fixing this might be a multistep process.

Check line 55 and 58, you'll find an extra set of {}'s.

That's all that's really popping out at me from this code, if you post the FLA so I can run it and poke around a bit that might help, too.

You're not far off though, keep it up!

"...there were only two good books in the hotel gift shop and I had written both of them."
-Douglas Adams

The first part is going to be going over what you have here and doing a little tidying up.

Now, as it was, your code actually executes fine, with just one warning. Fonts in Flash are a little bit finicky, since almost all computers have different sets of fonts on them, to use a specific font in an FLA you have to embed it (literally keep a copy of the entire font in your file) which is cumbersome and requires some minor micro management. While you're getting used to Flash, I recommend using the _serif and _sans options. When you specify one of these as your font, the users computer picks what it considers to be the default serif or sans-serif.

To do this, select your text field.

Under the font drop down select either _serif, _sans, or _typewriter.

Another thing regarding the text field. Right now it is set to be TFL, a new format with AS3 that I, personally, am not familiar with. I'm not entirely sure why, but they tend to generate extra files, and odd warnings so I've switched it over to a classic text field; you should do the same so we're on the same page. I'm sure if anyone else ends up seeing this, they'll beat my ear in about why I'm wrong.

At the top of the properties menu under where you name the instance you'll see a drop down that says "TLF text".

Click on the drop down and select "Classic Text".

Next use the drop down under that one and select "Dynamic Text"

You may have to retype the name of your instance in the appropriate text box.

Next, your layers. When adding objects programmatically (ie: var myObject:Object = new Object()) everything is added directly to the stage, layers aren't used. Therefore you don't need a separate layer for every object you add. To control which objects appear "on top" change the order in which they are addChild'd to the stage (objects added later appear on top).

Your layers can be cut down to just this; it's not super important, but it's good to have this grasp on AS3.

Now that we've tidied up the file, and I see what everything is doing, it's time to start really planning out what you want this to do. Post exactly what you want here. Try to explain it in as much detail as possible, almost as if you were programming it in the english language.

Thanks for clearing that stuff up man. Ill try to explain what im trying to do with the game in plan English............I will quote some stuff for my specification of the game, it is basically a penalty shootout game to advertise a new sports drink......

Overall Function of Game

"We are then taken to the penalty shootout with the goalkeeper between the goalposts and the football player waiting to hit the ball which is placed on the penalty spot. The player can either shoot left, right or center and the goalkeeper will either go left, right or stay in the middle in attempt to stop the user from scoring. Advertisement for the sports drink include bottles of the sports drink being placed left and right of the goalposts and also there will be banners near the crowd advertising the drink. Once the shot has been taken the score will be updated on the screen, if the ball went in the net then it will display on the screen but if no goal was scored the points stay at 0. Once the shot has been taken the user gets to take another shot. There will always be an option on the screen to exit the application."

Movie Clips That Need To Be Created For Application To Work

mcBall – This is the ball that the football player is aiming to put between the goalposts in order to score points.
mcPlayer – The player will make contact with the ball either placing it left, right or center to aim to score points.
mcGoalkeeper – The goalkeeper will either go left, to the right or stay in the middle in order to try and stop the user scoring points.
mcGoalposts – This is where the ball has to hit in order for the user to score points.

Events Within The Game

There will be a ball placed on the penalty spot and the football player controlled by the user can either choose to kick the ball down the center, to the left or to the right to try and score a point. The goalkeeper will choose a random direction to dive whether it be to stay in the center, to dive to the left or to dive to the right. If the ball meets the goalkeeper then that will count as a save and the user will not score a point but if the ball hits the inside of the net then the user will score a point and this will be displayed on the screen to let the user know they have scored a point. It is quite obvious that the collision detection method will have to be used while developing this, this has already been implemented in the labs so it should be possible to do this within the application. My knowledge of collision detection will no doubt be expanded on as i look to implement it into the game.

Alright, so the good news is that this IS actually going to be almost all animation. I'm a bit short on time today so I'll give you a brief outline.

You're going to want to make 6 animations; 3 of the ball going in each of three directions; 3 of the goal keeper diving in each of three directions. Put each in its own movie clip.

You're also going to want to use three buttons, one for each direction the ball can be kicked. When one of these buttons is pressed, you tell the appropriate movie clip to play (ball left, ball center, ball right). At the same time pick a random number, 1, 2 or 3. If it's 1, play the animation of the goalie jumping left, if it's 2 center, and 3 right. Use an if statement to see if the goalie and ball went in the same direction.

"...there were only two good books in the hotel gift shop and I had written both of them."
-Douglas Adams

I would like to build a football penalty game where the shooter uses the arrow keys to direct the ball into 6 possible areas of the goal. The computer goalkeeper would then dive to a random position to attempt to save. In turn the computer would shoot and the user directs the goalkeeper to save in 1 of 6 directions.

Player and computer get 5 shots each. You can opt to repeat the process and scores go into a high score chart.