h5游戏抽奖游戏源码

背景 (Background)

A while back I wrote an article called Simple Games which described how to create several "old school" games like Tic-Tac-Toe, Hangman and Blackjack, the latter of which used a set of graphical playing cards. The article has been well-received so I thought I'd write this article that also uses the graphical card deck.

不久前,我写了一篇名为《 简单游戏》的文章,描述了如何创建多个“老派”游戏,例如井字游戏,Hang子手和大酒杯,后者使用了一组图形扑克牌。 这篇文章广受好评,因此我想写这篇也使用图形卡套的文章。

卡座 (The Card Deck)

The card deck which is, or at least used to be, supplied by Microsoft is named VBcards.ocx. In the rest of this article I will refer to it as "the deck". It contains images of the normal 52 playing cards plus several other images that are useful in card games. If you have it on your computer then great. If not then I've attached it here so you can download it. After downloading you'll need to change the extension to "ocx".

由Microsoft提供或至少以前由Microsoft提供的卡座称为VBcards.ocx。 在本文的其余部分中,我将其称为“平台”。 它包含正常52张纸牌的图像以及其他在纸牌游戏中有用的图像。 如果您将其安装在计算机上,那就太好了。 如果没有,那么我将其附加在这里,以便您下载。 下载后,您需要将扩展​​名更改为“ ocx”。

Vbcards.txt

Vbcards.txt

玩游戏 (Playing the Game)

Both versions of the game work the same and the pictures that follow come from the Visual Basic Classic (VB6) Version.

这两个版本的游戏工作相同,并且后续图片来自Visual Basic经典(VB6)版本。

“交易”按钮 (The 'Deal' Button)

Here is what the game looks like after clicking the 'Deal' button. A new, random, set of 5 cards are generated each time it's clicked.

这是单击“交易”按钮后游戏的外观。 每次单击都会生成一组随机的5张新卡片。

“绘制”按钮 ('Draw' Button)

After the cards are dealt you are given the chance to replace one or more cards in the hope of improving your hand. You indicate which cards you want to replace (usually called "throw away" in poker) by clicking on one or more cards and the 'Draw' button becomes available. In the hand shown, adventurous people might throw away the two kings in hopes of getting a flush or straight flush, but most people would correctly throw away the clubs. After doing that the display looks like this:

发牌后,您将有机会更换一张或多张卡,以期改善牌局。 通过单击一张或多张纸牌,您可以指定要替换的纸牌(在扑克中通常称为“扔掉”),并且“抽奖”按钮可用。 在所示手中,冒险的人可能会抛弃两位国王,以期获得同花顺或同花顺,但大多数人会正确地抛弃球杆。 完成后,显示如下:

If you change your mind about one or more cards you can click it/them and the old card will reappear. When you click the 'Draw' button the missing cards are replaced and as in the real game you don't get another chance.

如果您对一张或多张卡片改变主意,则可以单击它/它们,然后旧卡片会重新出现。 当您单击“抽奖”按钮时,丢失的纸牌将被替换,就像在真实游戏中一样,您不会再有机会了。

“发卡”按钮 ('Cards Dealt' Button)

When clicked, a message will be displayed that in the case of our original hand, will say "Two of Clubs, Five of Clubs, King of Diamonds, Three of Clubs and King of Spades".

单击后,将显示一条消息,在我们的原始手中,将显示“两个俱乐部,五个俱乐部,钻石之王,三个俱乐部和黑桃王”。

“评估手”按钮 ('Evaluate Hand' Button)

When you click this button a message will be displayed that, in the case of our original hand, will say "A pair of Kings".

当您单击此按钮时,将显示一条消息,对于我们的原始手,该消息将显示“一对国王”。

“其他卡”按钮 ('Other Cards' Button)

As I mentioned above, the deck comes with more than just the 52 normal card faces. While it has nothing to do with Poker, I added this button so that you can see what else comes in the deck. Here's what you'll see after clicking it:

正如我上面提到的,卡座不仅具有52张普通卡面。 尽管与扑克无关,但我添加了此按钮,以便您可以看到甲板上还有其他内容。 单击后将显示以下内容:

