View Full Version : PHP text based game engine

03-24-2007, 02:41 PM

I'm currently just about to start developing a game engine for multiplayer text based games and wanted to ask if anyone had some good tips as to how to go about this. I could probably make one myself at the minute, however it would be a messy and inefficient system. Preferably I would like the game to be completely based around plugins to make it easier for people to make games. Plus I would like it to be easy to edit and add new plugins.

To help describe the structure of the game engine I hope to create I'll just list some of its details:

- must be object oriented
- must have the ability to use unlimited plugins (ie normal game features would be plugins, background processes such as levelling up would be plugins etc)
- must provide an easy method of loading new plugins or removing plugins.
- preferably works using ajax (though not necessary)
- plugins should have a standard structure (probably classes inheriting from a class called plugin or something)
- the structure should be able to be used repeatedly for any game
- possibly provide a set of standard functions that plugins may need

If anyone has any good tips on how to do this I would very much appreciate it :)

03-26-2007, 04:28 PM
My advice: Think about, throw ideas around in your head, and work it out. Once you've got a fair idea of the structure, sit down with a blank piece of paper and thrash it out. You'll spot a load of things that need clarifying as the system goes from fuzzy mental concept to solid design.

It sounds like you've got good ideas on how to build it, so, chew it over, and go ahead and design it.

- preferably works using ajax (though not necessary)

This seems an odd thing to say to me. AJAX is just a tool. Tools don't define what you build.

03-26-2007, 05:52 PM
My suggestion is to not use PHP because it is currently not as useful for large scale Object Oriented programming. But I'm sure you're set on it, so I'll give some tips anyway.

- must be object oriented

Define basic game elements, and try to abstract down as far as possible until you're left with:

Main class is Object

Everything inherits from Object.

Then create things such as Container (Object that can contain other Objects), add functions such as describeContents(), etc. Track amount of weight or # of objects it can contain.

Living Objects (objects that have stats/skills/vitals and can engage in combat, also inherits Container as living things can hold items)

Room Objects (inherits from Container)

My best tip for this part here is: Examine an LPC based Mud (Nightmare, Deadsouls, etc.). Look at the source code, look at their standard objects. They have done a lot of this work for you (my suggestions come from MUDs)

- plugins should have a standard structure (probably classes inheriting from a class called plugin or something)

This is called an interface. You can define one in PHP. Search for it.

- the structure should be able to be used repeatedly for any game

Be able to be used repeatedly?

- preferably works using ajax (though not necessary)

FoxyForest is correct in what he said, a design document (I hope you are making one) should not contain any technologies. It should be ideas formed into requirements.

If you do proper object oriented programming, you should be able to create pages that work with both AJAX, and without it.

03-26-2007, 08:10 PM
Thanks for the tips.

Yes I am working on documents for this. I am currently doing an extremely thorough analysis document of the idea at the minute. So hopefully getting a good analysis down will have helped to identify the everything the system needs allowing for a good design.

As for the issue of PHP not being a dedicated object oriented language, I'm aware of that fact and have toyed with the idea of trying to use java for it. However, my knowledge in java is somewhat lacking. I have much more experience in using PHP. I have made a couple of little text based games. Nothing that has been a huge success but it's not about that for me :P.

The type of games I'm thinking of are not really MUDs but more like bootleggers.us etc. However, I'm sure the same principles will apply. I will be trying to abstract the most basic aspects soon.

Thanks very much for the help :):)

03-26-2007, 08:20 PM
I'm not as experienced with browser turn based strategy games. I've played some, but never worked on code for one.

It might be harder to abstract this down to a low level. Although sounds like an interesting project.

03-26-2007, 09:57 PM
I'm sure it can be abstracted in the same way. Have an object class, user (admin, moderator, player inherit from this) etc. The container class would also apply to what I'm wanting to do.