BYOND chapter I: What is Byond? Basic Coding
WHAT IS BYOND?
BYOND is the premier community for making and playing online multiplayer games. As a player, enjoy hundreds of games created by our community, by people just like you. As a developer, make your own indie sensation with an easy-to-learn language, built-in online support, tools for developers, and plenty of articles and tutorials.
http://www.byond.com/games/hubpic/63873_6094_s.jpg
WHERE CAN I GET IT?
As I mentioned before, Byond is absolutely free, and the coding is incredibly easy to learn and gives you a basic understanding of how coding works for any style. In this tutorial, I'll get you started and teach you how to make your own game.
LETS GET STARTED
First, make sure you download Byond (link above). When you do, it'll come with 3 tools.
-"BYOND" which is the pager so you can play games right from your desktop and IRC with friends
-"DREAM MAKER" which is the program we'll be using to code and create our own games
-"DREAM DAEMON" which is the program used to host your games online for others to play
So for now, open "DREAM MAKER" and we can get started.
STEP 1:
http://i223.photobucket.com/albums/d...joe/byond1.png
When you open Dream Maker, this is the first thing you'll see. This is the general interface of the program.
Click "File > New Environment" and lets name it "Test World"
Now it'll ask you to create a Code (.dm) file. Just name it "Test World"
http://i223.photobucket.com/albums/d...joe/byond2.png
STEP 2:
Okay, so now we're going to make our Sprites first.
Click "File" > "New" and change the box from "Code File" to "Icon File" in the dropdown box. Lets name that "Player" and click [OK]. It'll open a new (.dmi) file on the left-hand side with an image of a Paint Pallet and a Video Camera.
For this example, I'll use sprites from Spriters Resource.
Click Here: The Spriters Resource | Main Page
That will take you to a website with ripped videogame sprites.
1. Go to "Gameboy Advance" on the left hand side bar.
2. Click "P" on the alphabet on the top of the webpage.
3. Look for "Pokemon FireRed/Leaf Green", and click it. It'll open sprite images.
4. Click "Ruby and Sapphire Heroes" and it'll open a new page with the sprite sheet.
5. "Right Click > Save As" and save it somewhere you'll remember it.
6. Go to the path you saved the sprite sheet in, right click it, and Open it with Paint.
7. You should see multiple directions for each character. Zoom in, and use the Selection tool to select your character.
8. CTRL+C (copy) the selected sprite
9. Go back to DREAM MAKER, and click the Video camera icon. It will open a 3x4 cell page with Directional arrows pointing Down, Up, Left, and Right. These are the directions you push on the keyboard to make your character move.
10. Double Click on the first cell in the Down section (top left corner), and Paste your copied sprite into the Pallet. Click the "Flood" option on the left and right-click around your character until all you have is the character itself, as seen below.
http://i223.photobucket.com/albums/d...e/byond4-1.png
11. After that's done, do the same with the other motions of your sprite on the sprite sheet you have open in MSPaint until you get a screen that looks like this.
http://i223.photobucket.com/albums/d...joe/byond6.png
12. Click the number above each cell "should be 1" and change it to "2". The higher the number, the slower their sprite moves. No sense running a million mph to go 2 feet.
13. Click "Back" on the bottom right hand corner, and it'll bring you back to the sprite sheet. Right-Click on the small image of the sprite you just made, and click "Edit State". Name it "male" and select the box "Movement State"
http://i223.photobucket.com/albums/d...joe/byond5.png
STEP 3:
Now we'll make our Turf (Grass, Water, etc.)
To do this, go to "File>New" and create another icon file (.dmi) but name this one "turf"
Now instead of selecting the Videocamera, we'll select the Paint Pallet icon.
Select the "Flood" tool, and Green on the color pallet. Paint it all green, and name it "grass".
Make another one, make it blue, and name it "water"
http://i223.photobucket.com/albums/d...joe/byond7.png
Now, we'll go ahead code all of this in. Make 2 new code files
Click "File>New" and select "code file (.dm)" in the first box, and name the second one Player, then do the same and name the second code file "Turf"
http://i223.photobucket.com/albums/d...joe/byond8.png
Below is the code we'll enter for the Turf. I'll break it down for you.
http://i223.photobucket.com/albums/d...joe/byond9.png
Code:
turf (you put it as the parent code for environment icons)
Code:
Grass (the title of the icon)
Code:
icon = 'turf.dmi' (This means the icon is in the "turf.dmi" file)
Code:
icon_state = "grass" (This means the icon in that file is titled "grass"
Code:
density = 1 (This means you can't pass through it.)
Code:
verb (we're going to make the water have an option)
Code:
Look() (the name of the option. We want to look at the water)
Code:
set src in oview(1) (The src(icon) has to be one pixel away in your view for you to use the "look" option)
Code:
usr << "You see your reflection" (You get a message on the side telling you "You see your reflection"
Notice, we have the code indented (press Tab to do so after each line)
This means that the child code (icon, density, etc.) is in the parent code (grass)
Think of it as an Adjective. Something describing something else.
Verb means we're making this icon do something, or have an option. Now this water in game will have a "Look" option when we right click on it.
Now lets go to "Player.dm" and enter this code for the Male
http://i223.photobucket.com/albums/d...oe/byond10.png
It's the same as before, we're just establishing that the Mob (user/character) is an icon named "male" in the file 'player.dmi'
**IMPORTANT NOTE**
Capitalization and correct spelling is key in coding
http://i223.photobucket.com/albums/d...oe/byond11.png
STEP 4:
Now that we have that, lets create our World.
Click "File>New" and make a Map file now. The Map works on an "X,Y,Z" basis.
X is how many icon-spaces horizontal
Y is how many icon-spaces vertical
Z is how many of these sections exist.
Lets name our Map file "world"
http://i223.photobucket.com/albums/d...oe/byond12.png
Before we click it, we're going to click "Ctrl+K" on the Keyboard. This Compiles (saves) your project and checks it for Errors. Right now, you should have no errors.
http://i223.photobucket.com/albums/d...oe/byond13.png
http://i223.photobucket.com/albums/d...oe/byond14.png
Now, we're going to fill the blank space with Grass and Water. DO NOT cover the bottom left hand corner of the map in Water, because that's where you start.
our water is Dense. If you start in it right now, you can't move. So make the water go around it.
When that's finished, click the "File" tab on the left hand side above your list of icons, and click the "TestWorld.dm" option. That'll bring us back to the code. Now we want to code in our character so we can actually start in this world.
Make sure your code looks Exactly like mine.
we're going to name our world "Test World", as you can see
we're also going to put in "/turf/Grass".
What this does, is automatically fills our map with Grass as the base icon so we don't have to.
We're going to also put our character in the Mob section, only this time we're not going to put "male" after the "mob".
Mob (Stating it's your character)
Icon = 'player.dmi' (this is where the Icon is)
Icon_state = "male" (this is what the icon is called)
Now lets Compile (ctrl+K) our game, and Run it (ctrl+R)
http://i223.photobucket.com/albums/d...oe/byond15.png
SEE MORE IN CHAPTER II
Quick Notes and Meanings
MOBS
"Mob" means in order for the verb to work, a mob must exist in the world
Mobs can be NPCs, You, and other players.
Mob is short for "Mobile"
Mob is a "parent", which is the code the verb, proc, etc. belongs to. Those are the children.
VERBS
"Verbs" are what you do. Verb is a child code to Mob (parent), but can also be a parent to other code such as "Say". (Since "Say" is what you're doing)
Verbs take "Arguments"
With a verb, Arguments come from the player.
ARGUMENTS
Arguments are "Input" for the player.
Common Arguments are abbreviations for bigger words.
In this case, it's "msg", short for "message".
You can call an argument anything you want. it's best to go with something short and easier to type
OPERATOR
The Operator is the "<<" signs. (Two lesser-than signs)
Operators are Symbols placed between things that cause specific things to happen.
Example:
with "<<" the Right side is being output to the left side, which is the Whole world.
"world << "hello my name is Plague"
"world >> "eugalP si eman ym olleh"
IMBEDDED EXPRESSIONS
Imbedded Expressions are the quotes that go around something, or anything similar.
With quotes around something, it means the whole thing is a text string. What the player typed in, our msg, is a text string. or "text".
When something is a text string, it has the [] brackets around it. That's called an embedded expression.
Example:
A nugget buried in our text string
KEY: Whenever you embed something in brackets, that means its going to get replaced as the user sees it.
Example: [usr] is replaced by the Username.
Example: [msg] is replaced by the Message
COMPILING AND RUNNING
Go under the Build menu and choose "Compile."
Bottom menu will say:
Loading Testworld.dme
Saving Testworld.dmb
Testworld.dmb - 0 errors, 0 warnings
ICONS
To make a new icon, go to File>New>Icon File(.dmi)
Use Icon files to create Icons for your game. Its best to keep them seperate
ICON STATES
After you've made your icon, go to the .dmi file it's located in, double click underneath your icon, and you'll be able to change the name of it.
The name of that icon that you choose is its Icon State.
PROCS
Proc is short for Procedure.
Procs are littel bits of code that make all the action happen
Every proc has Parentheses () after its name.
When your game is ordered to do something, it "calls" a Proc.
Example: Login() gets called automatically when a player logs in
Example: Logout() gets called automatically when a player logs out
Example: the ..() command says to go call the actual Built-in Login() proc. Thats what puts us on the map.
IMPORANT: The Login() I coded is a child, and it doesn't know everything the parent does. So we tell it to go ask its parent what to do with that ..() line.
VARS
Var is short for Variable.
Characteristics of Mobs and Turfs (such as Icon and Gender) are built-in variables.
A variable is a place where a bit of data is stored. It's called a variable because we can change it at will, so the info it gets can vary