TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   pgn files for chess (http://www.talkphp.com/absolute-beginners/4116-pgn-files-chess.html)

hello-world 04-09-2009 10:16 AM

pgn files for chess
 
There are many Chess and tactics Server using PGN files.
Are those games played on client side ?
Can anyone tell how they embed it into php ?

dschreck 04-12-2009 01:49 AM

Quote:

Originally Posted by hello-world (Post 22939)
There are many Chess and tactics Server using PGN files.
Are those games played on client side ?
Can anyone tell how they embed it into php ?

Depends.

I'd have to say though, I'd rather just use flash for that type of board game. ActionScript 3 offers you a lot of control in flow, and the ability to create movie files for each piece. Which offers a lot of possiblities as far as adding spice to the game. Like pieces that walk to their position with animation, animiated combat, etc etc. ActionScript 3 can also be bundled with SmartFoxServer - which would allow you to have a multiplayer chess game in about 2 or 3 days of work.


But as far as doing it in just PHP... that's not too difficult either.

You have to set up a series of rules for the game, ie: pieces can only move in this direciton, only move so many spaces.

You could do it purely in JavaScript, which would be only client side. The problem with that is you're now relying on the player to not change those rules. So you'll need to validate the users actions on our server side.
This can be done with ajax.

Now making this multiplayer is a little more difficult, as you'll need to handle and hopefully maintain several sessions at once. You must also force the user to respond.

There's several design methods to get around this, not all of which I'm allowed to speak of due to where I work ;p


If you're looking on where to get started: Try it in PHP and JavaScript + some Ajax. Shoot, I'd say just get it to respond to where you click on the board.

Then try to get it to allow you pick a piece, and move that piece to that place you click.

Then, try and get it to respect the rules you want to use.

And yes, use pngs :)

xenon 04-12-2009 09:29 AM

You'd need to parse the PGN files and extract information from that files in order to reconstruct a chess game. They are only "recordings" of chess games, if you're more confortable with that term. You COULD use PGN files to do that recording, or you could use your own programs to do that (as PGN files parsing is a more complex task). Use PGN files if you want to provide compatibility with the international chess leagues and such (it is a common format recognized by these authorities).

As already said before, you could make the game 100% server or client side based, or you could use both.

@dschreck: he asked about Portable Game Notation, not Portable Network Graphics (they have no generalities what so ever).

dschreck 04-12-2009 08:22 PM

Quote:

Originally Posted by xenon (Post 23034)
@dschreck: he asked about Portable Game Notation, not Portable Network Graphics (they have no generalities what so ever).

Hah! I misread :(


All times are GMT. The time now is 03:15 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0