ここJSノブ。私は、ベアボーンのマルチプレイヤーターンベースのカードゲームを考案しようとしています。私の現在のコーディング知識では、私は次の擬似コードに従って実装することができます..2人のターンベースのゲームロジック
私は3つのファイル、index.html、multiplayer.php、gameStatus.txtを持っています。
index.html:
player one clicks ready button, which sends 1 to multiplayer.php.
player two clicks ready button, which sends 1 to multiplayer.php.
every 1 sec, repeater() checks if "twoPlayerFound" is returned from multiplayer.php.
if "twoPlayerFound" is returned,
then console.log("two players are online, game begins..")
else
console.log("waiting for another player to join..")
multiplayer.php:
when 1 is posted from index.html, php checks gameStatus.txt
if gameStatus.txt has 0
then overwrite gameStatus.txt 0 with 1;
else if gameStatus.txt has 1
then overwrite gameStatus.txt 1 with 2;
send to index.html "twoPlayerFound"
gameStatus.txt:
either has 0,1, or 2
Q1。プレイヤーがもはやオンラインになっていない場合、どうすれば自動的にgameStatus.txtを0にリセットできますか?
Q2。この実装を使用する際の問題は何でしょうか? Q3。これは、マルチプレイヤーゲームのセットアップに
おかげ..
こんにちは...コーディングを習得しようとしている場合、アプローチはちょっとです。しかし、あなたが「完全に機能する」リアルタイムアプリケーションをやろうとしているなら、あなたは[socket.io](http://socket.io/)のようなものにあなたの時間を投資する方が良いと思います。 –