You may notice that I used 'Card 55' in the 'Draw Cards' paragraph.

您可能会注意到,我在“抽奖卡”段落中使用了“ Card 55”。

关于甲板 (About the deck)

The deck comes with 69 images which consist of the 52 normal card faces and the 17 other images shown in the previous paragraph.

卡座上有69张图像,其中包括52张普通卡面以及上段所示的17张其他图像。

When writing code that involves the deck, the cards are referred to by a number from 1 to 69. Note that somewhat strangely, the cards are not in the normal spades, hearts, diamond, clubs order but rather spades, diamonds, clubs, hearts order:

在编写涉及套牌的代码时,纸牌由1到69之间的数字表示。请注意,有些奇怪的是,纸牌不是按正常的黑桃,心,菱形,棍棒顺序排列,而是按锹,菱形,棍棒,心形排列。订购:

  • 1 - 13 are the Spades黑桃1-13
  • 14 - 26 are the Diamonds14-26是钻石
  • 27 - 39 are the Clubs27-39是俱乐部
  • 40 - 52 are the Hearts40-52是心灵

Numbers 1, 14, 27 and 40 are the aces. 2, 15, 28, 41 are the twos, and the rest progress in numerical order to the kings.

数字1、14、27和40是A。 2、15、28、41是二,其余的按数字顺序排列到国王。

用甲板编程 (Programming with the Deck)

To use the deck in a program you need to add a Reference to it and the default name for the deck is Deck1.

要在程序中使用平台,您需要为其添加引用,平台的默认名称为Deck1。

抽卡 (Drawing a Card)

I'm using "drawing" in the poker sense and to do so you just add a line of code like the following:

我在扑克中使用“绘画”,这样做的话,您只需添加如下代码即可:

Deck1.ChangeCard = GetACard

In the code that I've supplied, GetACard is a function that returns an unused, random, number between 1 and 52. ChangeCard is a method supplied in the deck that IMO would be better named ChangeCardTo because it changes the image to be the one associated with the supplied number.

在我提供的代码中, GetACard是一个返回未使用的,介于1到52之间的随机数字的函数。ChangeCard是甲板上提供的一种方法,IMO最好将其命名为ChangeCardTo,因为它将图像更改为一个与提供的号码相关联。

评估一手牌和其他代码 (Evaluating a Hand and Other Code)

The code behind the 'Evaluate Hand' button uses a group of functions named isPair, isTwoPair, isTrips, etc. all the way up to isRoyalFlush which examine the current hand and return True or False. The Dealt and Rank functions combine to generate the message from the 'Cards Dealt' button.

“评估手”按钮后面的代码使用一组名为isPairisTwoPairisTrips等函数,一直到isRoyalFlush为止 ,该函数检查当前手并返回True或False。 的处理好的函数组合以生成从“卡处理好的”按钮信息。

One more important piece of code is contained in the Click event of the 'Deal' button and it looks like this in the Excel version:

“交易”按钮的Click事件中包含另一段重要的代码,在Excel版本中如下所示:

Private Sub cmdDeal_Click()
Dim lngIndex As Long
ReDim mintCardCounts(1 To 13) As Integer
Dim bTesting As Boolean
' Initialize the cards used
mintCardsInHand(0) = 0
mintCardsInHand(1) = 0
mintCardsInHand(2) = 0
mintCardsInHand(3) = 0
mintCardsInHand(4) = 0
' The number of the card we are dealing
mintCurrentCard = 0
'bTesting = True
' Deal
If bTesting Then
' Using 1, 10, 11, 12 and 13 (in any order) will
' create a spade royal flush
Deck1.ChangeCard = 1
imgCard0.Picture = Deck1.Picture
mintCardsInHand(0) = 1
Deck1.ChangeCard = 13
imgCard1.Picture = Deck1.Picture
mintCardsInHand(1) = 13
Deck1.ChangeCard = 12
imgCard2.Picture = Deck1.Picture
mintCardsInHand(2) = 12
Deck1.ChangeCard = 11
imgCard3.Picture = Deck1.Picture
mintCardsInHand(3) = 11
Deck1.ChangeCard = 10
imgCard4.Picture = Deck1.Picture
mintCardsInHand(4) = 10
Else
Deck1.ChangeCard = GetACard
imgCard0.Picture = Deck1.Picture
Deck1.ChangeCard = GetACard
imgCard1.Picture = Deck1.Picture
Deck1.ChangeCard = GetACard
imgCard2.Picture = Deck1.Picture
Deck1.ChangeCard = GetACard
imgCard3.Picture = Deck1.Picture
Deck1.ChangeCard = GetACard
imgCard4.Picture = Deck1.Picture
End If
GroupCards
cmdDraw.Enabled = False
For lngIndex = 0 To 4
mintOldCardsInHand(lngIndex) = mintCardsInHand(lngIndex)
Next
imgCard0.Enabled = True
imgCard1.Enabled = True
imgCard2.Enabled = True
imgCard3.Enabled = True
imgCard4.Enabled = True
cmdEvaluate.Enabled = True
cmdCards.Enabled = True
frmDrawPoker.Repaint
End Sub

