[web] Tutorial: Making PHP webgames from scratch.

Started by
4 comments, last by Mathachew 17 years, 9 months ago
The only coding experience I have was from Flash Actionscripting (AS). AS game programming is "tutorial heaven" - with no prior coding experience I learnt how to make scrolling shooters and on-rails shooter within 3-4 weeks. The biggest problem in PHP webgame programming is that it is too easy for people who learnt the basics. If we learn how PHP work, it is very easy to apply the knowledge to make a webgame. The problem is, many game developers have a hard time learning coding, no matter how simple. Main reason is because of a lack of interest: I cannot learn actionscript by learning the basics and simple keywords. The only way I could learn AS without falling asleep is actively coding the game that I want and picking up AS along the way. There isn't any Tutorials on the net for PHP games. So I thought: Why not start one? Experienced coders please bear with me: I'm going to write this in a way that is probably "dumb" for programmers because I'm not going to start with the basics. It'll be in a reverse engineering way: start with our final product and examine the steps required to reach there. This is the most effective way for me and I suspect for many eager game designers. Experienced coders/programmers: I have no PHP experience either! Therefore, most of this article will be me asking for help but I'll make it very specific: no open ended questions like "how do i make graphics". Most of the time it'll be simply asking you guys to post links to codes on the net. If you do help out: THANK YOU VERY MUCH! :) Non-coders/programmers: If you want to learn much from this Tutorial, it is best that you participate actively. This tutorial is very much for my benefit than anything else and so i might miss out things that others might need to know. Lets start...
Advertisement
Game Programming Basics

If you can do "Hello World" in PHP, GREAT! We're ready to start! But I guess some of you reading this might have zero programming experience. I was fortunate to start with Actionscripting which is an extremely easy language to start with!

A quick way to get some programming experience is to get the trial version of Flash and code a crude flying shooter using this step by step tutoral:
http://www.gotoandplay.it/_articles/2004/10/sshooter.php

I didn't learn just from that tutorial and the game it made is pretty crude (no diagonal movement of the plane!) but it is a pretty effective way to get some coding experience under your belt. Important things to learn are: Variables, Functions and the general way programs work.

If you don't know what are Functions, Loops, Variables, "Nesting", Class (for OOP) then we might have a problem. I don't think expert knowledge is required but at least know what they are and vaguely what they do.

Setting up PHP

This is another thing that most people should know and if you don't it is very difficult to accomplish anything. All you have to do is to get to the point where you can do "Hello World".

There is a very simple and straightforward tutorial on www.php.net regarding the setting up and coding of "Hello World" in PHP. I'll post the link later when I can access PHP.net (it is down for me).

I recommend PHP Designer as your coding software. It rocks!
Game Programming Wiki (see the last paragraph; links to a live example, but no code)

PHP Game Source Code (multiple examples with full open source)

PHP Game Programming Book (recommended)
Available Resources

There is actually one Tutorial on the net that addresses PHP Gaming:

Part 1
Part 2
Part 3
Part 4

But it is of limited use for PHP game developers with zero PHP programming experience.

There is one book that specifically deal with PHP game programming:

PHP Game Programming

But all PHP books can be used for PHP game programming since a basic mastery of PHP would equip you with the tools for a PHP game.


First Lesson

I assume you have a game model/design, which is probably the simplest and most fun part of this entire process. Lets do some basic coding: The log-in system.

A registration/log-in system, according to my formally trained programmer friend, is one of the simplest thing to code. It can be done in 5 mins if you're skilled. Furthermore, every PHP webgame require one of these and therefore I think it'll be a great starting point.

The basic model of our log-in system consists of:

1) A Database to store Usernames, Passwords and a Variable.
2) A webpage containing a simple form that allows people to log into your system. This page will access the Database and check if the Username/Password matches.
3) A registration page containing a form that allows editing of the Database, adding new Usernames and Passwords.

Our goal in this lesson is to accomplish this:

1) Register Username, Password, Real Name.
2) Log in with Username, Password.
3) Once logged in the user will reach a page showing his Real Name.

*A coder pointed me in correct direction. Once i sorted it out i'll update this.

[Edited by - sarahcovenant on July 28, 2006 1:04:27 AM]
I hope you do know that you could have put everything into one post.
Thanks for the variouus resources everyone!

This topic is closed to new replies.

Advertisement