HOME | DD

Computer-Turret — Flash RPG Tutorial

Published: 2007-10-27 20:54:02 +0000 UTC; Views: 16072; Favourites: 118; Downloads: 658
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]

Due to the massive success of the last RPG tut I made. I made a new, better, more up to date version.

Well what are you waiting for? Get going! Start building your own RPG.
Related content
Comments: 89

Risa884 [2011-05-24 22:59:57 +0000 UTC]

helpful

👍: 0 ⏩: 0

Hikara-chan [2011-05-03 00:27:45 +0000 UTC]

I suck balls

👍: 0 ⏩: 0

dumpaling [2011-02-18 21:17:21 +0000 UTC]

This was so helpful!

👍: 0 ⏩: 0

KawaiiSairen [2011-01-05 17:14:08 +0000 UTC]

do you know how to make a button go to a random frame?

👍: 0 ⏩: 1

Computer-Turret In reply to KawaiiSairen [2011-01-05 18:58:15 +0000 UTC]

Simply tell it to generate a random number in the range you want using random() [AS1/AS2] or Math.random() [AS1/AS2/AS3].
For example:

gotoAndStop(int(Math.random()*5));
Would generate a random number between 0 and 4 (not 5) and go to and stop on that frame. It is enclosed in int() to type cast it as an integer.

Math.random() generates a number in the range[0,1) (ie: 0.55674353 or whatever) then it is multiplied by 5 (change to whatever upper limit you want+1) to give 2.78371765, then the int() removes all the decimals resulting in just 2. So it then goes to frame 2!

More examples:

gotoAndStop(int(Math.random()*11)+5);
It will go to a random frame between 5 and 15. (Generates a number up to 10 and adds 5. If it generates 0 then it goes to frame 5 (lower limit), if it generates 10 then it goes to frame 15 (upper limit).

👍: 0 ⏩: 1

KawaiiSairen In reply to Computer-Turret [2011-01-05 19:05:34 +0000 UTC]

okay thanks

👍: 0 ⏩: 0

kaboom-wabit [2010-11-29 17:26:26 +0000 UTC]

um.. i am making this game, all i dont know is the save and load part >.< can you um.. tell me the codes
i dont know, it looks @.@ <-- mixed up or something XD

👍: 0 ⏩: 0

KawaiiSairen [2010-11-27 19:23:47 +0000 UTC]

hi, i was wondering, if you make a day feature, so that you sleep and it becomes day 2 and then next it becomes day three etc.
do you know how you make things happen on certain days?
i really need help

👍: 0 ⏩: 1

Computer-Turret In reply to KawaiiSairen [2010-11-27 21:10:38 +0000 UTC]

Well you could have a variable keep track of what day it is and increase it when the character sleeps. If you wanted certain events to happen on certain days just use an if statement to check if the day is correct if(day==2){ //have the event occur } or whatever.

👍: 0 ⏩: 1

KawaiiSairen In reply to Computer-Turret [2010-11-27 21:27:52 +0000 UTC]

ok thanks but how should i make the event?
i tried adding a code to go to another frame if it was day 2 but it didn't work.
here is the code just incase there is something wrong with it
--> if(day==2){ //have the event occur }
on (release) {
_root.gotoAndPlay("yaay");
}

oh and i was supposed to add it to a button right?

👍: 0 ⏩: 1

Computer-Turret In reply to KawaiiSairen [2010-11-28 00:01:48 +0000 UTC]

if you were to do it that way you'd have to do
on(release){
if(day==2){
//insert something to do, goto another frame?
}
}

I think you need to learn how to use if statements and understand the code you are writing rather than blindly copy and paste.

👍: 0 ⏩: 1

KawaiiSairen In reply to Computer-Turret [2010-11-28 10:35:06 +0000 UTC]

thank you!

yea i know but i can't really learn unless i ask someone to help me.
i have no other place to learn from

but thank you really much!

👍: 0 ⏩: 0

Menestria [2010-11-24 11:56:38 +0000 UTC]

Which code did you use ? Actionscript 2 or 3 ? Thank you !

👍: 0 ⏩: 1

Computer-Turret In reply to Menestria [2010-11-24 19:54:44 +0000 UTC]

Now? AS3. In the tutorial? AS1/2.

👍: 0 ⏩: 1

Menestria In reply to Computer-Turret [2010-11-25 19:23:54 +0000 UTC]

OK, thank you

👍: 0 ⏩: 0

KawaiiSairen [2010-11-16 20:00:38 +0000 UTC]

thanks for making this ^^
but on my energy stats it says: Energy:undefined/200
? how do i remove the "undefined" part?

👍: 0 ⏩: 1

Computer-Turret In reply to KawaiiSairen [2010-11-16 21:08:34 +0000 UTC]

It means that you have a variable name wrong somewhere most likely. It's saying "undefined" because the variable isn't defined >_<.

👍: 0 ⏩: 1

KawaiiSairen In reply to Computer-Turret [2010-11-17 16:18:11 +0000 UTC]

but i checket it it seemes to be rigth names but it won't work i used this code

your_button.onRelease=function(){
//"your_button" is the buttons instance name
if(show_cash>=10){//check if you have 10 or more cash
//"your_cash" is your variable for money in the game
show_energy+=1//train you to be stronger or if you are buying an item
//or something you can put whatever code to activate the item there instead
show_cash-=10
//you bought something, you give them the cash for it
}
//close our brackets

(i am just exploring with codes XD)

and the dynamic text boxes that says undefined has the vars show_energy and
show_cash

please help

👍: 0 ⏩: 1

Computer-Turret In reply to KawaiiSairen [2010-11-17 22:03:03 +0000 UTC]

Did you set any default values for the vars?

👍: 0 ⏩: 1

KawaiiSairen In reply to Computer-Turret [2010-11-18 15:21:57 +0000 UTC]

i don't think so, where is it?

👍: 0 ⏩: 0

sonyscreens [2010-08-16 21:49:11 +0000 UTC]

Nice tutorial!

Do you think you could help me with something? No one seems to have a tutorial for talking with NPCs. :/

👍: 0 ⏩: 1

Computer-Turret In reply to sonyscreens [2010-08-16 22:19:55 +0000 UTC]

There are a lot of ways you can do that.

Just a matter of how you want to do this:
?hero is close to an NPC?
//could be done using hittest or checking if x,y coords are in a certain range of the NPC's x,y coords

?button to talk to an NPC is pressed?
//pretty straight forward


//if they just say one thing and you don't talk back just have a pop up with what the npc has to say?
//if you want to have different options to reply back with or just yes/no answers or simply have to press a button to continue then it get's a little harder but then it's just displaying different things based on the choice the player makes.

Really there are dozens of ways to go about it, not sure what kind of conversation engine you want.

👍: 0 ⏩: 1

sonyscreens In reply to Computer-Turret [2010-08-16 22:28:51 +0000 UTC]

I will have the player press a key when touching the npc to start the talking. I can do that.

The conversation part will be straighforward, just pressing a button to continue through the conversation. Like an RPG style box.

However, I can't figure out how I would get the text box into position and also keep the player from moving during the conversation.

Thank you.

👍: 0 ⏩: 1

Computer-Turret In reply to sonyscreens [2010-08-16 23:07:08 +0000 UTC]

Well have your movement code wrapped in a check if(!talking){//movement code } and so when you start a conversation talking=true and when the conversation ends have talking=false. That way it'll only let you move if talking is not true (ie: false).
Not sure what you mean by textbox, like a speech bubble or just a box that appears at the bottom of the screen?

👍: 0 ⏩: 1

sonyscreens In reply to Computer-Turret [2010-08-17 15:29:56 +0000 UTC]

Okay. I can do that.

I want a box at the bottom at the screen.

How can I go about doing that? Should I just leave it there invisible and have it appear when the conversation starts?

My other idea was to have all the conversations off screen and have them track the player like a vcam when activated.

👍: 0 ⏩: 1

Computer-Turret In reply to sonyscreens [2010-08-17 18:07:26 +0000 UTC]

Oh I just assumed you'd have a movieclip of the conversation window with a dynamic text box inside of it and just change what the textbox reads when you talk to different people.

conversationMC.conversationText="Matt: Halt criminal scum!";

You could have it visible=false when not in conversation or good practice would have you remove it and reattach it to the stage when you start a conversation. (likewise removing when done conversation).

👍: 0 ⏩: 1

sonyscreens In reply to Computer-Turret [2010-08-17 19:09:32 +0000 UTC]

Okay! I can try that.


Thank you for all your help!

👍: 0 ⏩: 1

Computer-Turret In reply to sonyscreens [2010-08-17 20:10:06 +0000 UTC]

Anytime, if you have any more feel free to ask.

👍: 0 ⏩: 1

sonyscreens In reply to Computer-Turret [2010-08-17 20:32:43 +0000 UTC]

Then can you help me with attaching the conversation? It is a movieclip.

And I have changed my method. You have to click the exclamation point above the NPC's head to talk. It only appears on contact.

Would I use attachMovie() for the conversation box? I've never used that function so I'm lost. Or is there a better way?

👍: 0 ⏩: 1

Computer-Turret In reply to sonyscreens [2010-08-17 21:28:59 +0000 UTC]

You should read the adobe docs
[link]
I'd love to be like, hey you should just learn AS3 and skip this obsolete shit! But that wont help you.

Basically you have to give the movieclip in the library a linkage name which you then use in actionscript to call it and add it to the stage. When you do this though you have to give it a new name and a "depth" (so it knows if it's above or below other movieclips). Then you can reference the new name any time after that like you would any instance name of a movieclip.

👍: 0 ⏩: 1

sonyscreens In reply to Computer-Turret [2010-08-17 23:33:55 +0000 UTC]

Thank you.

👍: 0 ⏩: 0

The-fishy-one [2010-02-27 21:47:26 +0000 UTC]

Thanks for sharing this tut, man! One of the most detailed I've ever seen.

[ This is TheFishyOne from the XGen Forums, if you remember me. The one that was asking a lot of questions on his failed RPG. ]

👍: 0 ⏩: 1

Computer-Turret In reply to The-fishy-one [2010-02-27 21:55:00 +0000 UTC]

It's not perfect nor the best but it's as good a spot to start as any I guess.
I do remember your threads and I'm glad it helps.

👍: 0 ⏩: 1

The-fishy-one In reply to Computer-Turret [2010-02-27 22:25:37 +0000 UTC]

Not quite a start for me but I DO have learnt some new techs, which I find really helpful and a simpler way to put them than kilometric code.

👍: 0 ⏩: 0

StarCrystalDreams [2009-11-07 05:19:28 +0000 UTC]

Hi~ Thanks for your tutorial, I wanted to make an RPG for my friend. I have one question though. How do you make multiple characters? Like, for example, you choose whether you are a boy or a girl, or different characters, like "Lily" or "Sarah" or "John"?

Thanks in advance

👍: 0 ⏩: 1

Computer-Turret In reply to StarCrystalDreams [2009-11-07 15:22:47 +0000 UTC]

There are multiple ways to that, much like anything done in Flash. Rather than try to explain I'll just whip up an example quickly.
Example (swf): [link]
Example (fla): [link]

👍: 0 ⏩: 1

StarCrystalDreams In reply to Computer-Turret [2009-11-08 04:19:19 +0000 UTC]

Thank you for the info!

👍: 0 ⏩: 0

Princess-Peachie [2009-11-06 14:49:22 +0000 UTC]

When I get Flash CS3 for Christmas I'm totally going to try this out. I've got MX right now it won't work, but soon!
Great job on this by the way. Thank you for it!!

👍: 0 ⏩: 0

alexw99 [2009-07-26 22:46:39 +0000 UTC]

all your lonks dont work for me. iv got flash mx

👍: 0 ⏩: 1

Computer-Turret In reply to alexw99 [2009-07-26 23:35:57 +0000 UTC]

Ug, I can't save that far back. I'm using CS3 so the farthest back I can save is Flash 8.
Any chance you could "get" a better version.

👍: 0 ⏩: 1

alexw99 In reply to Computer-Turret [2009-07-28 18:16:30 +0000 UTC]

they cost a frikkin lot! i dont fink so sorry

👍: 0 ⏩: 1

Computer-Turret In reply to alexw99 [2009-07-28 19:08:18 +0000 UTC]

cough pirate cough

👍: 0 ⏩: 1

itty-bitty-stock In reply to Computer-Turret [2011-06-23 19:00:20 +0000 UTC]

XD you sound just like my best friend and I.

👍: 0 ⏩: 0

alexw99 [2009-07-26 17:50:09 +0000 UTC]

dont worry i sorted it out!
but could you be able to add doors?

👍: 0 ⏩: 2

Computer-Turret In reply to alexw99 [2009-07-26 20:57:26 +0000 UTC]

Also, if you wanted to enter and exit buildings at the correct location you could do something like I did in this engine. [link] which involves saving the x,y and placing the hero/player there when you exit the building/go back to the main map.

👍: 0 ⏩: 0

Computer-Turret In reply to alexw99 [2009-07-26 20:55:05 +0000 UTC]

You could easily just have an invisible hittest area in front of a building's door that when the hero/player hits it, it goes to the frame where you can walk around inside. Much like I did here [link] (the red arrow on the left leads to another frame with the fight) only with a door and instead of a fight, another map with different walls, etc.
Source of above: [link]

👍: 0 ⏩: 0

alexw99 [2009-07-26 16:51:52 +0000 UTC]

i have a problom i checked all the coads and i can still get through the walls why?

👍: 0 ⏩: 0

Mitsuray [2009-07-08 20:25:33 +0000 UTC]

i hope you can help me with this, i have been searching for some time now and i just can't find a explanation of the battle to game transition... (so your gonna be the "victim" )

When you go into a battle, you change frame (ok, normal...) but then when you win and wanna go back to the game, how do you do it so that your character is on the place where you left it before entering this random battle and not always on a certain place you defined him to appear initially...

👍: 0 ⏩: 1

Computer-Turret In reply to Mitsuray [2009-07-09 11:26:58 +0000 UTC]

well on the game stage have to initial X and Y variables to place where the hero/main character is.
Say on the menu screen before playing have them set to whereever you want him to start
var intX:Number=300
var intY:Number=320
Then on the game frame, make him go to those x,y values right away first (hero._x=intX and hero._y=intY) and then you can move from there. Then just before you enter a fight or a building, save new intX=heroInstance._x and same for intY=heroInstance._y
So when he comes back to the game frame he'll instantly return to the newly set x,y position.

I can make an example later if you need more help. I'm short on time and have to go!

👍: 0 ⏩: 1

Mitsuray In reply to Computer-Turret [2009-07-09 22:43:13 +0000 UTC]

Thanks a lot for the response to start off!

And well, i got almost everything, i just don't really get what was heroInstance, is it like somthing invisible just to mark his "spot" so when he ends the fight he goes back to the "spot"?

Also, this is suposed to be a random encounter (dunno if you had that in mind or not, but since i can't really understand the heroInstance i can't really tell).

Also (another also ), does this work with vCam stuff? I never really tryed the vCam but from what i got somthing you can do with it is like making everything move exept somthing (in this case would be the hero), so if everything else moved and the hero was kept in the middle he would always go back there but how would the stuff around him be?

Dunno if you could understand my doubts lol...

Thanks a lot for your answer in 1st place, even if it doesn't work with the vCam i'm pretty sure i will be able to it with a lot of static screens xD (as long as i can understand what's that heroInstance if you are gonna have the patience to re-answer to me or if you don't wanna answer to this stuff here you could make a more elaborate flash tut or somthing with this kind of issue and put on your page [maybe you could help more peopl that way since we are on comment page 2 some people wont even notice your extreme help])

👍: 0 ⏩: 2


| Next =>