What I'd like to point out is when line 19 is uncommented, you can change the code in lines 23 to 47 and set up different hands for testing purposes.

我想指出的是,当第19行未注释时,您可以将第23至47行中的代码更改为测试目的而设置不同的指针。

两种版本之间的差异 (Differences Between the Two Versions)

There is no difference in the way the game is played but there are some differences with the code. In the VB6 version I take advantage of its control array concept to simplify the handling of the card images.

游戏的玩法没有差异,但代码却有差异。 在VB6版本中,我利用其控制阵列概念来简化卡图像的处理。

Excel版本存在问题 (A Problem with the Excel Version)

When you open the workbook you will probably get this message.

当您打开工作簿时,您可能会收到此消息。

(
)

I assume that's because it's an old OCX and Office has "forgotten" about it but in my experience it's perfectly safe. As proof of that you can either click 'OK' or 'Cancel' and it still works.

我认为这是因为它是一台旧的OCX,而Office已经“忘记”了它,但是以我的经验,它是绝对安全的。 作为证明,您可以单击“确定”或“取消”,它仍然有效。

资料下载 (Downloads)

Excel: Draw Poker.xlsm

Excel: 绘制Poker.xlsm

VB6: Draw Poker.zip

VB6: 抽奖Poker.zip

Enjoy!

请享用!

If you find that this article has been helpful, please click the “thumb’s up” button below. Doing so lets me know what is valuable for EE members and provides direction for future articles. It also provides me with positive feedback in the form of a few points. Thanks!

如果您发现本文对您有所帮助,请单击下面的“竖起大拇指”按钮。 这样做可以让我知道对EE成员有价值的内容,并为以后的文章提供指导。 它还以几点的形式为我提供了积极的反馈。 谢谢!

翻译自: https://www.experts-exchange.com/articles/29698/A-Game-of-Draw-Poker.html

h5游戏抽奖游戏源码

h5游戏抽奖游戏源码_抽奖扑克游戏相关推荐

  1. 抽奖系统源码_微信抽奖系统PHP源码开源

    介绍: 微信抽奖系统源码是一个以php+MySQL进行开发的手机抽奖系统源码.用途:适合做推广营销.直播.粉丝抽奖. 功能介绍: 1.后台可以设置每个抽奖用户的抽奖次数,后台添加设置奖品,适和企业和商 ...

  2. java 抽奖系统源码_基于jsp的抽奖系统-JavaEE实现抽奖系统 - java项目源码

    基于jsp+servlet+pojo+mysql实现一个javaee/javaweb的抽奖系统, 该项目可用各类java课程设计大作业中, 抽奖系统的系统架构分为前后台两部分, 最终实现在线上进行抽奖 ...

  3. lua游戏脚本实例源码_在nginx中使用强大的lua实现定向需求

    前言 Lua 是一种轻量小巧的脚本语言,用标准C语言编写并以源代码形式开放, 其设计目的是为了嵌入应用程序中,从而为应用程序提供灵活的扩展和定制功能.其设计目的是为了嵌入应用程序中,从而为应用程序提供 ...

  4. Java实现简易联网坦克对战小游戏(内涵源码)//Java+Java游戏+拓展学习+资源分享

    介绍 通过本项目能够更直观地理解应用层和运输层网络协议, 以及继承封装多态的运用. 网络部分是本文叙述的重点, 你将看到如何使用Java建立TCP和UDP连接并交换报文, 你还将看到如何自己定义一个简 ...

  5. python概率随机抽奖源码_抽奖算法-指定概率的随机

    抽奖模型 普通概率模型 普通概率模型是最常用的一种模型,但是在游戏运营过程中的确发现很多小白玩家不能正确理解--他们认为中奖率 10% 的设定等同于抽 10 次肯定会中一次.这显然是错误的,普通概率模 ...

  6. python射击小游戏源码_导弹发射小游戏——Python源代码

    导弹发射小游戏 # 导弹发射小游戏完整源代码 # Designed by Mcoblack 公众号pythonwanyuxue import turtle import random # 设置屏幕画布 ...

  7. 网上买的几百元的最新微信公众号H5游戏平台完整源码下载

    网上买的几百元的最新微信公众号H5游戏平台完整源码下载 微信Html5游戏平台源码,大家可以直接打开浏览器本地测试,到时候修改下关注链接就行,简单易学 游戏太多了,不上图了,大家自己下去研究吧! 下载 ...

  8. 帝国CMS仿玩游戏网源码大型游戏资讯网站源码

    帝国CMS仿玩游戏网源码大型游戏资讯网站源码 仿<玩游戏>wanyx 大型游戏资讯门户模板,模板采用帝国 CMS7.5 内核制作完成,自带手机版. 模板带有部分内容数据,但没有图片附件,有 ...

  9. 游戏陪玩系统源码中聊天室内礼物系统的实现

    游戏陪玩系统源码中聊天室的礼物系统,第一步用户看到的无外乎都是礼物的列表界面 纵观主流聊天室的礼物列表应该都是使用UICollectionView实现的,所以我也不例外,下面就是各种撸代码.效果如下 ...

最新文章

  1. 初级开发人员的缺点_作为一名初级开发人员,我如何努力克服自己的挣扎
  2. R语言abline函数为图像添加竖线、横线、斜线、回归线实战
  3. mysql导入导出sql文件
  4. Get Started with Apex的playground练习
  5. Deep Residual Learning for Image Recognition(MSRA-深度残差学习)
  6. RabbitMQ入门HelloWorld(C#)(翻译)
  7. opc客户端_OPC UA 预备知识 OPC 核心概念
  8. 新松机器人刻蚀机_中国最大机器人产业基地新松智慧园在沈阳启用
  9. Asp.net中Mysql存储中文乱码解决方法
  10. OpenGL ES 中的模板测试
  11. 关于 API 定义 安全
  12. python 句子中没有中文_使用python进行汉语分词
  13. 【.NET程序员面试题----初级】第一卷
  14. 持续近40年的战争 X86系列CPU大史记
  15. 静态网页设计——春节
  16. 台式计算机睡眠了怎么唤醒,分享大家几种电脑深度睡眠怎么唤醒方法
  17. FFmpeg源代码简单学习:avformat_find_stream_info()
  18. Flink的流处理与批处理
  19. Windows电脑 添加 安卓或者苹果平板作为拓展屏(spacedesk )
  20. NAT技术---网络地址转换

热门文章

  1. 手机传输文件服务器,手机文件传输到服务器
  2. 高性能浏览器网络(High Performance Browser Networking) 第四章
  3. fatal: detected dubious ownership in repository at ‘/home/
  4. bzoj1778 驱逐猪猡 [高斯消元+概率DP]
  5. java外文资料_java外文文献(毕业设计).doc
  6. plotjuggler⬅ROS1/ROS2画轨迹神器➡rqt_plot+rqt_multiplot之超级加强版
  7. sqlmap中tamper的用法
  8. Linux(Ubuntu)下使用OneNote
  9. ​​​​​​​墨画子卿第三章:初心第2节:回家
  10. git cherry-pick 多分支的代码库,将代码从一个分支转移到另一个分支