HOME | DD

Computer-Turret β€” Make a full RPG in flash

Published: 2006-10-01 16:41:20 +0000 UTC; Views: 29019; Favourites: 250; Downloads: 608
Redirect to original
Description [Edit] This tutorial is outdated! It can still be used for learning some basics for Flash but it is advised you find newer tutorials! I have a new video tutorial series on youtube ( [link] ) for making a Flash game using AS3. [/Edit]

Want to make a RPG(role palying game)?
Well this is the tutorial for you.
Works in mx pro 2004 and up as far as I know and possibly lower.
Related content
Comments: 134

Ai-Tinyfox In reply to ??? [2010-06-27 07:18:09 +0000 UTC]

One thing to say...

THANKSSSSSSSSSSSSSSSSSSSS!!!

But, (No,not but again...!)

I tried to create 3 more buttons to decrease points and then they deacreases the stats to "-1" and I cried and I almost commited suicide and... heeeeeeeeeeeeeeeeeeeeeeeeeeeelp

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to Ai-Tinyfox [2010-06-27 14:03:45 +0000 UTC]

Remember it's -= not =-

If I say strength=-5
It'll equal -5
If I say stength-=5
It'll SUBTRACT A VALUE EQUAL TO 5 (take 5 away from strength)

πŸ‘: 0 ⏩: 1

Ai-Tinyfox In reply to Computer-Turret [2010-06-27 14:16:08 +0000 UTC]

