Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 [Tutorial] Graphical RPG
Index -> Programming, Turing -> Turing Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message

PostPosted: Sat Dec 13, 2003 6:30 pm   Post subject: [Tutorial] Graphical RPG

I have a few motivations for writing this tutorial, the first being that many new programmers first ambitions for starting to learn programming is to create some awesome game to impress everybody, and make themselves look almighty. (Also to control a few peoples lives, heh. Wink ) The second being I would love to have some bits, so if you like this tutorial, learn something from this tutorial, or are interested while reading this tutorial, please donate bits. Very Happy

Step 1
The Planning Process
Normally, Role Playing Games do not end up good, if you dont know what your doing, makes sense right? I suggest setting out an hour or two of quiet time, taking a pen and paper, go into a silent place, and think. What is good about an RPG? What do people like in an RPG? Why do I like in an RPG? Write these ideas down, because they are all important. Here are a few things you must decide: when will this RPG be taking place? (present, past, future....dark ages, feudal ages, alien homeworld) Then think of what kind of characters you want in the game. (Humans, monsters, demons, aliens, whatdotcolor warriors...) After these are done, you'll want to think about what can be done in this game. (killing monsters, levelling up, increasing stats, getting better weapons/armor, gaining new allies, destroying big bosses, etc.) Then think of a goal for the user to accomplish in the game.
Everything that has a beginning, has an end...

(ex. You must raise your magic and strength to be all powerful, and once this is accomplished, you may travel through the Woods of Desolation, and travel up to Hells Tower. Only there will you face off against the ultimate evil...who you must destroy to save everything that is, and will come to be!) Then you may want to think of certain challenges in the way in your quest. (Like a Giant Horrid Ogre, who can only be gotten past, if you feed it the Elixir of Weakness at the stroke of midnight.) From each of these encounters, the player should probably receive some reward, like a new weapon, or a powerful arcane spellbook. After this, you will probably want to take out a big piece of grid paper, size it in pixels, draw the four sectors (or quandrants)...then draw up a map. This process makes the game immensley easy. But! do not make it out to be the dimensions of the screen (640*400), make it much larger. Ill explain this later though. Then you will probably want to think or some sort of skill tree, or circle of spells.. its easier if you do this now, believe me. With all these steps done, your far into your way to making a great, graphical RPG!

Step 2
The Drawing Process
This will only be needed if you are not importing your own images.
Open up something like MSPaint, and draw a grid of squares, 10*10. Each square should be 10 pixels across and above. This will help you quite easily in the item, character, enemy, map design process. Now on this grid, draw whatever you want to see in your game. (ex. the hero) Make an (x,y) co-ordinate, (maybe at the chest) as a starting point. Open up Turing beside this Window (sized down), and start measuring away. Make Draw.Line commands based on lines relative to the x and y co-ordinates.
(Draw.Line(x-50, y-30,x+10,y+30,255)

Step 3
The Programming Process

The Secret to Scrolling
Make scrolling games is pretty much up to a few arrays. Make an array called "object_x" and "object_y". For every object, whether a tree, fence, wall, castle. Make the "object_x,object_y" equal to each of their (x,y) co-ordinates (as explained above). Now for movement, when the user right clicks to move, (if mouse_button=100) then record that as destination_x, and destination_y (and a variable called unit_moving. Make it equal to "yes"). Now do something like:

if unit_moving="yes" then
   if destination_x>unit_x then
     for i:1..length(object_x)
     end for
   elsif destination_x<unit_x then
     for i:1..length(object_x)
     end for
   end if
   if destination_y>unit_y then
     for i:1..length(object_y)
     end for
   elsif destination_y<unit_y then
     for i:1..length(object_y)
     end for
   end for
end if
if unit_collided_with_object="yes" or  unit_reached_destination="yes" then
end if

This is the ultimighty secret many people have been after. And YES, I do not that this will continue scrolling, and does not have a trigger that checks if its reached its destination. Im leaving that up to you. Wink
That code means, for example, if the player right clicks and the destination_x and the destination_y is greater then the unit_x and the unit_y...then the map object_x and map object_y will decrease by 1. This makes the map scroll for the character. The sprite is in the centre, while it looks like he is moving, the map is actually moving to give the scrolling effect. This can also work for saving items if they drop on the ground. Just make a new array called dropped_items_x and dropped_items_y. And wh enever the unit moves, it goes through those arrays making them scroll as well. Very Happy

Buttons and Controls
In your game, you'll probably want to have some buttons that open up new windows that show your stats, inventory, equipment, spells, and so forth. You can either use GUI Buttons for this, or make your own.

if (mouse_button=1) and (mouse_x<300 and mouse_x>100) and (mouse_y<200 and mouse_y>100) then
%^^Do a procedure for the button clicked
end if

Then these procedures will open up new windows showing the player what you program to show them.

Fighting is a little difficult, but I said " a little ". When the map scrolls, so should the monsters_x and monsters_y too. So there should be some statement that checks if the monsters_x and monsters_y are in a certain sight range of the hero, and if they both are, the statement should move the monsters_x and monsters_y according to what sector they are in, to attack you. Then there should be some statement that checks if the monster is beside the hero, and if it is, it attacks every certain amount of time. This can be some 'counter' array, that counts miliseconds between attacks. Then if the hero right clicks, and the mouse_x and mouse_y of the click is within (ex. 50 pixels) of the monsters_x and monsters_y, then hero should have an attacking graphic, which does damage to the monster. Now at the start of your programs loop, it should check in the monsters_hp array to see if its hp is less or equal to 0. If it is, it should drop a random amount of gold, and the player should have a random chance of getting some item drop from the monster.

The Conclusion
Well, in conclusion, if you follow these steps, you should be able to create a DAMN good graphical RPG! I wish every one of you reading this the best luck in all your games, and hope some of you will please donate bits.
Thanks for Reading![/u]

PostPosted: Sat Dec 13, 2003 6:44 pm   Post subject: (No subject)

cool tutorial, here, have some bits.


btw, if anyone needs help on scrolling, download me and SilverSprite's Ultimate Mario game, it's in the turing submission forum and submitted as a [FP]. The part I did was all about scrolling and different perspectives, check out the code.

PostPosted: Sat Dec 13, 2003 6:47 pm   Post subject: (No subject)

Thanks! I tried your kept having problems loading the images, heh.

PostPosted: Sat Dec 13, 2003 7:28 pm   Post subject: (No subject)

8) +Bits
Latest from Tony's programming blog. DWITE - a programming contest.

