制作金字塔纸牌游戏,不确定如何设置金字塔

时间:2014-08-01 00:55:18

标签: php arrays for-loop

我通常不会用PHP制作游戏,我通常只是做网站,但我之前用PHP制作过纸牌游戏。

这次我想尝试金字塔纸牌游戏,因为我喜欢玩它。

我不确定如何设置初始金字塔(显示底部前排,休息调整结束)。

示例:http://www.playjava.com/images/pyramids_ttl.jpg

http://www.playjava.com/images/pyramids_ttl.jpg

我使用for循环制作了金字塔,并且它设置得非常好,但我的问题是我不确定这是否适用于我需要的或如何执行检查以查看是否有新卡需要揭示。

我通常知道事情是如何运作的,但这让我很难过。

这是10个显示卡的底行的for循环。 ($ deck是一个准备好洗牌的阵列。)

for ($i=0; $i<10; $i++) {
    $card = array_shift($deck);
    echo "<div style='position:absolute;top:".$card_lvl_1t.";left:".$card_lvl_1l.";width:55px;height:90px;'><img src='".$card."' border='0'></div>\n";
    $card_lvl_1l = $card_lvl_1l+56;
}

非常欢迎任何建议。

很抱歉,如果这篇文章有点令人困惑或描述不好,但基本上我所要求的就是你会做什么的建议。

感谢。

1 个答案:

答案 0 :(得分:1)

很抱歉,如果我的想法不完整,但这就是我将如何解决这个问题,并且对于如何处理所有事情都处于高位。在进行任何编码之前,仍需要进行调整/最终确定。

我不会只使用php,jQuery也会参与其中。基本的游戏玩法是两张牌必须等于13,然后他们删除。如果完全取出卡片取消隐藏卡片,卡片会显示。另外,不要忘记浪费和绘制桩。 jQuery会调用PHP,PHP会以JSON身份返回。

PHP

Game class (OOP)
 |- initialize that would randomize the placement of cards in the pyramid and draw pile
 |- draw pile
 |   |- cards put in draw pile in a order to call
 |- waste pile
 |   |- cards put in waste pile in a order to call
 |- evaluate cards (card1, card2)
 |   |- sometimes may be one card (King)
 |   |- This would evaluate if they equal 13 and if they are remove
 |   |- Call to check card above if fully uncovered (probably would give each card a cover of 1 or 2 (1 card removed, then cover would be 0.5 or 1)
 |   |- successful?? remove cards from deck variables
 |   |- return JSON to remove cards and flip card X (if value not already in page, pass card face value)
 |- evaluate cover (card)
 |   |- this would check to see if the card is fully uncovered and used by the above
 |- card face value
 |   |- this would return the card face value
 |   |- Ex: King of Hearts may be KH, H13, or similar
 |- score
 |   |- self explanatory, but used to keep score if wanted
 |- card movment
 |   |- self explanatory

当然,变量可以存储金字塔,绘图,废物堆或卡片信息中的任何信息。

的jQuery

这将包括实际的游戏设置,播放和输出。

 Click
  |- Track 2 clicks in a row (within same div??)
  |   |- same card
  |   |   |- waste pile or pyramid card - do nothing
  |   |   |- draw pile - move card to waste pile
  |   |   |   |- ajax call to move card from draw -> waste
  |   |- different cards
  |   |   |- highlighting of cards clicked
  |   |   |- ajax call to check value in php file
  |   |   |- if successful in removing cards, display uncovered card if returned
  |   |   |- update score
  |- controls that do not require 2 clicks
  |   |- card is a king
  |   |- new game
  |   |- draw to waste pile button
  |   |- etc....