Umm, thanks. And those Llamas-you-don't-know-what-the-@#!@-are-they I can say they're some kind of a tradind present to prove your impressions to someone.
( Kinda cliche, isn't it ^^)

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to Ai-Tinyfox [2010-06-27 14:30:40 +0000 UTC]

Ah ok, many thanks and I hope your game goes well!

πŸ‘: 0 ⏩: 1

Ai-Tinyfox In reply to Computer-Turret [2010-06-27 14:49:22 +0000 UTC]

Haha, I don't think my game would be ok since It still has some problems and I don't know how to solve them and I will ask you again and then your shark avatar will bite me and... end of the story ^^
Lol

πŸ‘: 0 ⏩: 0

Schweinskopfsuelze [2010-05-10 13:39:48 +0000 UTC]

on(press)? are you serious?
Don't teach such bad habits!

πŸ‘: 0 ⏩: 2

itty-bitty-stock In reply to Schweinskopfsuelze [2011-06-23 19:48:40 +0000 UTC]

What's so bad about that? It works.

πŸ‘: 0 ⏩: 1

Schweinskopfsuelze In reply to itty-bitty-stock [2011-06-23 20:46:46 +0000 UTC]

- it creates a mess, spilling code everywhere
- it cannot be removed (as opposed to event methods)
- it makes people use _root and _global, which is horrible

Programming is not about "if" it works, but "how".

πŸ‘: 0 ⏩: 1

itty-bitty-stock In reply to Schweinskopfsuelze [2011-06-23 22:40:14 +0000 UTC]

I guess it's a personal taste, but I prefer code to be inside movieclips rather than the frame itself, because it makes it much easier for me to sort out problems. And what is so horrible about _root and _global? Really, I don't know - I use them all the time.

πŸ‘: 0 ⏩: 1

Schweinskopfsuelze In reply to itty-bitty-stock [2011-06-24 09:24:56 +0000 UTC]

Debugging becomes impossible if your code is literally everywhere.
A RPG is a great example because a lot of this will interact with each other.
If some collision detection happens here and some there, things will become very confusing very quickly.

The result is spaghetti code.
Very hard to maintain, debug and modify.

You cannot put the code in a class.
And again(!), we are talking about an RPG here, with a lot of objects interacting, oop is a key strategy in such a situation.

Again:
You cannot remove it.
You cannot disable a button by simply removing the event handling, because it is not possible.
You need a boolean flag variable with an if statement to check states.

Instead, you can add and remove event methods to an object and remove them again.
This is very useful if you want to pause a game for example:
onEnterFrame = null;

...is all you have to do. Stops your main game loop from executing every frame, which results in a game that pauses.

With your on() approach, you would have to check if the game is paused in every on() block.
And as your code is not centralized, you have to find everything that does something.

---

_root is bad, because a lot people do things like _root["mcs"+i] which is horrible code.
This is not typesave, if it fails, it won't do so until you are executing your file, no compile time error checking possible.
As this accesses _root in a dynamic way, most errors will fail silently .
It just "won't work" that will result in guesswork, not targeted debugging.

It also contains a string, which is prone to spelling mistakes.

---

_global breaks any encapsulation of functionality, reducing the possibility to reuse the code to 0.

---

At least try to use As2.
Coding on the timeline and using class files.

As3 is of course recommended.

πŸ‘: 0 ⏩: 0

Computer-Turret In reply to Schweinskopfsuelze [2010-05-10 18:49:56 +0000 UTC]

This was made in like 2005, I was completely new to Flash. I 100% agree it that AS1 is obsolete and horrible. However people continue to f-ing fave this so whatever.

πŸ‘: 0 ⏩: 1

Schweinskopfsuelze In reply to Computer-Turret [2010-05-10 20:28:30 +0000 UTC]

I see now, sorry.
I always think group submissions are new devs, my fault.

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to Schweinskopfsuelze [2010-05-10 20:34:41 +0000 UTC]

Even if old it will at least teach concepts which can easily be applied else-where. I've been thinking about making another one in AS3 as an update.

πŸ‘: 0 ⏩: 1

Schweinskopfsuelze In reply to Computer-Turret [2010-05-10 20:36:49 +0000 UTC]

sounds great. rpg is a nice base to teach benefits of oop. go go go

πŸ‘: 0 ⏩: 0

iCerveny [2010-04-18 17:38:46 +0000 UTC]

I'm the number one noob in the whole flash game world so I'll ask this quick:
"WTF IS "VAR", TEXT "BOX" AND ALL THAT SH**?" O_O you can cry/get angry at me but please just explain T_T

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to iCerveny [2010-04-18 18:29:50 +0000 UTC]

"var" is short for variable.
var score:Number=0;
We are initializing a "var" or "variable" named "score" and it is of the type "Number" and we are setting it to equal 0 (zero).

Text Box: When you create text using the text tool it makes a box, you can set it to be a dynamic, static or input textbox in the drop down in its properties when you have it selected.
Example: [link]

πŸ‘: 0 ⏩: 1

iCerveny In reply to Computer-Turret [2010-04-19 12:27:36 +0000 UTC]

oh, now i get it - thanks.

πŸ‘: 0 ⏩: 0

evolvd-studios In reply to ??? [2010-03-17 00:01:17 +0000 UTC]

saw some of your flash work, liked it a lot. I was wondering if youd like to join our group. Were a flash animator and programer group, here you can either share your latest flash work, or demos, ask your questions, or use our resource section wich keeps growing everyday, and has animated gif spritepacks for all you sprite animators out there. We also growing out our tutorial section on either animating and programing, and now got our new sound pack SFX archive for all your games, all free for the public upload. Please think about it. We have not long in deviantart, but hope to grow into a huge comunity soon enough. If interested, please reply with a yes and we will send you the invitation. If not interested, just reply a "no" or dont reply at all XD, your choice. For now, see you till next time!

By the way, we use personal invitations scince our invites have run out XD. Thats why we have to invite like this from now on XD

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to evolvd-studios [2010-03-17 01:21:10 +0000 UTC]

Well I've certainly come a long way since I made this tutorial, as I've said a lot it's very old and all the code is obsolete pretty much.
Sure, I'll join your group. I like the idea of combining all the talent like that.

πŸ‘: 0 ⏩: 1

evolvd-studios In reply to Computer-Turret [2010-03-17 03:04:15 +0000 UTC]

Ive sent you it, if you didnt get it please let me know, scince I might have spelt the username wrong XD

πŸ‘: 0 ⏩: 0

Heartbreaker-7 In reply to ??? [2010-02-28 16:29:35 +0000 UTC]

how would you add like weapons or items, and use them? like a key to a door, or a bow and arrow.

πŸ‘: 0 ⏩: 0

Silence-Echoer [2009-10-25 07:10:45 +0000 UTC]

THANKYOU!!!! This is so helpful and actually works!!!!!!!!!! THANKYOU SO MUCH!!!!!

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to Silence-Echoer [2009-10-25 12:51:20 +0000 UTC]

It is dated but working none-the less. Good as start as any. Glad it helped you.

πŸ‘: 0 ⏩: 1

Silence-Echoer In reply to Computer-Turret [2009-10-26 04:39:42 +0000 UTC]

I've been looking for one that works in flash 8 for ages, I'm so glad you made it!

πŸ‘: 0 ⏩: 0

Tryskellion [2009-09-19 18:22:14 +0000 UTC]

Thanks, this has helped me a lot.

πŸ‘: 0 ⏩: 0

Beastiewolf In reply to ??? [2009-08-22 08:01:14 +0000 UTC]

This is great for a Mario style game, which I've been wanting to make for a friend. I already have a jump code too. 83
Thank you very much!

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to Beastiewolf [2009-08-22 23:19:01 +0000 UTC]

Glad you like it!

πŸ‘: 0 ⏩: 0

ksetsuni [2009-08-07 03:24:19 +0000 UTC]

i was wondering if you could help me, i'm not really making an rpg, i'm making a sim date. i'm working on "health".
I got the sleep button to work, but it only works once. like say my HP says 100 i'd press the sleep button that adds 50hp, it would change to 150 HP & if i click it again it stays the same i was wondering what the code for this 1 is

...sorry if this is a bit confusing, i dont really know how to put it -_-

thanks for the tutorial btw it helped clear a lot of questions

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to ksetsuni [2009-08-07 12:15:03 +0000 UTC]

sleepButton.onRelease=function(){
//sleepButton is the instance name of the button
HP+=50//give 50 HP
if(HP>150){//check if it's over the max of 150
HP=150//set back to 150 if it's over 150
}
}

Could do something like that.

πŸ‘: 0 ⏩: 0

Edplosion [2009-08-01 09:25:22 +0000 UTC]

My gosh, this is the holie grail in teh form iof flash! This is soooo helpful!

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to Edplosion [2009-08-01 12:27:08 +0000 UTC]

^.^ I wouldn't say holy grail but I'm glad it's helpful

πŸ‘: 0 ⏩: 0

inechiSAN [2009-02-04 00:52:27 +0000 UTC]

wtf de shou?

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to inechiSAN [2009-02-04 12:23:41 +0000 UTC]

This tutorial is really out-dated. The coding is terrible, I don't advice you even use this tutorial.
>.>
<.<

πŸ‘: 0 ⏩: 1

inechiSAN In reply to Computer-Turret [2009-02-04 12:34:41 +0000 UTC]

ok arigato gozaimasu(thank you very mutch)

πŸ‘: 0 ⏩: 1

AnimeFan12354 In reply to inechiSAN [2009-02-18 17:14:51 +0000 UTC]

εΎ‘ζ—₯γ‚ˆδΊ”ε³Άγ™
ε…ƒζ°—οΌŸ

πŸ‘: 0 ⏩: 1

inechiSAN In reply to AnimeFan12354 [2009-02-19 01:23:24 +0000 UTC]

Goto the day I will
How are you?

gozaru? (@__@) well my translater sucks ass gozaru...

πŸ‘: 0 ⏩: 0

Evil-Crow [2008-12-23 11:50:42 +0000 UTC]

Oi Can u message me some good coding for a game like dragon fable?....i need help with EVERYTHING coding...menu, characters ect.

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to Evil-Crow [2008-12-23 13:24:18 +0000 UTC]

Yes I'll just code a multi-billion dollar 3d RPG game in Flash and then hand all the source code to you.
Might take... oh I don't know... infinity years seeing as it's pretty much impossible.
You have to LEARN to program yourself and ask when you have a problem with some code or are stumped on a situation, not ask for all the code to make your own game. Copy+Paste is only good for the first little while when you need examples of working code, mind you this tutorial is super old, the coding is not standard anymore and wasn't even "correct" for the time. It was pretty much made by me so other beginners could see a working example of what they could do with only learning some rather basic things and then go learn more on their own and expand on it.

I wish you luck.

πŸ‘: 0 ⏩: 0

carmiecarmela In reply to ??? [2008-08-13 13:34:41 +0000 UTC]

Thanks

πŸ‘: 0 ⏩: 0

carmiecarmela In reply to ??? [2008-08-09 04:26:38 +0000 UTC]

How do you change the "guy"? As in like if you click right arrow of your keyboard, he will face right and stuff..

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to carmiecarmela [2008-08-09 14:15:44 +0000 UTC]

You want him to face different directions?
Simply use rotation when the key is pressed.
EG:
if(Key.isDown(Key.RIGHT)){//when the right arrow key is down
guy._rotation=90//turn him to face at a 90 degree angle
//add w/e movement code you have
}
if(Key.isDown(Key.DOWN)){//when the down arrow key is down
guy._rotation=180//turn him to face at a 180 degree angle
//add w/e movement code you have
}

LEFT would be 270 or -90 depending on how you want to do it and UP would be 0

"guy" is the instance name of your character the player is controlling

πŸ‘: 0 ⏩: 0

Vinca In reply to ??? [2008-08-08 08:13:53 +0000 UTC]

Will it work on Flash 8?

πŸ‘: 0 ⏩: 0

fighterlegend In reply to ??? [2008-03-28 17:51:11 +0000 UTC]

umm.. about the stat thing.. can you send me the fla with the stats.. it wont work with me.. i have flash cs3 and using as2 :\

πŸ‘: 0 ⏩: 0

edster9 In reply to ??? [2008-03-23 19:12:49 +0000 UTC]

When I put the dynamic text boxes, where are people supposed to put numbers for strength,money,etc. when people are playing it? Like where can they put how much they want for each one?

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to edster9 [2008-03-23 19:22:36 +0000 UTC]

It's randomly generated their stats in this tut.
If you want them to be able to put in their own stats you could do it like this:
Make dynamic text boxes with the vars of strength, smarts, etc and have a button beside each one.
When you hit the button it'll use up one skill point and add one to the stat
eg:
var sp:Number=5//you can place 5 skill points
strength_button.onRelease=function(){//the button to add to strength stat
if(sp>=1){//if you have at least 1 skill point to use
strength++ //add to the stat
sp--//take a skill point away
}
}

πŸ‘: 0 ⏩: 1

edster9 In reply to Computer-Turret [2008-03-24 20:26:34 +0000 UTC]

Oh ok thanks that helped I'll be making my own game soon with your tutorial

πŸ‘: 0 ⏩: 0

Hawdon In reply to ??? [2007-11-14 21:51:14 +0000 UTC]

Could Some1 PLZ tell me what "VAR" is?
I know Im pritty much a noob...
And if u tell me what it is... Could u at the same time tell me where to find it?
Mine wont work.... Im guessing its because of the VAR.....
Plz tell me,......

πŸ‘: 0 ⏩: 1

Computer-Turret In reply to Hawdon [2007-11-15 01:58:42 +0000 UTC]

VAR is a variable.
A variable is anything that changes or can be changed.
Here's an old tut, sorry bought it being in AS1 but that's probably what you are coding in anyways....

What Is a Variable?
A variable is used to store information, which can be used later.

How do we use it?
In order to use it, we have to know the name of the variable. Let's do something easy to start off.

Click on your frame and press 'F9' for the actions panel to come up.
Type in this code:
Code:

myvariable = "Hi!"
trace(myvariable)

Now, the explaining.
myvariable represents our variable name; '=' sets the value.
The quotes ("") represents that it is a string, and we set the string to 'Hi!'.
Now I know what you're asking - what the heck is 'trace'?
Trace is a flash output command, which ONLY shows while developing, not when exported.
Press CTRL+ENTER to test it. Cool, right? Time to learn something better.
We're gonna add to the variable.

Code:

myvariable = "Hi!"
myvariable += " You're a fast learner!"
trace(myvariable)

Now this is easy to understand. We added:

Code:

myvariable += " You're a fast learner!"

Now, '+=' adds to something. String or number, either way it's '+='.
To delete something, use '-='.

Hey, you're pretty good!
Now delete all of the code, so we can do another cool thing with variables.

Is there anything that's actually useful with variables?
Yeah, tons! For one thing, they're used for health, magic and money in games.

Let's do something... useful.

Make a button. You know how right? Draw what you want as the button, and select it.
Then press 'F8' and select 'Button'.
Name it whatever you want. It doesn't really matter to me.

Now put it on the frame.
Then click the text tool, and make it not too big, not too small.
Set the type of text to 'dynamic' and put the variable as 'money' (in the properties panel after selecting it)
Put this code on your button.

Code:

on(release){
money += 1;
}

On the frame, put this code.

Code:

var money:Number = 1;

That's how to set a textbox variable - 'var' represents that it's a variable, 'money' tells what the variable name is, ':Number' tells what kind of variable it is going to be.

πŸ‘: 0 ⏩: 1

Hawdon In reply to Computer-Turret [2007-11-15 22:42:03 +0000 UTC]

hx

πŸ‘: 0 ⏩: 0

AznV In reply to ??? [2007-10-26 10:53:13 +0000 UTC]

I think I can use it! ^^

πŸ‘: 0 ⏩: 0


| Next =>