PDA

View Full Version : How-To: Make a Web-Based game, like DopeWars


Treadon
8th August 2006, 03:13 AM
One of the most common questions I get, at least once a day is, “I’m interested in making a game, but I don’t know where to get started, can you point me in the right direction? Can you help me make a game?” The answer to the first question is yes I’ll help you get started, that is why I’m making this post. The answer to the second one is no; Although I’d like to see more high quality unique (not just DopeWars knock-offs) games with creative ideas, it’s just not possible for me to sit down with everyone who wants one, between work, school, my social life (:O) and my own websites it’s hard to make the time, and I’ve also found that most people just don’t go through with it once they realize the amount of work involved, meaning any time invested was just wasted!

So, ya wanna make a web-based game, eh?
There are 4 main components to a web-based game:
1) The Code
2) The Database
3) Users
4) Hosting

3 is a simple concept, for a multi-player game to live, you need players. Marketing isn’t an easy task, and you’ll quickly find that any method where you get “something-for-nothing” doesn’t produce any results. I often get, “Can you place a link to my game from DopeWars?” It is possible something can be worked out, but like I said, don’t expect something-for-nothing. If you look at DopeWars there aren’t very many links leaving the site, we are not going to clutter the pages with links that offer nothing to our users or the game, a link swap is just clutter unless the partner has a significant user base to reciprocate traffic.

So where can someone get users for a new game, should they spam the forums? NO! If you want to build a real user base, you need to make a real effort. Start with friends, get it on search engines, place it in directories, etc. Banner-exchanges, link-swaps with other sites of your own size, search engine submission can all work together, just remember, the top way a game grows is by word-of-mouth.

Hosting, number 4 is also simple. To make your site available to others, you need to put it “on” the internet. You can develop it locally by installing a web-server on your own system, but eventually you’ll need online hosting. You can get away with a “free” web host; just make sure they support your code-language and database. I cannot list any free hosts because I don’t know any, this is because truthfully I think if you are serious about running a game, then you should get a real, paid host. Basic hosting will cost as little as $4 per month for a start-up game, as it grows you can upgrade packages and eventually get your own servers, but I think one of these small, administered packages is a good place to start. Every paid host will support the essential languages and databases required to run a game.

The code?!?! WTF? Coding a game is not easy, it requires hundreds of hours, plenty of patience and a PhD in Advanced Thermo-Nuclear Dynamics. The third requirement is optional, but I do think you should have some computer background beyond the resume classics of Word, Excel and PowerPoint. Before I started DopeWars I had already worked in two coding jobs and three computer jobs, currently I am a few classes away from a degree in Computer Science. The “code” is the logic that runs the game. The HTML code of a website contains the layout information. Where images are, what images are displayed, what to write, etc. The server side language manages incoming data, and produces the HTML. In the case of DopeWars, the code (server side language) is written in a language called PHP, they have an extensive documentation on their website, www.php.net (http://www.php.net); read it if you choose to use PHP, don’t be lazy, don’t expect someone to sit around and answer all your questions because you don’t want to put the effort in to read a few hundred page manual. PHP is all FREE! There are also paid alternatives, such as ColdFusion and Microsoft’s ASP, they are great choices, I prefer PHP for not just the price, but also the simplicity, as a matter of fact, all the DopeWars/Global Conflict coding is done using Notepad. If you have absolutely no coding experience, look in to ColdFusion, my understanding is they provide a graphic environment to create data driven websites (such as an online game). Based on your coding background, be prepared to spend weeks to months playing with code, reading documentations for the language and working with examples before you create anything related to your game. Coding is NOT EASY. Don’t expect to wave a magical wand and have all your code created for you. YOU WILL need to invest months of time, YOU WILL need to read boring documentations and YOU WILL need to bang your head on the desk when you can’t figure something out. Here I’ve included a small PHP snippet to act as your first example; this will also let you see the difference between your server side language (PHP) and the HTML code.


<?php
$variable = 'hello world';
for ($i = 1; $i <= 10; $i++)
{
echo '<B>'. substr($variable, 0, $i).'</B><BR>';
}
?>


The entire segment is the PHP code, starting with the “<?php” tag and ending with the “?>” tag. A variable is a piece of data stored in memory, surprise: $variable is a variable set to ‘hello world’. The “for” statement is a “for-loop”, it will cause the code between the braces {} to be executed 10 times, it will require another variable, $i, to keep count of the number of times the code has been executed, we can borrow this variable for the next line of code. Echo means create some output, your output will almost always be HTML. <B>, </B> and <BR> are all HTML tags, you need to learn HTML, it’s simple, there are millions of sites that will help you, Google it. Substr is a function, short for sub-string, to output part of a string, in this case, the string (of characters) is $variable. The function is instructed to start at character 0 of $variable and display the next $i characters. So the first time that line of code is executed, $i is equal to 1, so it will output ‘<B>h</B><BR>’, this HTML is will write the letter “h” in bold on a line of the client's web browser. What will happen the next 9 times this code is executed?

The final component is the data, a more abstract concept. To store and retrieve data, you should use a database. You may have heard of the big-boys, such as Oracle or DB2. There is a free alternative which almost all of the browser-based gaming sites are using known as MySQL. This is a third language you will need to learn, check out www.mysql.com (http://www.mysql.com) for the documentation, again, read it, learn it, don’t be lazy. Like PHP, MySQL is also free. PHP comes with a set of functions (like substr from above) that will allow your code to interact with the database, a common one is mysql_query($sql_code), which will execute a “query” on a database and return the result to PHP. What kind of data goes into the database? Anything that changes and often times, things that will never change; the usernames, passwords, users’ email addresses, drug names, coat pocket contents, working junkies, messages, cartel information all go into the database. You use PHP functions to store data into the database, as well as retrieve data from it.

Well that’s making a game in a nut-shell. Maybe this document told you nothing you didn’t already know, or it is well beyond you, in the latter case, don’t worry, just try to extract to main concepts from here and start 1 step at a time. My recommendation is learn HTML first, once you got that down, then work on the basics of PHP, once you got that, start doing PHP that involves database interactions. Once you got ALL that, then make simple applications, such as accepting input and storing it, while retrieving some other data and displaying it, only after being able to do all that, should you make a game. Good luck and have fun!

Dymond
8th August 2006, 03:17 AM
LOL awesome Tutorial Rit!!
My only suggestion would to also learn the basics of SQL and the theory of relational databases..I can't imagine your games are using flat tables correct?

kurtis469
8th August 2006, 07:40 AM
thanx rit i would give u rep but you turned if off very usefull

Smash Bros
8th August 2006, 08:10 AM
thanx rit i would give u rep but you turned if off very usefull


maybe for you. i just repped him lol.

cheers rit. looks very useful. ill take a look once i get the net back at mine again.

Puppy Dogs and Ice Cream
8th August 2006, 08:32 AM
can you help me make a game rit? lol

kurtis469
8th August 2006, 08:42 AM
can you help me make a game rit? lol


me too...can u code it for me and ill do the rest lol

steff
8th August 2006, 09:03 AM
This gives me horror images of learning True-BASIC and IIRC it is fucking useless for everything. :P I also learned Prolog too... that was a pile of shite IIRC too :P

the_big_man
8th August 2006, 12:52 PM
I personally dont have time to do all that stuff just for a game, and i like your game better than anygame i would ever make

Diogee old
8th August 2006, 07:24 PM
Great post treadon, I would like to point out that their are plenty of free scripts that can help you learn php and mysql. Although even with the free scripts it takes time and patience to learn as there are many functions. Also a tip for the "turns/tokens/ticks" is a cronjob. Info on crons (http://www.unixgeeks.org/security/newbie/unix/cron-1.html)

Here is a code for a very simple cron file
<?php
include "../connect.php";
$getturns="Update users set numturns=numturns+2";
$getturns2=mysql_query($getturns) or die("Could not get turns");
?>

This is just an example of a cron file there are many differnt ways to code it.

EDIT: Also Dreamweaver is a very usefull tool for PHP. I would also suggest Javascript for your sites again many free scripts to help you.

Diogee old
10th August 2006, 02:53 PM
Great PHP Web Site
http://www.php-editors.com/

Suggested Material
http://www.php-editors.com/php_manual/
http://www.php-editors.com/pear_manual/
http://www.php-editors.com/smarty_manual/
http://www.php-editors.com/mysql_manual/
http://www.php-editors.com/links/

Now if you are commited to making a PHP game. Then you will need a hosting plan here is a site with some of the best hosting sites available.

http://www.hosting-review.com/?gclid=CKnoz4C51IYCFQ2kWAodQ3Ls8g

Also a great tool for editing PHP is Dreamweaver, so I found a link to a dreamweaver torrent with keygen included, tested it myself so it does work.

http://torrentspy.com/torrent/417932/Dreamweaver_8_With_KeyGen

kurtis469
10th August 2006, 04:12 PM
good start up hosting site is 1and1.com

Dymond
11th August 2006, 12:46 AM
Remember the webhost needs to have a mysql database access! Some hosting services don't offer that. I can suggest a site that I'm running my website from because I have had great success and they are fairly inexpensive.

www.spenix.com

Mikey:)
15th August 2006, 10:58 PM
http://www.wampserver.com/en/

WAMP5 installs Apache, PHP5 and MySQL on Windows platform in one easy installer. It comes with a service manager as an icon tray and lots of options and its free. Its worth a mention that having an apache server running locally on your computer will help a great deal when your looking to develop web based games.

Dave Edit: Awesome Link Mikey! Installing these seperately can be a pain but to have something that does the work for you is nice. I am going to take advantage of this!

kurtis469
16th August 2006, 07:35 AM
http://www.wampserver.com/en/

WAMP5 installs Apache, PHP5 and MySQL on Windows platform in one easy installer. It comes with a service manager as an icon tray and lots of options and its free. Its worth a mention that having an apache server running locally on your computer will help a great deal when your looking to develop web based games.

Dave Edit: Awesome Link Mikey! Installing these seperately can be a pain but to have something that does the work for you is nice. I am going to take advantage of this!


good link man thank but has anyone ever used this ???? or if they are using it does it work good ?

Dymond
21st August 2006, 06:03 AM
I have installed Apache, PHP and MySQL on a windows machine before. I just did it the long way. This looks to take out some of the fuss.

chaoswolf
8th January 2007, 10:12 PM
sweet!!! i was about to ask, cause my friend just got his hands on a sever

Radical Truth
13th February 2007, 09:04 PM
Thanx for bumping this up chaoswolf!
One of my tasks for the day is reinstalling PHP and Apache. Must be my lucky day.
Great link Mikey (f)
Are you still about these days?

Mikey:)
16th February 2007, 10:04 AM
Only when people bump my old threads

Stinger
14th September 2007, 03:13 PM
Rit~
I read your post, and although I am amongst those that did NOT understand a bit of it (well beyond me), I don't want to make a game. I just want to say WOW. Rit...you ROCK! Not only did you create an awesome game (what an enormous amount of work), but you are willing to share a piece of the vast knowledge required to do so with your many random "followers". *wink* Thanks for this. Most people wouldn't bother to even take the time to reply, let alone to go into such detail. :airkiss:

Sir Brian
8th June 2008, 05:57 PM
i find that really interestin, though i dont have the slightest ambition of coding anything, ever. Not even M Express. :whistle:

:D

50thageneral
7th August 2008, 07:34 AM
or you could steal a script? get a FTP program, upload the files from notepad, get a host and work it out that way! Saves you about 6 months of your life and you have a sweet game called DupeWars!

Cushion
7th August 2008, 08:49 AM
how do u go about stealing the script ?