small web-based online game

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
Monopoly
Forum Commoner
Posts: 41
Joined: Wed May 21, 2008 1:19 pm

small web-based online game

Post by Monopoly »

I am planing to write a small web-based online game and I plan to write it in php (using mysql).


I am on the stage of writing the basic plan of the script , but even know I get confused .


Before asking help , I'd like to describe what the game "will" be about (and it will be only if you help me) .


Users register then log in .
Players fight each other using atack/block combinations (they click radio-type posts and then submit them), Example : if a fighter
selects atack "head" but his enemy sets block as "chest" then his enemy loses hp. Get it ?
Players may select their enemies from the the "fight list" and wait for an approval to fight , or vice versa , join the "fight list".
This game is some sort of a fight-club.
Some huge online games use this core (example combats.ru).

I hope you would understand...



While writing the plan of the core of the fight I get confused and I can't find a easy solution.


It would be very very VERY very very kind of you , if you help me or give a link where such help is to be found.


Please help me :oops:
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Re: small web-based online game

Post by Maugrim_The_Reaper »

The best advice is to write out exactly how combat works. Break into steps - if necessary use boxes, and link them with arrows to show how options can split into varying steps.

When that's done implement one step at a time. Use small functions/methods where possible - don't create a massive 3000 line script in a single function. Try to bundle duplicated code into their own helper functions.
Monopoly
Forum Commoner
Posts: 41
Joined: Wed May 21, 2008 1:19 pm

Re: small web-based online game

Post by Monopoly »

Do you think the game should be object-orientated? It's really small...
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Re: small web-based online game

Post by Maugrim_The_Reaper »

Lean towards objects for most things. The thing about objects is that they lend themselves to breaking complex tasks into a tree of smaller pieces you can pull from. If you just need to go hell and hash out something quickly - then feel free to do so. Just label it as a "prototype" and once done look for code duplication, too many if...else branching, etc. These will give you clues as to what objects and flex points are needed for an OOP implementation.
Post Reply