通过图像文件将纸牌实现为纸牌游戏. [英] Implement cards to a card game from image files.

查看:76
本文介绍了通过图像文件将纸牌实现为纸牌游戏.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个名为UNO的纸牌游戏,我得到了一些我想使用的纸牌图像,我想知道您如何以一种简单的方式将它们加载"到程序中.还可以为其分配值,并可以在图片框中随机显示.

我必须为每张卡创建指定的阵列吗?像card [x](imagefrompath(?),value(int),name)等...

我对此很陌生,因此我感谢所有帮助. :)

Hi,

Im creating a cardgame called UNO, and i''ve got some images of the cards that i want to use and i wonder how you in a easy way "load" them into your program. Also assign values to them and be able to randomized show up in a picturebox.

Do i have to create a specified array for each card? Like card[x] (imagefrompath(?), value(int), name) etc...

Im pretty new to this so Im thankful for all help. :)

推荐答案

我在代码项目中看到以下使用cards.dll进行卡片显示的链接.

经历这个..,这可能对你有帮助


使用Cards.dll绘制卡片 [
I see the below link in code project for cards display.., using cards.dll

go through this.., this may help u


Drawing Cards with Cards.dll[^]


我讨厌将它破坏给您,但是有人已经发明了Uno ! :)

但是对于您的问题...您不必创建数组...您可以通过多种方式来执行此操作.至于加载"它们...我可能会做这样的事情...

将所有图像压缩到一个文件中.
将该文件添加到您的资源中.
程序启动时,我将解压缩文件并提取所有图像并将它们放置在数组中.您可以从另一个答案中遵循文章中的编号约定(如果您使用自己的图像,这对您而言唯一有用的东西).
至于随机化,您可以使用.Net Framework中的Random类.如果您要玩现实游戏,只需确保跟踪已使用的卡即可.

但是还有许多其他方法可以做到这一点.
I hate to break it to you, but somebody already invented Uno! :)

But as to your question...you wouldn''t have to create an array...there are a lot of ways that you could do this. As far as "loading" them...I would probably do something like this...

Zip all of the images into one file.
Add that file to your resources.
When the program is started, I would unzip the file and extract all of the images and place them in an array. You could follow the numbering convention found in the article from the other answer (that''s about the only useful thing for you in it if you are using your own images).
As far as randomization, you can use the Random class in the .Net Framework. Just make sure you keep track of the cards that have already been used if you want a real-life game.

But there are many other ways to do this.


这篇关于通过图像文件将纸牌实现为纸牌游戏.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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