Name: 123 2009-04-22 6:13
hey /prog/ i need some help writing minesweeper with php. how do i do that?
action.php. index.html[code] will have the main interface page with a n*m size minesweeper board where each "cell" of the minesweeper board corresponds to one table cell. The state of each minesweeper game, along with the users ip address should be stored in a file "state.txt" where each line has a format [code]"127.0.0.1 012021200200200012012000010012012" or something, the first token is the users ip address and the second token is the state of the board encoded with bit flags (i.e.: 0 is hidden square with mine underneath, 1 is flagged square with mine underneath, 2 is flagged square with no mine underneath etc..). When the user clicks a "cell" on the table, client side validation is performed, then an asynchronous get request is sent to action.php containing what square they clicked or flagged- this is then validated server side- the operation performed and the state file updated, after which the php page returns the result as an associative array through json_encode() to be parsed client side by the user again, rinse and repeat.