1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Santa Clara, CA
    Rep Power

    Developing a web based two player game in PHP

    I want to develop a simple game in PHP.Game is as follows, a server displays a image to the two players,two players have to type keyword corresponding to the image if the key word is same,they are given next image. What I am confused is how to develop the interface for this game.How do I display an image to two different players simultaneously and how do i keep track of their answers.Moreover how to implement two players ?
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    A Land Down Under
    Rep Power
    While it's possible it's not going to be an easy thing to do. From what I'm guessing about your request, you'd have to use a database to keep track of the players, who is logged in, who's playing games and which players are assigned to each game. Then you'll need some way to poll the server to see what the other games state is so this would involve JavaScript and AJAX. You'd need to continually check the games state to see what the game wants to do next, then you can wait for the other player, prompt the player to make their move/guess/etc.
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Pennsylvania, USA
    Rep Power
    I could simplify it a bit more, but the basic theory is the same. Database (or memcache) to keep track of which player belongs to which game, a current game state table, and then ajax pollers constantly waiting for the other player to make a move and advance the game state.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo