ID:278400
 
========== CREATING A BASIC WORLD ==========
================ PART 2 ================

==|Includes|==
1 : Setting Your Preferences
2 : Creating The Player
3 : Creating The Tiles
4 : Pre-Map Work
5 : Create The Map
6 : Compile and Run

# Setting Your Preferences #

All right just before you get into some coding, you need to make sure you have Tabs enabled. These make coding much more simple. To activate tabs :

Go into a code file and then click on the options tab at the top and then click "Code Preferences".

Now click on tabs and then make sure everything is set as shown :




To use tabs you press the tab button on your keyboard. This is used instead of spaces so instead of having to remember how many spaces to use for different situations, you can just use "Tab" for all.


Alright you're almost there. Now we can start writing some code! Again, this is far more simple than it sounds.




#Creating The Player#

Okay, go to your code file named "Player.dm" by double clicking on it. Inside it will be completely blank but not for long. Underneath I'm going to write some code, you can choose to copy and paste it or write it out yourself. You'll learn more if write it yourself though.

I have added comments, this is like a virtual note. A comment is started by two forward slashes "//". They are ignored by Byond but you can always look back on them to remember how systems work. It is good practice to use comments but don't go overboard, remember only where necessary.

mob //This is a mobile object that can be controlled.
icon = 'Icons.dmi' // The icon for this mob is found in this file.
icon_state = "Player" // The icon in that file is called.
density = 1 // The player is dense/solid.


Okay so what does this all mean. Well first off we are defining what is known as a Mobile Object or mob for short. We choose mob because we need something the player can control and move around with as is common is nearly all games.

Next we need to think about what the "mob" is. It's the player so it should have those player graphics we made earlier. Well Byond needs to know two things for us to do that. First off, what file can it find the icon in (icon = 'Icons.dmi'). Two, where in that file is the icon (icon_state = "Player").

The last thing there is "density". This tells Byond that the player is solid. By solid I mean that objects can't pass through it. Imagine seeing a person walk through walls, it's impossible because we as humans are solid or "dense".




#Creating The Tiles#

Well you will remember we made some tiles earlier. They were called "Water" and "Grass". To bring these into our environment we will need to define them so Byond understands what they are. Go into your code file called "Tiles.dm". Here's the code again and I'll review what it all does underneath.

turf
icon = 'Icons.dmi' // This time icon covers both Grass and Water because they all fall under it.
Grass
icon_state = "Grass"
Water
icon_state = "Water"
density = 1 // Water has been made dense so you can't move through it.


Now as you can see this isn't a lot different to how we defined a player. The major difference is that we call this a turf. When you think of turf, try to think of the ground or terrain. It can't move and can't be controlled. It's simply to allow you to create a map. This is what Byond understands a turf is.

Next we define icon once more but it is a little bit different. Now because we're talking about two objects not 1 and we know they both have their icons in the same file we put it above them. This means that anything after that line will have it's icon in 'Icons.dmi'.

After that we define "Grass", this is the name of the turf. It will always be recognized as "Grass".

Now underneath that in the tree is it's icon state just like what we did with the mob.

Water is a little more tricky because we've added "density = 1". This is just so that when a mobile object tries to pass through water, it can't.




#Pre Map Work#

Alright with those all working we can move onto the code file we called world. This is going to be really simple, don't worry. Here's the code you need to put in there :

world
turf = /turf/Grass


Okay now what can I be talking about, I've defined turfs and a mob so what is world? Well the world is basically what we use to shape our environment. It holds a lot of useful information which we can change. For example we changed the information or 'variable' turf to "/turf/Grass" . "turf" when used under "world" is talking about the default turf. This is the turf which by default will always be the used. That will make more sense when we map a map which is next. Don't worry to much about world, it's not used very often.




#Creating a Map#

Now double click on your "Map.dmm" file. You should see this :



On the left is what's known as the object tree. It's the visual representation of that code you just added. If you press the "+" button next to turf you'll see the turfs. They won't come up automatically.

So let's get started on mapping then! Click on the Grass or Water tiles on the left hand side and using the "Add" or "Fill" buttons start drawing your map. It's a lot like making your first icon. Just click and drag.

It doesn't matter how you design your map, as long as there is water and grass and all the tiles are filled.

Don't worry about the mobs you can place. They aren't where the player will start from. I'll go over this in later tutorials, for now the player will start in the first place it can.





#Compiling#

Hurray you have finished your first world. Now you can compile and run it. To do that press the "Build" button on the top bar and then Compile. Now do the same again but click run.

This is what you want to happen when you compile :



If not something has gone wrong. Don't fret, it's easy to make mistakes so please go back over the tutorial and see if you've missed anything or added anything that shouldn't be there.

Assuming your game runs okay then congratulations, remember use your arrows keys to move around.







im just wondering......do any tutorials cover anything else than attaching mob to player and making a turf >_>
In response to MademanOne (#1)
I'm going to do more covering a lot of basic questions. Don't worry, this is just the start.