如何让我的纸牌游戏工作 [英] How do I do this for my card game to work

查看:58
本文介绍了如何让我的纸牌游戏工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对C编程很陌生,不太擅长编码。

我想创建一个纸牌游戏,但我似乎无法解决一件事。

如何在两个玩家之间从一个牌组分发固定数量的牌转,所以第一张牌转到第一张牌,第二张牌转到第二张牌,第三张牌再转到第一张牌,依此类推。



我尝试了什么:



不多,无法弄清楚! .................................................. ..

I'm pretty new to C programming and not very good at coding it.
I want to create a card game, but I cant seem to figure one thing out.
How can I distribute a fixed number of cards from one deck between 2 players in turn, so the first card goes to the first player, the second card to the second player, the third card again to the first player and so on.

What I have tried:

Not much, cant figure it out! ....................................................

推荐答案

看看你的另一个问题,我建议你创建一个卡片阵列,其中52个,并填写你的卡片实例:13黑桃,13,俱乐部,...

然后写一个功能来洗牌。

添加两个整数:牌组中的牌数(设置为52),顶部卡(设置为0)

要处理卡,请将卡放在顶部索引处,然后递增索引。减少计数。如果计数现在为零,则将牌组洗牌,并重置两个整数。
Looking at your other question, I'd suggest that you create an array of Cards, 52 of them, and fill it with your Card Instances: 13 Spades, 13, Clubs, ...
Then write a function to shuffle the deck.
Add two integers: Number of cards in deck (set to 52), top card (set to 0)
To deal a Card, take the card at the top index, and increment the index. Decrement the count. If the count is now zero, shuffle the deck, and reset the two integers.


Quote:

我是C编程的新手,并不是很擅长编码。

I'm pretty new to C programming and not very good at coding it.



建议:暂时搁置你的项目并花时间学习如何制作程序,按照教程。



掌握一些分析方法, Dijkstra自上而下方法是一个良好的开端。

https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design [ ^ ]

https:// en .wikipedia.org / wiki / Structured_programming [ ^ ]

https://en.wikipedia.org/wiki/Edsger_W._Dijkstra [ ^ ]

https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF [ ^ ]


Advice: put aside your project for now and take time to learn properly how to make programs, follow tutorials.

Master some analyse methods, Dijkstra Top-Down method is a good start.
https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design[^]
https://en.wikipedia.org/wiki/Structured_programming[^]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra[^]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF[^]


这篇关于如何让我的纸牌游戏工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