MySQL FIX: Row handle referred to a deleted row or a row marked for deletion.

Comments 5 Standard

Okay, so this could be a few things. Usually this means mysql is trying to access a row that you’ve already deleted. However I happened to get this error just by doing a select statement (and I hadn’t updated or deleted anything — go figure). I believe SQL didn’t like order in which I was selecting the fields. To diagnose the problem I broke the SQL down and gradually added the fields I’d selected back in piece by piece. Once I’d done this everything was fine and dandy.

When I was looking for help on this I found someone else who has having the same problem but the reason for their error message was because the database was in 65 compatability mode. Heh, sounds like a lot of things can give you this problem.

Pits of Doom Lesson 4: And Array We Go

Comment 1 Standard

In the last lesson we covered how to create a function, how to use some of php’s built in functions, and how to deal with sessions. Now we’ll take it even a step further.

If you’ve tried the little game we have setup right now you’ll agree with me that’s its not only boring, it’s really REALLY boring. Right now you can click one button and either win or loose the game. In the big scheme of things we want our character to walk around different maps, moving from place to place as well as fighting or falling into pits before they die.

But frankly you’re not at that point yet. So again we’ll take a step back and go at from an easier approach — letting the character move around a larger area before they run into the possibility of either finding the treasure or falling into a pit. So let’s say we have a map like this:

Map Name: Tutorial Map

Map Level: 1 (lower numbers are closer to the surface, higher numbers are deeper down)

W    W    W    W    W    W    W
W    S    E    E    E    E    W
W    W    E    X    E    E    W
W    E    E    E    T    X    W
W    W    W    W    W    W    W

S marks the starting place of our character on the map. The number E is an empty space, meaning the character can move there. The number W is a wall, the character can’t move onto that spot. X is a pit and T is our treasure. Now we already have a much more interesting game already. In order to give our character more movement we can use a database or an array. Since a database is in a way a really huge array we’re going to start with an array so you don’t have to worry about all the finicky problems that pop up with the database and then move on to the database later.

Lesson Concepts


In short an array is a way to hold lots information at one place. There are two types of arrays, single dimension arrays and multi-dimension arrays. We’ll cover single dimensional arrays first.

The easiest way to think of an array is a list of items. The list always starts at zero and grows up in it’s number. Let’s take a look at a simple array I’ve made called path. In each of the fields in the path I’ve stored information about what kind of item you might find there (treasure, walls or empty spaces)


$path[0] = “S”;
$path[1] = “E”;
$path[2] = “E”;
$path[3] = “E”;
$path[4] = “W”;


As you can see, out path has a starting position of a character, three empty spaces, and then a wall. If we were to try and build any kind of character movement using this array it would be pretty difficult. The character would start at position zero, be able to move up to 3 spaces forward, and then get stuck when it hits the wall at position 4. The only other option this character would have would be to turn around and go back to it’s starting position. How boring would something like this be? We want our character to be able to move in multiple directions, not just forward and back. That’s where multi-dimensional arrays come in. Take a look at this…


$path[0][0] = “W”; $path[0][1] = “W”; $path[0][2] = “W”; $path[0][3] = “W”;

$path[1][0] = “W”; $path[1][1] = “S”; $path[1][2] = “E”; $path[1][3] = “W”;

$path[2][0] = “W”; $path[2][1] = “E”; $path[2][2] = “E”; $path[1][3] = “W”;

$path[3][0] = “W”; $path[3][1] = “E”; $path[3][2] = “T”; $path[3][3] = “W”;

$path[4][0] = “W”; $path[4][1] = “W”; $path[4][2] = “W”; $path[4][3] = “W”;


Does this look familiar? Good! It should! This is a multi-dimensional array. I’ve tried to write it out so it looks similar to the map we have planned out above, only this is a much smaller version. With a multi-dimensional array you can store more then 1 coordinate at a time. Now we can have a left and a right direction along with an up and a down.

In the multi-dimensional array our character starts out where we’ve marked it with an S, at (1,1). This notation (1,1) is what we’ll call a coordinate. It notes the x and y location (x,y) of the character.

If this character were to move up, we’d subtract one from the x coordinate. If they want to move down we add 1 to the x coordinate. If they want to move left or right, we add or subtract one to the y coordinate. Now what happens if the character starts at (1,1) and they move to the right? They are given the position (1,(1+1)) or (1,2). Scroll back up and look at the array. Is there a free space at (1,2)? If there is, then we’d want to allow this move. If there’s a wall in position (1,2) then we’d give the character an error message.

Now it’s your turn to try. Write out the coordinates you’d need to get from the character’s starting position to the treasure. There are actually several ways to do it, can you find more then one way?

Once we have a larger array we have to always test both coordinates when the character moves from place to place, otherwise we won’t be pulling accurate information from the maze. Here’s how you’d test to see what value is in an array at a certain position.


$x = 0; //first coordinate

$y = 0; //second coordinate

echo $path[$x][$y]; //now we show the value of the path for the given coordinates


I’m sure you can see where this is going. You can test an array for a value just like you can test any other variable.


$x = 0;

$y = 0;

if ($path[$x][$y] == “E“)


echoYou’re on an empty space!“;


else if ($path[$x][$y] == “W“)


echoHow did you get stuck in a wall?!?“;