PostPosted: Tue Dec 16, 2003 12:42 pm   Post subject: (No subject)

i will just add this here, i posted this some where eltes but i think it will be more usefull here.

How to make a title sytem for your rpg:

a title system is a way of making maps that are easy to tell where the person is and what is to each side of them. it also lets you make maps realy fast and have a good effect.

here is the basick idea on making one:

1. you make titles for each type of texchure in your rpg, like grass, part of a house, a wall, a fence, ect. each of thess whould be a small bmp, may be 24 by 24.

2. then you name each of thess title 1, 2, 3, ect (ex. 1.bmp)

3. now you deside how big your playing area will be, rember that it has to be made out of titles that are the same size like in my exaple 24 by 24. so lets say you deside to make it 20 tilies by 20 titles. so now you have to make a map file now wich is just a file with the numbers that rep the bmp files. ie. a 1 whould be 1.bmp. this file has to flower your desions on how may tiles by tiles you whont. so in 20 by 20 your file whould have to have 20 rows of numbers and 20 coloms of numbers.

4. now for the hard part. you need to code some fuctions to read the map file and put the data in to array. then you need to make a fuction that uses this array and then loads all the pic files (ie. 1.bmp) and then draws them on the screen in the right spost.

Note: you can load the pics easly b/c they are in fromat num.bmp.

5. now that you got the map on the screen you need to make and equation to covert the x,y loaction of you cather to a row and colom number based on your title grid.

6. now b/c you know what part of the grid the guy is on you can then pulg thous numbers in to the array that has the typles of titles in it to find out what type of title your guy is on.

7. using this info you now can do serveral things:

i. make genreal staments about what to do if guy gose on a scerent type of title (ex. go thougth a door or walk in to lava)

ii. using this info you can also tell what is in front, behind, to the left and to the right of you by adding or subatring one to the colom or row num in the array. this will let you do the colcion dection b/c if there is a wall tite to your right you set it so the guy can not move right.

8. now once you got all this done, code and wroking right with will take some time, you can now make tones of maps very fast with out much eforect at all.

And it is that easys Razz
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!

PostPosted: Thu Dec 25, 2003 11:32 am   Post subject: (No subject)

Or if your bored/lazy, program a map editor like the one I did at:
lol...ill probably hand that in with my final so lame Wink
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to: