So today, obviously by the title, I am going to be showing you how to make a simple RPG with the theme of ninjas. Why? Cause everyone generally likes ninjas, plus it allows us to add some cool stuff.
I have two sections of everything. I show the newb way, and then if you have dabbed a little here and there, there's the other way. If you think you may already know a section, there should be something in italics under the sections title which will just explain in a few sentences what to do so you can skip to the next section. Note! Some stuff might be optional to read, so if you feel like you understand things pretty well, then you can skip them.
-Setting Up A DM Environment
-The Preset Coding (optional)
-Comments In Your Coding (optional)
-Mob and the Object Tree (optional)
-Variables and Output!
-Compiling and Running the Game! (optional)
-Switch and Input Procs
-What We Have Done!
--Setting Up A DM Environment
-Talks about how to create a new game environment!
If you already know what to do, make a new environment, call it Ninja RPG. Make the code files name Movement.dm.
Setting up a DM environment:
1) Open Dream Maker
2) File -> New Environment
3) Directory should be wherever you want your files to be. (I choose desktop)
4) Make the Name "Ninja RPG"
5) Another box should pop up asking about a .dm file, and naming it the name that we just chose, we want to name it "Movement.dmi" and save it.
6) You now have a code file and a game environment set up!
--The Preset Coding
-This is just an optional read
Now in this coding, you should see some code already in there, it should look like this:
Just don't worry about it. :D
-Explains the different types of files and how to make a new code file. You also learn how name your world and give it a hub.
If you know it, create a new code file, call it World and copy the coding into it.
Alright! The first thing we have to do with a new game is give program it's name in and whatnot!
1) File -> New...
2) Now, you see a drop down box that shows code file, icon file, map file, interface file, and script file. These are different files that contain different things. The code file (.dm) contains the coding of the game, the icon file (.dmi) contains the art, the map file (.dmm) contains the maps that you play on, the interface (.dmf) is the skin, GUI, graphical interface, or any other term you have for it, script file (.dms) is... well... I don't really know. I never use it, and when I have, it was way back in BYOND version 3.5. So... I'd imagine it's not going to be important in this RPG. But anyways, click "Code File"
3) Name it "World". NOTE: There is not need to put the extension (.dm) because we've chosen it to be a code file.
4) Click "OK"
Now we have just created a code file! Hurray! Now to the cool stuff. Write this in the coding (Don't forget to use the tabs!):
Now let me explain what you just did (I hope you put your key in there...). You can use world for many things! Here, we just used it for 2 things. We used it to name the game Ninja RPG and to set it's hub path that we connect to.
--Comments In Your Coding
-Optional. Explains how to use comments.
// is a comment in the language. Anything you write in // will be skipped over whenever you compile. /* */ is used for larger sums of text such as paragraphs. In this example, I explain what name and hub do with comments.
-How to call Login()!
If you already know this: Create a new code file called Login. Copy the code below.
Let's begin now on what happens when you log in the game! Let's create a new code file (.dm) and call it "Login". You might be telling me that I forgot the space between log and in, but you'll find out. We are going to use what's called a proc. Yay! Terminology! Proc stands for procedure. There are defined procedures in the DM code just how world and name are defined, Login() is one of them! Now you are probably wondering why I put the () at the end of the proc, Login. This is because () is what's called an operator. It's used to call a proc or verb. So here's how we call our Login() proc!
--Mob and the Object Tree
-Optional. Explanation about objects and mobs.
Mob stands for "Mobile Object"Â. Human players are known as mobs when they log in (Although this can actually be changed! But that's more advanced than what we are doing here). But this is why we call mob/Login(), so this how we control what happens when someone connects to the game! I like to think of mobs as humans, NPCs, monsters, anything that would "have life"Â in the real world. There are three other objects like mob that I will explain below.
The three objects are area, obj, and turf. Now just like how mob kinda resembles what it generally is, these do too! Area is kind of used for making regions on the map and mainly things that deal with... well... area! Turf is basically what it means! Turf! Ground! Examples of turf would be: grass, dirt, sand, water, buildings, trees, ect. Basically things that won't move, will always stay where they are, and are basically... just there. Obj stands for object. I like to think of these as items as anything that will move, but is not human, or will not be generally on the map. Pots, stoves, swords, shields, guns, fireballs, spells, bullets, and more, are generally coded as obj. So these are the four objects of dm: area, turf, obj, and mob. Together, they make up atom (first letter of each object).
--Variables and Output!
If you already know this, just copy the code and move on
Let's make it so that you get a welcome message and then it will ask you what kind of class you want to be! Here's the coding for a welcome message:
Oh snap! Did he just throw in some other stuff?! Yes he did! First let's talk about the statement:src << "Welcome to [world.name]". Src is a variable. What is a variable? Well as you ca see in the coding, there is a little line called var/class="None". I'll explain more about it, but just as an example, class is indicated a variable for mob. Src is a variable for the object that contains the verb or proc. So basically, src is YOU! << is another operator. It's an output operator that outputs whatever's on the right side to whomever's on the left! So here it's outputing "Welcome to [world.name]" to src! You might notice that I put the sentence in quotation marks. This is to define it as a string of text. Anything you put between those quotation marks will be outputted. Now for the final part of the line, [world.name]. This will ouput the world's name as we defined it (remember world/name="Ninja RPG"? That's what it will output!). This is how you will access any variables!
--Compiling and Running The Game!
-Explains how to compile and run the game!
Let's run the game so you can see what you've done so far!
1) Build â Compile (Compiling puts the code together so you may run it!)
NOTE! You should get this at the bottom output box:
loading Ninja RPG.dme
saving Ninja RPG.dmb (DEBUG mode)
Ninja RPG.dmb - 0 errors, 0 warnings
If you didn't, you must have made a spelling error or something. Make sure your code is identical to mine.
2) Build -> Run (Runs the game)
3) Gaze upon your creation!
Don't worry, eventually we will get this looking good!
-Explains how to change what data is in a variable
If you know this, just copy the code and move on.
Here's a better example of variables. As you can see in the coding, I put mob/var/class="None". Think of it this way, "Mob's class equals None". Now why use variables? We can make them equal anything in the coding! Let's make some variables and have them change in the coding!
So as you can see, I made a new variable for mob called weapon. If you notice near the end of the code, we did what is called defining a variable. We gave them a new meaning. Now src's class is Villager and src's weapon is Dagger, he's mighty tough. So this is how you can define variables in your game. You can make the weapon equal sword, staff, shield, anything! You can make the class equal sage, ninja, or Lummox Jr! It just don't matter! But let's make it so the player can choose what his class is, which will determine his weapon!
--Switch and Input Procs
-Explains and shows switch() and input() procs as well as how to allow the player to select what class they want.
If you know this, just copy the code and go on.
The reason why I didn't finish the code is because I want to explain the line I just typed. Switch() is a proc used to find something that equals what's in it's parenthesis. Cool huh? The input() proc is used (in this situation) to output a message asking the user through a little box what choice do they want to choose. The "What class do you want?" part of input() is the message part, basically what's the question going to be. The "Choose Class" part is the title of the box that will show in it's top left corner. The in list ("","","") is basically a list of the decisions they can choose. You can make as many as you want. Just add more commas and quotation marks. Now onto the next part!
-Explains how to use the if() statement and what it does!
If you know this, copy the code and move on.
Now here, I've added what's called an if() statement. It checks if what is inside it is what was chosen by the player. And then under it, I have the variables of the player being changed to define what he had chosen! Now let's finish it up for warrior ninja, and fearless ninja classes!
What We Have Done!
Alright! Now we've made it where the player can choose what his class is, but his weapon is decided on what class he chose. At the end, I put another output line so it will say that you are you, the class you are, who wields the weapon your class has!
I hope this helped you gain the basics of DM programming. I'll be making more to add to the Ninja RPG series of tutorials. The next one will be mainly based on maps and icons! Woohoo!
Note: If for some reason you are getting an error, make sure you coding is the same as mine. If you have checked and you still can't get it right, you can download the source of what we did today here and compare and make sure everything is right.(If link doesn't work, click this: http://files.byondhome.com/Ganing/Ninja%20RPG.zip )
I hope to do this at least once every two weeks. (This took roughly 3.5 hours to do >.<) Time to get some sleep! Questions, critique, and suggestions greatly accepted! I hope this wasn't oversimplified, I just really wanted to have a very detailed explanation of how to make a game for newbs who are still having problems truly grasping the language!!