HOME | DD

Published: 2011-11-09 14:03:48 +0000 UTC; Views: 30515; Favourites: 2148; Downloads: 1034
Redirect to original
Description
Thanks for featuring this tutorial! It's a great honor---
Learn how to create a Flash game, step by step! Every line of code is explained so when this tutorial is over you've got the knowledge to create a complete game.
Please note that I always recommend buying a book for full instructions on Flash - this is merely a good start.
Related content
Comments: 221
gwap01 [2012-12-17 20:21:03 +0000 UTC]
this is fantastic! learned more in an hour than I did in an entire semester! darn teacher making us fill in blank codes and never explained what they do!
👍: 0 ⏩: 0
illusivereality [2012-12-17 20:19:42 +0000 UTC]
Great tutorial. A good way to get started making Flash games. I'd recommend that people learn ActionScript 3.0. It's a bit harder to get started with, and yes, they made things needlessly complex, but it's faster and the complex things can be useful in large projects.
👍: 0 ⏩: 1
KenneyWings In reply to illusivereality [2012-12-18 00:16:58 +0000 UTC]
I would also recommend AS3. This is an older tutorial though, but it might be handy for some people. I know schools love to teach students old stuff, like AS2.
👍: 0 ⏩: 1
illusivereality In reply to KenneyWings [2012-12-18 07:51:55 +0000 UTC]
Heh, that's true, our English curriculum still had a section about sending telegrams!
👍: 0 ⏩: 0
Natmonkey In reply to ??? [2012-12-17 20:11:19 +0000 UTC]
That is so cool! Thanks for creating and sharing this.
👍: 0 ⏩: 0
NaokoYiran [2012-12-17 19:36:02 +0000 UTC]
Nuuuuu don't enable more people to make bad shmups- /shot
Playing the actual game, I noticed you forgot to restrain the player's movement, meaning the player ship can just fly off the sides of the screen.
Also it would be nice to throw some hints of more advanced concepts in, if just as single sentences after descriptions to give beginners some other topics to look into and learn more. For example you're using Flash's built-in collision detection, while standard practice in shmup games is to use hitboxes, so you could drop a mention of hitboxes after the description of player collision. You even drew the ship with a convenient rectangle in the middle suitable for a hitbox, heh.
👍: 0 ⏩: 1
KenneyWings In reply to NaokoYiran [2012-12-18 00:31:30 +0000 UTC]
I'm trying to teach people how to code, not how to recreate my game. That's why I bothered to explain every single line of code, so people would get a hang of it and could create anything they want.
👍: 0 ⏩: 0
graphicsurge [2012-12-17 19:27:18 +0000 UTC]
Ive tried to learn basic flash, but it always feels like the books jump past basic code. Any advice?
👍: 0 ⏩: 0
Crono8 In reply to ??? [2012-12-17 19:04:16 +0000 UTC]
Wow I wish I had this a few years back xD; Cool, thanks!
👍: 0 ⏩: 0
sevenofeleven [2012-12-17 19:03:41 +0000 UTC]
I wanted to do a video game in flash but I forgot a lot of flash stuff.
Thanks for the tutorial.
👍: 0 ⏩: 0
TheodenN In reply to ??? [2012-12-17 18:59:23 +0000 UTC]
I am a C++ programmer and checked this out to get a sense of how things are done in flash.
It was fun to browse through this and the music is very good.
👍: 0 ⏩: 1
KenneyWings In reply to TheodenN [2012-12-18 00:32:16 +0000 UTC]
While this tutorial teaches ActionScript 2.0 the newest version is ActionScript 3.0 which is way more similar (and mature) to C++. Go check that out, it should be right up your alley!
👍: 0 ⏩: 1
TheodenN In reply to KenneyWings [2012-12-18 10:47:00 +0000 UTC]
I was checking it out just out of curiosity. Actually I am a fan of native code and I am trying to stay away from managed code especially while working on games. Thanks for the info though
👍: 0 ⏩: 0
Respectless In reply to ??? [2012-12-17 18:44:52 +0000 UTC]
This is truly generous of you, thanks a lot man!
👍: 0 ⏩: 0
MysticNarwhal [2012-12-17 17:08:53 +0000 UTC]
way cool, I took flash for animation. I'll go over this, thanks for all your work.
👍: 0 ⏩: 0
The-Under-Network In reply to ??? [2012-12-17 17:05:10 +0000 UTC]
It's content like this that needs to be on Newgrounds.
👍: 0 ⏩: 1
KenneyWings In reply to The-Under-Network [2012-12-18 00:17:31 +0000 UTC]
It is on Newgrounds! [link]
👍: 0 ⏩: 0
The-Golden-Knight In reply to ??? [2012-12-17 16:45:58 +0000 UTC]
Super AMAZING! I will be referring to this, as overwhelming code usually makes my jaw drop. I can handle elementary logic fine; just learning the language is tricky.
Just a minor point: Chapter 1 Page 5/6, there is a grammar error: "This tells the spaceship to subtract 6 pixels from it's X axis." The its is wrong.
👍: 0 ⏩: 0
Doom-the-wolf [2012-12-17 15:40:50 +0000 UTC]
Although this tutorial actually works, it teaches many bad practises that will make it difficult to people who want to learn how to make real video games in the future. I am slightly disappointed that this could have gotten a daily deviation.
There are a lot of things I would have done differently in this tutorial, but I'm going to focus only on the most important of the mistakes. Over a year ago I made a short informative Flash file named "Common mistakes in Flash games" , which I will point to when describing each problem.
onClipEvent(X){}: Placing code in MovieClips will make it very difficult to find the code when you have a lot of MovieClips. ActionScript 3.0 even removed MovieClip specific code altogether. I recommend creating a layer in the main timeline and putting every single line of code there. The new code would be: myClip.onEnterFrame = function(){}. Also, placing code in MovieClips will make it difficult to tell which MovieClip is running in what order. In this game it doesn't matter, but in other projects it might. See the section "Misplaced code" in my tutorial for more details.
Key.isDown(): Using this function removes the responsibility of learning about event handling. This is a bad thing. Events are an important feature of ActionScript that must be understood even to make the simplest of games. For moving the ship left and right, this works fine. But for shooting bullets you should create an event listener, like this:
var listener: Object = new Object();
listener.onKeyDown = function(){
//Create bullet annd place it where the ship is.
};
Key.addListener(listener);
This is asoo one of the features ActionScript 3.0 removed. See the section "Endless jumping" in my tutorial for more details.
timer = 0, enemies = [], i = 0: These are undeclared and untyped variables. This is a very bad practise by any standard. Any ordinary programming language would have refused to compile. Are these Numbers, Booleans, Strings, Arrays or Functions? The correct way to declare a variable is this:
var timer:Number = 0;
var enemies:Array = [];
var i:Number = 0;
But this isn't the only problem with the way your variables have been declared. If you created a variable in the main timeline like this:
timer = 0
And you wrote the same code in two different MovieClips:
onClipEvent(load){
timer=0;
}
onClipEvent(enterFrame){
timer++;
}
What do you think would happen? Would each MovieClip have their own local variable named "timer"? Or would they both be using the "timer" variable created in the main timeline? The scope of a variable is a very important thing for people to learn. Like with the other two examples, ActionScript 3.0 removed the ability to use variables without declaring them first. See "Weak typing" in my tutorial for more information.
Finally, I noticed a special kind of problem in a specific variable declaration, when you wrote the code
spawnEnemy = function(){}
Once again, this variable should have been declared like this:
var spawnEnemy:Function = function(){}
But declaring a function as a variable is unnecessary, and should only be used when the function variable will not always have the same function. Instead, you should declare functions as a constant:
function spawnEnemy(){
}
I know you might think that you're teaching people in a way they can understand but, although they will learn how to make this particular game, the mistakes will only cause them trouble in future. Making games is not an easy thing and beginners should not be encouraged to believe they can do it on the first day. People who want to learn how to make games must first learn proper programming and then search for game specific tutorials. I recommend using ActionScript 3.0 as a learning tool, because it is stricter and has many more error and warning messages.
👍: 0 ⏩: 3
KenneyWings In reply to Doom-the-wolf [2012-12-18 00:18:52 +0000 UTC]
It's an older tutorial, every single tutorial out there will teach people a certain style of coding. I'm managing fine on my day job writing this 'bad code'.
👍: 0 ⏩: 1
Doom-the-wolf In reply to KenneyWings [2012-12-18 00:45:37 +0000 UTC]
Well, there are styles, and then there are mistakes. Not declaring or typing variables is an example of a dangerous one. As I described in the previous comment, it can cause confusion as to which objects have access to what variables. It also prevents you from finding out when you make accidental assignments, like trying to assign a Number to a String variable.
Although your method of programming works within the limits of ActionScript 2.0, it creates difficulties in your ability to create more advanced projects, or to even switch to other programming languages. As Flash becomes less popular each year, the need to switch to other languages will become more pressing.
👍: 0 ⏩: 1
KenneyWings In reply to Doom-the-wolf [2012-12-18 00:54:45 +0000 UTC]
Hey sorry for the short answer I gave you, was going through all the comments and replying as much as I can
The code I'm teaching here is meant to be kept very simple in order for beginners to understand. Yes, in the long run it might be bad practice but I rather learn something very easy and the details along the way than being bombarded with every detail that doesn't matter gameplay wise but will result in better code.
Besides, the tutorial is quite old (around 2009, in 2011 I've made a Flash file out of it - before it was just plain text). I would not write a tutorial about ActionScript 2.0 anymore but rather ActionScript 3.0. AS3 of course enforces certain rules you brought up, like variable declaring. This absolutely makes it harder to learn for beginners, but it will result in cleaner code and a better overall understanding of all programming languages.
Flash is not getting less popular, it's a hype made up during the HTML5 days. Adobe is now focusing on Adobe AIR which enables Flash developers to compile their game to native apps for Android, iOS and more. Apple just announced their app of the year which is Photoshop Touch, made using AIR, thus made using Flash. Yes, that's the same Apple that didn't want any Flash on their device earlier. Also, don't forget about Scaleform. Tools made for AA developers to create UI's and menu's for their games, using, yes, Flash. Games like Skyrim, Borderlands, Batman Arkham City, Mass Effect and The Witcher 2 to name a few. They all use Flash for their UI and menu's.
Flash is used everywhere, people just don't notice it.
👍: 0 ⏩: 1
Doom-the-wolf In reply to KenneyWings [2012-12-18 01:38:04 +0000 UTC]
I'm happy to hear that you have switched to teaching ActionScript 3.0. Although I don't think that easier learning is better. I think clean code and good software methodology should be taught very early, so people will find it easy to stick with it in the future.
It's true that Flash has recently added new features, like hardware accelerated graphics. It's working much better for video games and applications than ever before. But it is becoming less popular in web development in favor of HTML 5.
The way you talked about HTML 5 made it sound like something that came and went. The real HTML 5 days aren't here yet. It's still only a draft and they predict that it will continue to be one for a lot of years. HTML 5 was made by the W3C, an organization that regulates all of the current web standards today. They know what they're doing.
👍: 0 ⏩: 1
KenneyWings In reply to Doom-the-wolf [2012-12-21 12:19:16 +0000 UTC]
You're right, in web development Flash is getting less popular but thanks to Adobe's quick thinking it's getting more popular in mobile development and creating menu's in games.
👍: 0 ⏩: 1
Doom-the-wolf In reply to KenneyWings [2012-12-21 12:22:02 +0000 UTC]
Well, that was an interesting conversation. Thanks for replying.
👍: 0 ⏩: 0
xblackwater In reply to Doom-the-wolf [2012-12-17 16:44:58 +0000 UTC]
I see what you're saying, but AS2 for starters isn't bad. That's how I learned.
I taught myself AS2 when I was 12, made tons of good games (all lost now), then I grew up and realized how sloppy AS2 was.
But to be honest, I was 10 times more productive with AS2 than I am with AS3. Something about focusing on the code being organized takes away from actually getting anything done. Y'know?
AS2 is alright for folk that are more into game design than programming.
👍: 0 ⏩: 1
Doom-the-wolf In reply to xblackwater [2012-12-17 17:00:51 +0000 UTC]
ActionScript 2.0 is a bad learning tool for the very reason that it's easy and allows many mistakes to compile. So it's better to start with ActionScript 3.0 and then move to the less restrictive ActionScript 2.0 once you have a good understanding of programming and don't want the restrictions to get in your way. Of course, learning this way takes more time and everyone is impatient.
Making a game is not supposed to be easy, and tutorials like this one give the illusion that it is. Game design is a subsection of programming and should not be taught as a separate field but as a specialization of programming (In other words, more difficult than programming). There is an entire phase of software engineering dedicated to designing and organizing your code before writing a single line. While it seems counterproductive at first, it will make the code much easier to read, debug and update in the future.
👍: 0 ⏩: 1
TheRecklessKid In reply to Doom-the-wolf [2012-12-17 19:04:02 +0000 UTC]
Opinions, opinions, opinions.
👍: 0 ⏩: 1
Doom-the-wolf In reply to TheRecklessKid [2012-12-17 19:43:46 +0000 UTC]
Programming and software engineering techniques are not opinions. They've been standardized to be efficient and easily manageable.
👍: 0 ⏩: 1
TheRecklessKid In reply to Doom-the-wolf [2012-12-17 20:28:23 +0000 UTC]
"good", "easy" are opinions.
👍: 0 ⏩: 1
Doom-the-wolf In reply to TheRecklessKid [2012-12-17 20:35:42 +0000 UTC]
Alright, if it's about ActionScript 2.0 being worse than ActionScript 3.0 for learning, I can grant that it's an opinion. But it's an informed opinion. It is my understanding that if you give beginners a language that allows then to make mistakes, they will find it harder to realize they're making mistakes (Like failing to declare any variables) and won't correct themselves.
The fact that this tutorial is promoting bad programming practises still stands, and that is not an opinion. Your short, vague sentences give me the impression that you do not actually know very much about programming. Am I mistaken?
👍: 0 ⏩: 1
TheRecklessKid In reply to Doom-the-wolf [2012-12-18 14:25:03 +0000 UTC]
Unless, you've fully surveyed every one's results, you can't say much factually.
Opinions.
👍: 0 ⏩: 1
Doom-the-wolf In reply to TheRecklessKid [2012-12-18 16:13:44 +0000 UTC]
This comment is as vague as the previous two. You need to specify. Are you replying to my first paragraph, my second one, or both? What results am I supposed to survey? And on what group of people?
👍: 0 ⏩: 1
TheRecklessKid In reply to Doom-the-wolf [2012-12-18 16:53:15 +0000 UTC]
Never mind.
I didn't sign up to be your special-ed teacher.
/facedesk
👍: 0 ⏩: 1
Doom-the-wolf In reply to TheRecklessKid [2012-12-18 16:59:21 +0000 UTC]
You don't seem to be a programmer or a statistician. I'll just leave it here.
👍: 0 ⏩: 1
TheRecklessKid In reply to Doom-the-wolf [2012-12-18 17:39:30 +0000 UTC]
And, you've come to that conclusion through my "short" and "vague" sentences?
You said you hadn't the proper data to comprehend what I was telling you, because I was being "short" and "vague",
yet you hypothesize that I'm not a programmer?
👍: 0 ⏩: 0
DestroyErase In reply to Doom-the-wolf [2012-12-17 16:14:55 +0000 UTC]
It was rewarded with a DD because it was pretty and glossy.
👍: 0 ⏩: 1
Doom-the-wolf In reply to DestroyErase [2012-12-17 16:16:59 +0000 UTC]
You can't deny that. It certainly has artistic value. I just think that the purpose of a tutorial is giving good information and should be evaluated under that criteria.
👍: 0 ⏩: 1
DestroyErase In reply to Doom-the-wolf [2012-12-17 20:57:45 +0000 UTC]
Wasn't disputing that. I agree with you. A tutorial is for reading accurate and on-target information, not to see incorrect or outdated information in a highly approachable format. I can see where the admiration for this tutorial came in blindly with the feature though. If it looks so amazing and glossy, it would have been a fair assumption for people without any particular knowledge in game creation to also assume he is on point with his guidance.
👍: 0 ⏩: 1
Doom-the-wolf In reply to DestroyErase [2012-12-17 21:06:42 +0000 UTC]
Well, to anyone else, the tutorial looks perfect. And what it teaches works correctly. There really isn't any "fault" or "blame" here, and I'm not asking for any action to be taken. I was just putting up my criticism here with the hope that some readers might learn from it.
👍: 0 ⏩: 1
SqueakyToybox In reply to Doom-the-wolf [2012-12-17 22:23:08 +0000 UTC]
Hi Doom
Thanks for your comments on this tutorial, it was a really interesting read. I can clearly see that you are a more advanced coder than what this tutorial describes here and a better coder than myself. I think that tutorials aren't suppose to be a rule book but just a stepping stone to something you wouldn't have previously tried or something you were interested in but didn't know how to do. I personally haven't tried a shooter game before and I found this tutorial very clear and understanding and fairly easy for people to understand so that is just a few reasons why it was chosen for a DD but I think what you mentioned above was very valuable information. I think someone starting out with Flash though wont understand exactly what type of coding they need to do, they will learn that over time like I did with trial and error.
👍: 0 ⏩: 2
Pix3M In reply to SqueakyToybox [2012-12-17 22:43:29 +0000 UTC]
What a funny misunderstanding. Some people are seeing tutorials as being much more authoritative than how you personally see it. This will probably cause a few headaches for those who are the sort to see them a bit more authoritative.
👍: 0 ⏩: 1
<= Prev | | Next =>