That’s it! Seems pretty easy doesn’t it?


In this lesson we covered single and multi-dimensional arrays. In order to complete this lesson you’ll need to know how to assign values to a multi-dimensional array, access the values in the array, display the values in an array, and then write if-else statements to respond differently based on what’s in the given position in the array.

To make this lesson easier I’ve included a custom function that draws the map to the screen and shows you the character’s position as it moves around. The character is drawn in red until you find the treasure, then it turns green!

Game Files

Working Version: character.php — we have enough of a functioning game that you can start playing it for yourself!

Source Code: character.txt

Try it yourself: character2.txt

Lesson Reasoning

This lesson helps us work up to getting character movement based off of values from another data source. Right now we’re using data we’ve entered ourselves, but pretty soon we’ll be pulling this information from our database. This is only one level below reading from a database and it’ll help you understand character movement on a baser level before we add the complication that is SQL.

Now comes the question, can we change the map as we play? Let’s say, instead of the game being over when the character finds the treasure, we instead want them to move onto a new map. Sounds easy, but the more maps you have the more difficult this becomes!

And did you notice how much time it took to make your own custom map? Pff, we don’t want to do that for all the levels in the game. We need something much faster and more powerful, which brings us to the next lesson.

In the next lesson you’ll learn how to dynamically load different map files into the map array from a file instead of having to have it typed on the character’s page. That way we can relocate the character to another map once they’ve found the treasure. Also, we’ll create a map editor so we can quickly and easily make map files.

Once we have those two things done we’ll be ready to move on to putting all the character movement into a database table, creating maps and saving them directly to the database, and letting our character move up and down in the map levels using ladders.

Return to Lesson 3 or you can Go to Lesson 5

Pits of Doom Lesson 3: Mixing Things Up

Comments 3 Standard

In the last lesson we covered how to make a form, check to see if a button has been pressed, and display a message according to whether the user found the treasure or not. Now it’s time to take our very simple navigation page to the next level: random treasure location.

In our final game, the position of the treasure will be pre-determined by data in our database. However, we won’t know what position the treasure is in as the user is navigating their character around the game because this information will be loaded as they play.

In our next lesson we’re going to apply a more advanced concept to figuring out if the treasure is in the correct location. Instead of always knowing where the treasure is, we’re going to make the treasure start in a random direction each time the page is loaded. That way we have to check every time to figure out where the treasure is, and if the player will fall into a pit or not.

Lesson Concepts


In programming, a function is a great way to break bigger tasks into smaller more manageable pieces, or reduce the need of having to write the same piece of code over and over again. In PHP the syntax for a function is very simple:


function myfunction ($parameter1, $parameter2)


echo $parameter1 . ” ” . $parameter2;


This is a really simple function called myfunction. It takes two parameters and simply echoes them on the screen whenever you call it. The periods you see in the echo statement are a way to concatenate or join the two variables together with a space in between them.

Calling a function is just as easy as making one. Anywhere you want myfunction to print something on the screen all you have to do is:


echo “Hey there, here is what myfunction has to say: “;

myfunction(“Hello”, “World!”);


If you were to run this you’d see: Hey there, here is what myfunction has to say: Hello World! Not only can a function print to the screen, it can return values you can then store into variables. Let’s take a look at this function:


function Mod5 ($number)


return $number % 5;


This function takes any number you give it and mods it by 5. If you aren’t familiar with the modulus operator, all you need to know is that it returns the remainder from the division, and not the number you’d get if you divided $number by 5.

Now let’s see what how we’d use a function that returns a value instead of printing it on the screen:


//declare our function
function Mod5 ($number)

$number % 5;

if ($_POST[‘number’]) //they’ve entered a number

echo “Your number is: ” . $_POST[‘number’] . “<br/>”;

$number = myfunction($_POST[‘number’]); //we store the modulous of what they entered back into the number variable

echo “Your number % 5 is: $number”;
else //show them a form to enter a number


<form action=”#” method=”post”>

Please Enter a Number: <input type=”text” name=”number”><br/>

<center><input type=”submit” name=”submit” value=”submit” /></center>
} //don’t forget to close our ELSE statement

In this example we’ve taken the number a user enters into a text box and then display the number back to them along with the remainder of that number when it’s divided by 5.

One of the great things about PHP is that it comes with a huge collection of pre-defined functions you can use when you program. You can take a look at all the functions by going to The one function I want to touch on in this lesson is the random function.

As you can probably tell, you don’t always need to know all the little specifics that go on inside of a function as long as it always gives you the results you’re expecting. The same goes with the random function. I could go into details on how it takes the current time on your computer and does a bunch of mathematical stuff to it — but that’s just plain boring!

The short of it is, the rand function takes 2 parameters. The first parameter is the lowest number you want it to generate when it runs. The second number is the highest number you want it to generate when it runs. So, if you wanted a random number between 1 and 4, including the numbers 1 and 4 you’d do this:


echo “My random number is: “ . rand(1, 4);


View the page with this php code. Now refresh the page. You’ll notice the number is constantly changing.

One other function you’ll need to know is the unset() function. This function is great, you pass it a variable or an object (don’t worry, we’ll get to those later) and it sets the value of that function to null. Think of it as taking a jar of cookies, opening the lid, and dumping all the cookies on the ground. That’s essentially what the unset() function does.

Congratulations, you now know how the rand and unset functions work. You’ll need both of these for this lesson!


Now one of the biggest problems we run into is how to keep track of a user’s past responses. Or how to keep track of anything about the user from one page to another. That’s where sessions come in. Sessions are a way to track information about the user as they go from one page to another. Eventually we’ll be using information from the database to track a lot of the moves a user is making with their characters, but we’ll still need to know who the member is as they go from page to page. For right now, we’ll use sessions to keep track of the direction the user picked. And now, instead of letting the user continue to pick a direction after they’ve fallen into the pit we’re going to give them a game over message until they decide to reset the game and try again.

Sessions are very easy to use. They work almost exactly like the $_POST and $_GET variables you can use to access information about what someone has entered on to a page. However, there’s a few major differences:

  1. You can set the values of the $_SESSION variable
  2. Session variables remain with the user until you tell them to expire, they don’t change page by page.
  3. Session variables can be set to expire so they don’t last forever, or you can set them so they never expire and DO last forever.

Using sessions now will get you familiar with them before the programming becomes more complicated.

If you’ve done anything with cookies before then sessions will be a breeze for you. Sessions are a good alternative to cookies because if a browser has cookie functionality turned off you will still be able to keep information about a user from one page to another. If that went right over your head don’t worry, it’s not essential to this lesson.

There’s one thing you have to keep in mind about sessions. In order to use a session you have to call a special function at the top of every php page, BEFORE YOU DO ANY KIND OF OUTPUT!! This last is important. If you try to output anything before calling the session_start() function you will get an error.

Now let’s setup a simple session. Create two pages, one called welcome.php and the other called main.php. Welcome.php is an example of a web page you might see that greets you and asks you what your name is. Main.php is an example of a page you might look at after you’ve visited the welcome.php page.

In welcome.php we have this:

session_start(); //the first thing we do is start our sessions

if ($_POST[‘name’]) //they entered their name in the form
$_SESSION[‘name’] = $_POST[‘name’];

//now we’re going automatically to redirect them our next page
//using a function called header() that’s built into PHP

header(“Location: main.php”);

<form action=”#” method=”post”>

Enter your name for our first session variable! <input type=”text” name=”name” />
<center><input type=”submit” name=”submit” value=”All Done!”></center>

Now, inside of main.php we’re going to put this:

session_start(); //we have to start our session again to get the data we saved before

echo “Welcome to the main menu “ . $_SESSION[‘name’] . “!”;

In the main.php file we pull out the information we stored in the session variable for name and print it back out on the screen. Nifty! Now we know, no matter which page this user goes to from now on, as long as we call session_start() we’ll be able to access their name from the variables $_SESSION[‘name’].

Congratulations! You should now understand the basic concept of sessions.


In this lesson we learned about how to make our own function and talked about how PHP has it’s own predefined functions we can use to make our life a whole lot easier. I talked about how to make a function print something on the screen versus a function that returns a value. Functions that return a value can also be printed on the screen, but you’d have to put an echo in front of the function call to do that.

Next we talked about sessions. Sessions are a way to store data as the user moves from page to page around your website. Without sessions we wouldn’t be able to tell who was who as multiple people will eventually load this game and try to play it. Right now we’ll be using sessions to keep track of a game being over or not, but eventually we’ll only use sessions to keep track of which user a person is as they play.

Game Files


character2.php (no source code)

Note: these are text files so you can copy/paste all the source code.

Lesson Reasoning

In this lesson character.php now has the treasure starting at a random location. If the user picks the incorrect location they get a game over message instead of being able to pick a direction again. In order to play again the user has to click on a reset button to start the game all over again. I’ve introduced functions, sessions, and a more abstract checking.

Once we start pulling information from the database we won’t know anything about the character’s current location at runtime other then their x,y,z coordinates and the map they’re on. Information about items in that position will all have to be tested each time the character tries to move somewhere. By introducing the treasure in random locations we start to get into the habit of checking information about our location as we select a particular direction.

Return to Lesson 2 or continue on to Lesson 4

Pits of Doom Lesson 2: Breaking It Down

Comments 3 Standard

One of the best things to do if you’ve never made a game before or you don’t have much programming experience is to break things down into their most basic parts. We’ll start off making this game by doing some really really simple programming and then adding functionality until the game is complete. It doesn’t look like much now, but at the end of this tutorial you’ll be able to download a fully working version with an installation file that you can use under the GNU public license to modify and edit as you wish.

The last thing I want to mention is the teaching style I’ll be using throughout all of the lessons in this tutorial. I’m big on letting people try things on their own before I give them the answer. Pretend you’re asked to take a history test. If I was to just hand you an answer sheet with all the right bubbles filled in you’d never learn anything from the test. This is a theory I hold to. In each of the lessons in this tutorial you’ll find two versions of every file I’ve made. One file will have no code in it. That way you can try to program this game from scratch by yourself. But if that’s too daunting don’t worry. The other version of the file will have all the working code inside of it.

Even if you’re not a programmer I encourage you to try your hand at programming each lesson. I’ll go over some of the basic concepts you’ll need to complete the programming before concluding with the reasoning behind what I’ve done so far.

Lesson Concepts

About PHP

