PHP Game Tutorial

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PHP-Required
Forum Newbie
Posts: 1
Joined: Thu Jul 21, 2005 6:07 pm

PHP Game Tutorial

Post by PHP-Required »

I was wondering if someone could point me or show me a tutorial on making a php game (not a big one just like a small one) I want to make a php mini game center for my website... if you got a tutorial that would help me please post it here or send it to php-required@hauntedgraveyard.net thank you


php-required@hauntedgraveyard.net
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

That would be virutally impossible. Games written in PHP are just websites with a specific theme. There's practically no commonality between the way various games work, so there'd be nothing to base the tutorial around. If you're interested in writing a game, learn how to write other applications (blogging, ecommerce, cms, contact management, image creation, etc), and then transfer what you learn into game development.

It's the same in all areas of software. You'd probably be suprised just how dull 95% of games development really is. You spend a lot less time thinking up cool storylines and character stuff, and a lot more buried neck deep in writing vector maths systems and menu code.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

onion2k wrote:That would be virutally impossible. Games written in PHP are just websites with a specific theme.
You could not be more wrong.

There are over a dozen highly popular php-driven games. There has been a book on php game programming, and sites with over *50,000* active players exist.

They are nothing like a website with a specific theme. 40,000 lines of code in BNT alone dwarfs all but an e-commerce website. Hardly a theme.
onion2k wrote: There's practically no commonality between the way various games work, so there'd be nothing to base the tutorial around.
Also completely untrue. I work on numerous php games: Blacknova Traders, Wordog, Legend of the Green Dragon, and more.

All of them do things that are common to each other. They all have logins. They all store user data. They all generate html pages. Many have templates. Many have security features. The amount of code reuse that is possible between the games is VERY high.
onion2k wrote: If you're interested in writing a game, learn how to write other applications (blogging, ecommerce, cms, contact management, image creation, etc), and then transfer what you learn into game development.
Actually, because there are so many php games (Promisance, phprpg, the list goes on!), you can dive right in - and many of them are opensource, and DESPERATELY in need of help.

If no one else wants you, Blacknova Traders is always looking for more help!
onion2k wrote: You'd probably be suprised just how dull 95% of games development really is. You spend a lot less time thinking up cool storylines and character stuff, and a lot more buried neck deep in writing vector maths systems and menu code.
Sorry again, but for three fantastic years, I've been working on these games, and its a blast. What you consider uncool can really be a blast. I spent four hours finding a better/faster way to create a warplink table. As a result, I was able to expand games from 2,000 common sectors, to over 100,000. Thats cool. Thats fun.

Granted, by itself, it was just number-crunching and algorithm work, but big-picture, it allowed me to add completely new storylines and game features.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

You don't need a game tutorial to learn to program a game in php, you can just read just general tutorials about anything in php and apply the knowledge gained to your application, however I'm sure some one will find a game specific tutorial for you; but you will most likely end up reading other tutorials to learn more.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Roja wrote:
onion2k wrote: There's practically no commonality between the way various games work, so there'd be nothing to base the tutorial around.
Also completely untrue. I work on numerous php games: Blacknova Traders, Wordog, Legend of the Green Dragon, and more.

All of them do things that are common to each other. They all have logins. They all store user data. They all generate html pages. Many have templates. Many have security features. The amount of code reuse that is possible between the games is VERY high.
The list of things you mention there are not game specific. They feature on every website I've written in PHP. As I said before, PHP games are just websites with a specific theme like any other. If you get down to the raw code you'll find 99% of sites are all the same:

1. Log in stuff.
2. Content management stuff.
3. Admin stuff.
4. Data manipulation stuff.

Whether it's an ecommerce app or an RPG the principles are exactly the same.
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

personally if I was developing a small game for a website I would make the game front end in flash and use php behind the scenes to drive all of the data etc.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

onion2k wrote: The list of things you mention there are not game specific. They feature on every website I've written in PHP. As I said before, PHP games are just websites with a specific theme like any other.
Character generation. Inventory storage. A*Star best path search algorithm. Combat sequences. Game balance issues.

These things are not done in any ecommerce app, any application, and certainly not a website with a theme.

You are seriously insulting and underestimating a growing field that I've spent 3 years enjoying, and you have no experience to draw from when making your claim. Ron Harwood, the original creator is giving a presentation at an upcoming php conference on php gaming. If it was so common and so simple, why give a presentation on it?

I seriously suggest you look into any of the dozen games that are out there before (yet again) trivializing php games as "a website theme". Its nothing of the sort.
onion2k wrote: If you get down to the raw code you'll find 99% of sites are all the same:

1. Log in stuff.
2. Content management stuff.
3. Admin stuff.
4. Data manipulation stuff.
To a degree, I will agree that there are core items that are the same - thats the very point I made in my last post. *YOU* said "There's practically no commonality between the way various games work", which was completely inaccurate, and now you've reversed course and said 99% have commonality. Make up your mind.

In truth, 99% is hardly accurate. Over 1/3rd of the BNT codebase is game-specific code, dealing with issues that a normal website would never touch. How to traverse a space in the best path possible. How to handle planetary combat. How to handle player-to-player combat and interactions. These are not common functions. They are true game programming issues, common to most games - in any programming language.
onion2k wrote:Whether it's an ecommerce app or an RPG the principles are exactly the same.
Show me one ecommerce app using an A*star algorithm.

Seriously, your first post was ignorant of the php gaming scene, and this post is just flippant. *LOOK* at the code before commenting further about how 'trivial' it is. 40,000 lines of code is not a website theme.

Thats why there is a Book on PHP game programming. Its not just a website theme. Its complex, its unique, and it has specific challenges that you have to address.

The original poster wanted to know how to progam php games. You had no experience doing so, and your advice was "work on something else first". I've got three years experience with the field, there are books written on the topic, there are presentations being given at conferences, and there are whole communities built around improving the games. Lets focus on helping the original poster instead of belittling the very genre he is interested in - a genre that is growing, interesting, uncommon, and challenging.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Roja wrote:The original poster wanted to know how to progam php games. You had no experience doing so, and your advice was "work on something else first".
Err.. I've written lots of games*. I've written them in PHP, Blitz3D, C# with DirectX.. I've even had some code running on a Playstation 1 (only a little Net Yaroze demo thing mind you).

I do have experience of this stuff. My point is that a game is merely an application designed to entertain people rather than serve a business purpose. The principles are all exactly the same no matter what purpose the application is supposed to serve.

* Here's an example: http://www.ooer.com/b3d/tank.zip (very much Beta, B3D source included, just run tank.exe to play .. controls are ASWD and mouse to aim. And F to drop a mine.)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

onion2k wrote:My point is that a game is merely an application designed to entertain people rather than serve a business purpose. The principles are all exactly the same no matter what purpose the application is supposed to serve.
Once again - show me an ecommerce app with A*star. They are not exactly the same. There are game-specific issues that programmers have to deal with.

There are entire courses in college specific to game design theory. Whole colleges that exist *solely* to teach the very unique and uncommon needs of games.

They are *not* just like any other application.

But if you want to get general enough, yes - shockingly, programs all need to take input, give output, and process inbetween. Thats the level of generalization that you need to approach to defend your illogical argument.

I think you can understand that generalizations at that level mean nothing, and do nothing to help the original poster.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Roja wrote:Once again - show me an ecommerce app with A*star. They are not exactly the same. There are game-specific issues that programmers have to deal with.
That's ridiculous. It's like saying "Well, only online shoe shops have a foot size function, therefore they're completely different to all other websites".

You can't highlight a specific function and suggest that makes the application totally different to all other applications. Coz it doesn't.

Besides, given enough time I'm sure I could dream up a use for pathfinding in an ecommerce app. And weapons.

In fact, more ecommerce apps should have weapons. :twisted:
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

interesting reading.
programmermatt
Forum Commoner
Posts: 65
Joined: Tue Mar 15, 2005 5:03 pm
Contact:

Post by programmermatt »

Sorry to take this conversation off its current flow, but I was curious as to why BNT has not released anything to sourceforge in about 3 years? Is active development over or are you releasing code through other means?
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

programmermatt wrote:Sorry to take this conversation off its current flow, but I was curious as to why BNT has not released anything to sourceforge in about 3 years? Is active development over or are you releasing code through other means?
Active development isn't over, we have a new release due out in a few weeks, and a *much* larger release due out after that. Its a long story, so I'll PM you the details instead of going far off topic. :)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

onion2k wrote: You can't highlight a specific function and suggest that makes the application totally different to all other applications. Coz it doesn't.
Like I said, by your standards, yes, every program does input, output, and processing.

There are differences. Perhaps you should read up on game theory, game design, and understand why people (John Carmack, for example) can spend 10 years learning just how unique and totally different games are.

A*Star is a perfect example of the types of domain-specific knowledge you need to have. Most games have to do pathfinding. Pathfinding by itself has over a dozen major books dedicated to it. But to you thats not unique.

Game balance is an entire course at Full Sail - a college dedicated to game studies.

The list goes on. You are entitled to your opinion about games, but answering someone interested in learning how to program games with "Learn something else" is hardly as helpful as "Here are 12 opensource games that you can jump into programming today".
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

And just as a side note: Neopets is a PHP-driven game website. They use Macromedia Flash for their games, and PHP to run the database and fun stuff ^_^;
Post Reply