PHP is a server side programming language. That means any code you write on any PHP file will never be visible to anyone who goes to a file with php code on it. The benefits of this are you don’t have to worry about people stealing any code you’ve written. When someone views a PHP page, all they see is the HTML or text you’ve generated with PHP or typed onto the page yourself.

PHP files have a .php extension. A lot of people I’ve talked to take that to mean PHP files cannot display HTML or Javascript. That’s incorrect. The .php extension is the server’s way of knowing it needs to evaluate any PHP code on the file before the person requesting the page sees it.

The biggest draw back with PHP is that it’s a server side programming language. That means any time you want to make a change to what the user sees on the page they either have to refresh it, or navigate to a new page. Websites where you see changes applied immediately (google mail, wordpress, to name a few) use something called AJAX. AJAX is an asynchronous relay between a server and a user’s browser. This means they don’t have to refresh the page to see changes. If you’re interested in something like that then this tutorial is still the one for you. PHP is often used in combination with AJAX to create more dynamic web pages. However, I won’t go over any AJAX in this tutorial, so once you’re done making this game you’ll need to find some AJAX tutorials.

Printing to the Screen

All PHP code is delimited by a start and end php tag that looks like this:

echo “Hello World!!”;
print “Hey there!”;
echo “<b>WOW!!</b><br>”;
print “This is sooooo neat…”;

The PHP start and end tags are lot like matching HTML tags. If you don’t have any HTML experience I strongly recommend you take some of the tutorials on before you continue with the lessons here.

If you don’t have the correct start and end tags that would be one reason why someone could see your PHP code on the screen. Without the PHP tags the server doesn’t have any way to know what you’ve typed needs to be evaluated as PHP.

In the code above you’ll also see print and echo statements. It doesn’t really matter which one you use, but this is how you print something to the screen. Notice on the third print statement there is HTML in the quotation marks. There is nothing wrong with putting HTML inside of your PHP, in fact that’s one of the great things about it.

A few syntax things to keep in mind:
1. You always need matching start and end <?php ?> tags.
2. PHP statements always end with a semicolon ;
3. When you echo something to the screen it should be inside of single or double quotation marks
4. If you need to put quotes in your print statements then you should escape it like this:

echo “And he said \”Hi Mom, how are you today?\””;

The backslash tells PHP to evaluate the quotation mark as text and not as the end of the string.

5. You won’t see an error in PHP until you go to view the page. That’s because php is only evaluated on runtime. Sometimes this is very frustrating, and you’ve probably seen error codes before. If you get an error message read it, it usually tells you what you did wrong in your code.

Common PHP Errors & Solutions

Parse error: syntax error, unexpected T_STRING in [file location] on line [#]
This means you forgot a ” or a ‘ somewhere. There should always be at the start and end of a string. If you have a matching pair, make sure you don’t have one too many. If you have quotes inside of your string then you need to escape them using a backslash like this: \” or \’

Parse error: syntax error, unexpected ‘}’ in [file location] on line [#]
This means you have some kind of multi-line statement and you either forgot a bracket or having too many brackets. Brackets always come in pairs. Sometimes it mean you’re missing a semicolon at the end of the previous statement.

Parse error: syntax error, unexpected ‘”‘ in [file location] on line [#]
This means you probably forgot a parentheses before of after the DOUBLE quote. Sometimes it could also mean that you forgot to escape the double quote.

Parse error: syntax error, unexpected “‘” in [file location] on line [#]
This means you probably forgot a parentheses before of after the SINGLE quote. Sometimes it could also mean that you forgot to escape the SINGLE quote.

Parse error: syntax error, unexpected ‘;’ in [file location] on line [#]
This means that you’re missing something before the semicolon at the end of your statement. Usually its a closing parentheses. However, it could also mean you have a semicolon in a position PHP is not expecting one to be in. That usually happens in loops.

Parse error: syntax error, unexpected T_EXIT in [file location] on line [#]
This means you forgot a semicolon before an exit; call

Parse error: syntax error, unexpected $end in [file location] on line [#]
This usually means you forgot a semicolon or your function isn’t returning like it should be.


In PHP a variable is defined by a $ dollar sign. That means any word with a dollar sign in front of it will usually be evaluated for some other kind of content. The easiest way to think of a variable is to think about a jar. You can put things into a jar and take things out. You can stick a name on a jar but then decide you want to change that name later. Variables also work this way.


//this is a comment, comments are for you
//they aren’t processed as code
//get into the habit of leaving comments for yourself so if you come back later
//you can remember what you did or what you were trying to do

$myvariable = “Hello”;
$mysecond = ” World!”;

echo $myvariable;
echo $mysecond;

print “<br>”;

echo “$myvariable $mysecond<br>”;

$myvariable = 2;

echo $myvariable;

In this example I have two variables. You can assign them a value using the equal sign. Variables in PHP are dynamic. That means you can assign them to one type (a string) and then reassing them to another type (an integer) without any kind of conversion. If that just went right over your head, don’t worry. All you really need to know is the syntax to assign a variable.

If-Else Statements

Games are all about decision making and that’s the benefit of a programming language. In order for anything to work in this game we’ll have to set it up to follow the rules and logic I briefly outlined in Lesson 1. To do this we need to respond differently based upon the choice the user playing our game makes.


if ($_POST[‘button’]) //someone clicked a button

echo “You pressed a button!”;
echo “You haven’t pressed a button yet. Go ahead, try it!”;

<form action=”#” method=”post”>

<input type=”submit” name=”button” value=”Press Me!”>


In this example you see a .php file that has a section of PHP code and then below that it has some regular HTML. The part to pay attention to is the if-else section. Here we display a different message to the user based upon if they’ve clicked on our button or not. IF the button has been pressed, the code between the brackets { } of the if section will execute. Otherwise the code between the else brackets will execute. I’m sure you can already see the power of PHP in this one example. If you’d like more help with If-else statements and some more examples of if-else statements read my tutorial here. This covers some PHP programming concepts more in depth and gives more examples.

Form Basics

A form is one way to get information on what the user is doing back and forth to the server and PHP. All forms must have a start and end <form></form> tags. In order to submit any information from a form to the server you MUST have a submit button. Without a submit button you won’t be able to tell the page that the user is trying to send you data about what he/she is doing. You can see a small form in the example above. It has both the start and end form tags, as well as a button. If that looks unfamiliar to you then you really should go back to and do some catching up on your HTML skills!

$_GET and $_POST Variables

In order to get data from a form PHP stores two special variables for us. The variables get data depending on the type of METHOD used in the form. If you look at our example above, we use a POST method. That means all the names and values of our form are sent to the server and stored inside of the $_POST variable. That way we can pull information from those variables to see if a user clicked a certain button or link. In the example above, we’re checking to see if someone has clicked on our submit button that we’ve named button (yay for generic names!). If we’d called our submit button BOB and didn’t change the if statement to check for $_POST[‘BOB’] then we’d never see the words telling us we’d pressed the button. As far as PHP is concerned, we no longer have a submit button called button so there’s no way it will ever be pressed.


There you have it. I’ve not covered in brief (and sorry if it’s not brief enough for you — or too brief!!) all of the major concepts in the first part of the tutorial files you can download below. Again, if you’re up for the challenge, try programming this file yourself by opening the character2.php file. At the top of the page it will outline everything I’m trying to accomplish in this particular file for this lesson. If you just want to see some working code then download character.php and jump right into the next lesson.

Game Files (click to view)


character2.php (no source code)

You’ll need to copy/paste the source from one of these files and give it a .php extension for the last part of the tutorial to make sense. All of these files are viewable as .txt files so you can see the PHP code inside of them. If they were .php files you wouldn’t ever be able to see the .php code. Do you remember why?

Lesson Reasoning

A lot of the logic behind the game we’re going to make has to do with movement of a character around the game world. Remember there is a difference between a member and a character. A member is an actual person who will login and play this game by the time we’re done. A character is something the member will use to navigate the game. Each member can have multiple characters.

Character.php is from the point of view of one character. Each character will be faced with the option of which direction they can move — left, right, forward or back. Every time a character moves we’ll need to evaluate the move and take some action depending upon the new location they’ve moved to.

Although this file only checks for a single direction and places the “treasure” in one specific location, it’s a step in the right direction. With this file we know which direction has been selected, we can compare that direction to the new position they’ve moved to, and we can print a message on the screen indicating if the character won or lost based upon finding the treasure.

Return to Lesson 1 or you can always Continue to Lesson 3

Free Multiplayer PHP/MySQL Game — Pits of Doom

Comments 15 Standard

About a month ago I started giving someone PHP/MySQL lessons. In the lessons I made up a little game to teach the guy how to do different things in PHP all the way up to making his own multiplayer online text-based game. So in the next few months I’m going to share insights on creating your own PHP/MySQL game by posting the code for this little game under the GNU public license. That way you’re free to edit/update and change it as you see fit. If you’d give me credit for it (or at least keep the link on it) I’d appreciate it.

I’ll post the tutorials here along with the final code for the game and an installation file (which I’ll even teach you how it works!) so you can follow along and see how I go about making an online game, the thought process behind it, and how to get one up and working yourself.

Game Tutorials

Download Game Code

.zip archive — Coming Soon!

.tar.gz archive — Coming Soon!

Download Game Tutorials

.zip archive — Coming Soon!

.tar.gz archive — Coming Soon!

Want your own custom online game? Get a price quote at my website:

Pits Of Doom Lesson 1: Planning Stage

Comments 2 Standard

Before you start any kind of online game you need to take a minute to sit down and consider some of the following questions:

  1. What is my game called?
  2. What is my target audience?
  3. Can I afford the cost and time of manging my own game?
  4. Am I good at working with people?
  5. What competition already exists for the game I’m going to make?
  6. How will my game work?

It’s All In A Name

A name can make or break a game. Pits of Doom isn’t anything exciting, but this is a tutorial game, not something I’ve made to produce to lots of people. Your name should be memorable, but not too hard to spell, say, or remember. Shorter names seem to work better as well, but that’s more of a personal preference.

Hit the Target

Many people overlook target audiences. When you design your game you need to keep in mind who actually plays your game. If your game is for young children then you don’t want a game that’s overly complex, hard to navigate through and has few images. Also take into account your audience’s familiarity with computers and the Internet. A child isn’t as likely to be able to understand complex directions or sequences whereas a hard core video game addict should have no problem navigating menus and following technical directions.

Audience Tips:

  1. Games made for ages 5-7 should have lots of pictures, big buttons, be easy to play, and have few words to keep younger children interested. There should be lots of games, puzzles, animations, and things to keep kids from getting bored. A suggestion would be using popular cartoon characters as they play the game.
  2. Games made for ages 8-17 should have more text, but also a lot of pictures. You want to make sure it’s easy enough for the younger players to get around and play, but hard enough to keep the interest of older players. Most games made for teenagers will automatically attract younger kids and adults at the same time.
  3. Adult games have more of a risk. Keeping younger players from seeing what they shouldn’t can be a hassle. One thing to keep in mind is that if younger viewers see content they shouldn’t you could be getting some very angry messages from parents of younger players. A suggestion would be using some kind of way to make sure the player is over 18, such as needing to give a money transaction to play. For an adult game you can assume they have decent computer skills and are possibly hard core gamers. Complexity and strategy and action should play big parts in these games.
  4. A mix of all ages is the hardest challenge. Games have to have a mix of easy play, medium play, and hard play for all age levels. You’ll have to manage keeping the attention of all age groups. This usually happens on its own if you have a really popular game, because everyone wants to play no matter what his or her age is.

Carrying the Costs

Games are inherently expensive. The bigger and more popular your game becomes the more it’ll cost you to keep it up and running. Are you willing to put up the expensive of domain names, servers, bandwidth, hardware upgrades, technical support, and so forth and so on? My biggest game has over 100k members and costs me over $300 a month just in server costs. That’s over  $3,600 a year just to keep the game server online. Then you have to factor in advertising, domain names, and additional expenses such as postage and letter heads and office supplies. Will you be able to carry the costs of the game’s expenses if your game isn’t generating enough revenue to support itself? These are all really important questions. Take the time to research how much it costs to buy a domain, get hosting setup, and any other additional fees you may run into before you start.

Cost Solutions

Just because you don’t have a big budget, don’t let that limit you!! There are several things you can do to limit your expenses.

  1. Limit the numbers of members who can join your game. This will reduce your bandwidth — the amount of data passed back and forth over the internet — and will encourage your members to stay active. You can even go through and delete accounts that are inactive after a certain period of time.
  2. Limit how many people can play online at a single time. This isn’t the best solution, but sometimes it’s a good option if your game is popular but you don’t have many people that play online at any particular time during the day.
  3. Don’t expand your hosting/server needs as your costs increase. If you can’t afford it, then you can’t afford it. Make your members deal with slower response times and hangups. Not great for customer service but at least they can all play.
  4. Don’t advertise. I know this goes against the grain, you make a new game and you really want to share it, but I’ve found word of mouth is the biggest and best form of advertising out there. The more people that know about your game the more will want to play and the higher your expenses.
  5. Make your game a “friends only” game. Limit it to people you know or friends of people you know. If it’s just a game you plan on making as a hobby, something to do in your spare time, this is a great alternative.

I’m a People Person

Even if you aren’t planning on it, your game will generate a lot of interaction among people. People will email about problems or questions or help constantly. If you’re not great with people or you can’t be bothered then you’re in for an eye opener. A website without any kind of support doesn’t do well in the big scheme of things. Take the time to evaluate yourself. Are the benefits worth the downfalls?

Overtake the Competition

Is your game 100% unique? Chances are that it’s not. Take a day or two to find any other site you can that’s even a little bit similar to the game you have in mind. Join them and check them out. What are features you like? What do you dislike? The more time you spend going through your competition’s setup the more you’ll generate a feel for what you want your own game to be like, what features are a given, or could be improved upon. Knowledge is power, and giving your target audience a more useful, more enjoyable game is sure to win their approval and guarantee your popularity.

Liability & Legal Mumbo Jumbo

Terms and conditions or terms of service are a legal agreement between you and anyone who decides to play your game. In this agreement you want to make sure that anyone who uses your website cannot sue you or take you to court!!! Every game you make should have terms and conditions. If you can afford it I highly recommend that you pay a lawyer to write them for you or review what you’ve written up yourself. If not you can take use a copy of the terms and conditions I’ve drawn up for Pits of Doom at the end of this tutorial as a starting point for your own game. Listed below are some general things I would recommend thinking about or including in your terms. Please note this is not legal advice and any tips below are no substitute for getting a lawyer whose familiar with current online practices and laws.

Protect Yourself:

  1. Make sure you state that by using your website your visitor is legally tied to your Terms and Conditions. This means that they accept them as legal document.
  2. Make sure you remind your visitors that any changes made to your Terms and Conditions are in place immediately. You don’t want people to tell you they never agreed to your changes.
  3. Don’t forget to include a statement saying that your visitors can’t hold you responsible for any kinds of fees or losses as a result of using your website. This includes computer problems, buying products off your website, game fees, etc.
  4. If you make people pay to access your game then you should have a section describing your refund policy – even if you don’t give refunds, tell them that. A refund means you’ll give someone his or her money back. For example if someone paid you twenty dollars and asked for a refund you’d give them their twenty dollars back.
  5. Be extra careful to protect yourself from things members may put up on your game. Include something saying you’re not responsible for any links, explicit or harmful text/pictures, services or products displayed on the site by members, third parties (people outside members), links and advertisements.
  6. Remind site visitors that you’re not responsible for any information they share or give out to other members or other places found through your website.
  7. Mention that visitors post content on your site at their own risk. This lets them know they’re responsible for their own actions.
  8. Describe your cancellation of accounts. This means you write out why you can delete or ban someone’s account and for what reasons. For example, you can include that if someone cheats or breaks a rule then you can delete their account. If your visitors are paying to play you might want to tell them they can or cannot get their money back for having their account deleted or banned.
  9. Always have rules. Rules state what is and is not acceptable on your website. Make sure you include harassment, rude or nasty comments, server abuse, emails, etc.
  10. Add anything else you need that I didn’t mention. Your terms and conditions should be your lifeboat when you’re drowning. Everything you need or think you need should be on board. If you’re not sure if you should add something or not, add it. They can be as long or as short as you want, but it’s always best to be safe now instead of sorry later.

Privacy Policy

A privacy policy lets your members know how you’ll be using any information you ask them. For instance, if you asked a member for their address and telephone number when they joined you might have plans to call them or send them regular mail. Some people don’t like this and others are fine with it. In your privacy policy you should tell people how you plan to use the information they give you when they join your game. So in the example above you would say that if members give out their telephone number they’ll receive phone calls, and if they give out their home address they’ll receive mail. This way people know exactly what happens to the information they give you.

Laws You Should Know About

There are several Internet laws you should concern yourself with if your game is based in the USA. Reading them isn’t an option of whether or not you feel like it, they are a must read. If your game is based outside the USA you’ll need to research yourself to see what rules and regulations you have to comply to.

If your game allows children you need to read the COPPA act. This concerns the privacy of personal information you may gather from children under the age of 13, how it must be stored, and who can have access to it.

Whether your game allows children or not you need to read the Digital Millennium Act. This is one of the largest and most important laws that pertains to you as an Internet game. It outlines things from playing music from current artists on your website to allowing members to upload pictures, videos, and any other content. Knowing about the DMA will protect you from copyright infringement lawsuits which will become one of your biggest concerns as your members generate their own content using or interacting with your game.

Some other minor laws include the Internet Tax Freedom Act and the Communications Decency Act both of which are fairly self explanatory from their names.

Business Licenses

Most counties of USA states require you obtain a business license if your game is generating over x amount of revenue a year. Usually you’re charged based on your annual income and the fee’s are fairly minimal if your game is making less than $10,000 a year. You can usually get an application from your local chamber of commerce or county treasury. You will typically be charged once or twice a year.

Sole Proprietor vs LLC

A sole proprietor is one person who owns an entire business or service. If your game is just a hobby chances are you’ll never need anything else other than this. All revenue you make from your game must be claimed on your personal income tax and your tax return will be calculated as if it was a part of your typical salary. In most states you don’t have to report additional income unless it exceeds $5,000 but you’ll need to check your state laws to confirm that.

An LLC, or limited liability company, is the other option. It separates you from your game and removes the chance that someone can sue you as an individual. Instead they must sue the game itself which means there’s no possibility you could loose your house or car or property. If your game is making more than $5,000 a year in revenue an LLC or something similar should be in the works.


Inherently anything you make yourself is automatically copyrighted by you, even if you never file copyrighted paperwork or register a trademark. However in a legal case having a certified copyright is a must.

A copyright is easy and fairly cheap to file.  You can do it online now through the Electronic Copyright Service. It costs about $35 per copyright and takes anywhere from 6-8 weeks to have it approved. Once the copyright is approved you’ll get an official letter with a copyright identification number. Now you have a legal document verifying you hold the copyright to your game.

A copyright filed after January 1st, 1978 for a single author will last for the life of the author plus an additional 70  years. A copyright filed for joint authors will last until the life of the last surviving author plus 70 years. If you ever decide to sell your game you can easily transfer your copyright from you to the new legal owner.


These are a bit tricky. I wouldn’t ever try and register a trademark without a lawyer, there are just too many inns and outs and little things you have to know about. A trademark costs anywhere from $275 to $325 depending on the classes you register it for. As your game gets more popular a trademark will ensure you own all legal rights to name branding, products and any additional services that arise as your game grows.

The biggest problem with trademarks is trying to find a unique name. If your trademarked name sounds too much like other trademarked names it will be denied. If your trademark is spelled differently but phonetically sounds the same it will also be denied.

Trademarks are expensive but well worth it as your game expands and grows. You can file trademarks electronically at the Trademark Office.

Gambling & Gaming

This might not seem like something you’d think about as you’re developing a game but it is something you need to be aware of. If you offer “pay for play” gaming where your members will win prizes as a result of playing your game this is considered gambling. Gambling is defined as playing a game for money or property, or betting on an uncertain outcome.

In many states gambling is illegal without a proper license. In some states it’s illegal period. If your business model is considered gambling you’ll need to make sure you can get a license for it. Then you also run into the problem of making sure that you only have members from states where you have a valid gambling license. Over the Internet this is fairly hard to do.

For instance, let’s say you have a legal gambling license in West Virginia where your business is based. Your website attracts individuals from all over the United States. Someone from Virgina signs up and starts playing your game. Almost all forms of gambling in Virginia are illegal unless sanctioned by the state itself. Now you have someone illegally gambling on your website which could lead to future complications for yourself.

So how do you get around it? Simple, you don’t. Charging money for your game cannot be tied to winning any kind of prize or property. That means you could charge members for something completely non-related to a prize you’re giving out, or allow both paying and non-paying members to have an equal chance of winning the prize. If a member doesn’t have to pay anything in order to win a prize then it’s not considered gambling.

Gears & Cogs

Now it’s time to set your brain into motion. Write down the biggest features you want to include in your game. Then go ahead and break it down into smaller pieces. This will help you express all of your ideas before you start making anything and should increase the usability of anything you end up making.

Putting It All Together — Pits of Doom

Here is something I’ve thrown together to give you an idea of the thought process I went through when coming up with the Pits of Doom game.

I chose a really generic name for this game simply because it’s a tutorial on making your own online game. Here are some names I might consider if this was a game I was making as a serious revenue earner:

Black Abyss

Infinity Nights

Dark Haven

The target audience for this game is boys between the ages of 12-18. That means they’re all in middle school or higher. They’re probably used to seeing shoot em up/slasher video games by this age. Most of them have a fairly high computer usage skills at this point, but some of them are young enough to struggle. That means my navigation and layout should be simple to a point, but maybe the game play can be much more complicated.

Some similar online fighting games are: – an online strategy game. I find this one to be way too complicated for younger players. It has some great ideas, but it’s a bit overwhelming when you go in to play for the first time. – what do you think about this one? Follow the link and ask yourself, what do I like, what don’t I like? What could be done better?

Now write down some similarities you saw. What about the differences? Things that are similar in all games are probably features you’d want to strongly consider having yourself, or to some variation. Those are things that have made these games popular.

This game isn’t ever going to go up on any of my servers except for this tutorial code, so it won’t cost me much of anything to maintain. Can’t afford the cost of having a game online but still interested in learning how to make one? No problem, all you have to do is download and install XAMPP. Now you can run the game right on your own computer at home. Once it’s installed you can setup a database and get busy. Need more help getting XAMPP up and going? Try this tutorial.

Finally, I took the time to define the features I’ll be adding to the game and broke them down:

Game World –

Each map in the game is called a map node.

There can be an unlimited number of map nodes in the world.

Map Nodes –

Each map node has a name, a description.

Each map node can have unlimited coordinates.

Coordinates –

X, Y, Z value.

Has 1 object associated with it.

Wall value:

  • 0 = open, they can move to that coordinate
  • 1 = there is a wall here

Has 1 transfer node associated with it, detailing that moving to this coordinate will force the user to move to that coordinate on the new map node.

Has a level associated with it, detailing that moving to this coordinate will force the user to move up or down one level.

Item Objects –

G = gold (random amount each time)

T = treasure

S = sword

A = armor

L = lantern

O = oil

H = shield

C = enemy creature/monster

X = pit, chance of them dying, or draining all magic, or dropping to a lower level

T = health tonic

M = magic potion

S = store where they can buy items

L = ladder, you can climb up or down to another level

Characters –

These are owned by members.

They have a name, gender, and breed (monster, human, elf, dwarf, centaur, fairy).

When the members is online, they are always associated with an active coordinate.

They can equip items and use them to help their statistics.

The more they play the higher the character’s statistics go.

Statistics Include:






Fighting Level

Magic Level

Magic Amount – how much magic they have they can currently used

Weapon Equipped

Spell Equipped

Armor Equipped

Shield Equipped

Characters can fight other characters and monsters in the game.

If a character kills another character then they get to keep all of the items the character they killed had equipped and any gold they’d collected in the past 20 minutes.

Characters can trade items with each other if they’re both on the same coordinate.

Members –

Has a username, login, and password.

Keeps an email to send them password information.

Keeps track of when they are online or offline so it can activate their character.

Starts off 500G

It costs 100G to create a character.

Members can trade in gold for better weapons, however they must get the character to a store first.

When a member is online all of their characters are active in the game.

Members can trade any item they have among their own characters even if they aren’t on the same coordinate.

As soon as a member logs off or closes the game window all of their characters go inactive unless they are currently being fought by another character or attacked by a monster.

Mail –

Members can send messages to other members in the game.

Messageboard –

Members can post on a community message board.

Best of the Best –

Top members and characters in the game.

Oldest characters in the game.

Strongest characters in the game.

Game Objective –

The objective of this game is to navigate around the game world and gain prestige for your characters by keeping them alive as long as possible.

The more characters you have the easier it is to explore the world but the harder it is to keep all of them alive.

Pits are one of the biggest hazards in the game, they continuously drop you to lower and lower levels. The lower you are on any map the harder the monsters are to defeat.

Pits –

If you run into one of these you will have one of these random possibilities:


Loose all your money

Loose your best item

Loose all your magic strength

Loose all your value in 1 statistics area

Have one value in your statistics areas cut in half

Be teleported to a random location on any map

Drop down to a lower level (if there is one).

Monsters –

These are automatically generated by the game. The further down you are on any map the harder they are to defeat but the bigger the reward for killing one.

Player Movement –

You won’t be able to tell if you’ve hit a wall, a pit, or an empty space until at least one of your players has explored the map already. That means you have to visit the entire map before you can see what the map looks like from a top down view. This makes it more exciting as you won’t know what you’ll find until you go there.

Phew! That’s a lot but this is actually a fairly straight forward and small game. I’m sure you can already think of a hundred different things you would or could add to it from what I’ve described already.

Now, you’re ready to start learning how to make this game. Go to lesson 2.