标题:[原创]扑克牌发拍源码,图形界面
只看楼主
jnwfh
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-12-16
 问题点数:0 回复次数:14 
[原创]扑克牌发拍源码,图形界面
OyhVu4cK.rar (200.06 KB) [原创]扑克牌发拍源码,图形界面



搞了一整天,弄了个图形界面的发牌源码,里面包含了54张牌,才只有初步的东西。

TlcpzPpe.rar (244.25 KB) [原创]扑克牌发拍源码,图形界面

搜索更多相关主题的帖子: 图形界面 扑克牌 源码 发牌 
2005-12-22 16:50
唐伯猫
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:5323
专家分:58
注 册:2005-8-9
得分:0 
看来你用的是05版本的,我的版本打不开.

<iframe name="alimamaifrm" frameborder="0" marginheight="0" marginwidth="0" border="0" scrolling="no" width="300" height="170" src="/go/app/tbk_app/chongzhi_300_170.php?pid=mm_28854300_2441872_11377541&page=chongzhi_300_170.php&size_w=300&size_h=170&stru_phone=1&stru_game=1&stru_travel=1" ></iframe>
2005-12-24 09:11
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
得分:0 
无论如何,谢谢楼主!
2005-12-25 14:29
lovemexiaoyu
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2006-5-12
得分:0 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace Poker
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
Primary.Width = imageList1.Images[0].Width;
Primary.Height = imageList1.Images[0].Height;
}

private void 开始ToolStripMenuItem_Click(object sender, EventArgs e)
{
CardY = this.Height - imageList1.Images[0].Height - 20;
int[] pv ={ 14, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
int[] pt ={ 0, 1, 2, 3 };
ArrayList AllCard = new ArrayList();
for (int f = 0; f < 2; f++)
{
for (int i = 0; i < pt.Length; i++)
{
for (int j = 0; j < pv.Length; j++)
{
AllCard.Add(new Card(pt[i], pv[j], i * pv.Length + j));
}
}
AllCard.Add(new Card(7, 0, 52));
AllCard.Add(new Card(7, 1, 53));
}
this.SelectPrimary(AllCard);
AllCard = SetPrimary(AllCard, PrimaryFace, PrimarySuit,false);
for (int i = 0; i < Gamer.Length; i++) Gamer[i] = new ArrayList();
int alcount = AllCard.Count - 8;
for (int i = 0; i < Gamer.Length; i++)
{
for (int j = 0; j < alcount / 4; j++)
{
int m = rand.Next(AllCard.Count - 1);
Gamer[i].Add(AllCard[m]);
AllCard.RemoveAt(m);
}
}
IComparer cardcomparer = new CardComparer();
Gamer[0].Sort(0, Gamer[0].Count, cardcomparer);
DrawCard(Gamer[0]);
PrimaryCard.Face = PrimaryFace;
PrimaryCard.Suit = PrimarySuit;
SelectPri sp = new SelectPri(PrimaryCard);
sp.ShowDialog();
PrimaryFace = PrimaryCard.Face;
for (int i = 0; i < AllCard.Count; i++) Gamer[0].Add(AllCard[i]);
for (int i = 0; i < 4; i++)
{
Gamer[i] = SetPrimary(Gamer[i], PrimaryFace, PrimarySuit, true);
Gamer[i].Sort(0, Gamer[i].Count, cardcomparer);
}
DrawCard(Gamer[0]);
}

private void SelectPrimary(ArrayList allcard) //随机一张牌
{
PrimaryCard = (Card)allcard[rand.Next(allcard.Count - 1)];
PrimaryFace = PrimaryCard.Face;
PrimarySuit = PrimaryCard.Suit;
Primary.Image = imageList1.Images[PrimaryCard.Index];
}

private void DrawCard(ArrayList GameCard)
{
this.panel1.Controls.Clear();
PictureBox[] GamerButton = new PictureBox[GameCard.Count];
for (int i = GamerButton.Length-1; i >=0; i--)
{
Card MyCard = new Card(0, 0, 0);
MyCard = (Card)GameCard[i];
this.panel1.Controls.Add(GamerButton[i]);
GamerButton[i] = new PictureBox();
GamerButton[i].BackgroundImage = imageList1.Images[MyCard.Index];
GamerButton[i].Location = new Point(0 + CardXSikp * i, 50 );
GamerButton[i].Size = new Size(GamerButton[i].BackgroundImage.Width, GamerButton[i].BackgroundImage.Height);
GamerButton[i].Tag = MyCard;
GamerButton[i].TabIndex = i;
GamerButton[i].TabStop = false;
GamerButton[i].Click += new System.EventHandler(this.Card_Click);
GamerButton[i].Parent = this.panel1;
}
}

private void Card_Click(object sender, System.EventArgs e)
{
PictureBox b = (PictureBox)sender;
int cardindex = this.panel1.Controls.Count - b.TabIndex - 1;
int cardy = this.panel1.Controls[cardindex].Location.Y;
cardy = cardy < 50 ? 50 : cardy - 50;
this.panel1.Controls[cardindex].Location = new Point(this.panel1.Controls[cardindex].Location.X, cardy);
}
private ArrayList SetPrimary(ArrayList allcard, int primaryface, int primarysuit,bool selectface) //设置主牌
{
if (primaryface == 7) return allcard;
for (int i = 0; i < allcard.Count; i++)
{
Card GamerCard = new Card(0, 0, 0);
GamerCard = (Card)allcard[i];
if (selectface&&GamerCard.Face == PrimaryFace && GamerCard.Suit != PrimarySuit) GamerCard.Face = 4;
if (GamerCard.Face != PrimaryFace && GamerCard.Suit == PrimarySuit) GamerCard.Face = 5;
if (GamerCard.Face == PrimaryFace && GamerCard.Suit == PrimarySuit) GamerCard.Face = 6;
allcard[i] = GamerCard;
}
return allcard;
}
}
}

public class Card
{
int suit;
int face;
int index;
public int Suit
{
get
{
return suit;
}
set
{
suit = value;
}
}
public int Face
{
get
{
return face;
}
set
{
face = value;
}
}
public int Index
{
get
{
return index;
}
set
{
index = value;
}
}
public Card(int Face, int Suit, int Index)
{
face = Face;
suit = Suit;
index = Index;
}
}
class CardComparer : IComparer
{
public int Compare(object info1, object info2)
{
Card Card1 = info1 as Card;
Card Card2 = info2 as Card;
if (Card1.Face != Card2.Face)
{
if (Card1.Face > Card2.Face) return -1;
if (Card1.Face < Card2.Face) return 1;
}
else
{
if (Card1.Suit > Card2.Suit) return -1;
if (Card1.Suit < Card2.Suit) return 1;
}
return 0;
}
}
楼主是否能将你的代码,标上注释,或详细讲解一下,谢谢了,主要是如何把牌写到imagelist里面的,还有怎么显示在panel里面的,对了我还有一个疑问,怎么在你的程序文件夹里怎么找不到那些扑克牌的图片!我现在也想做个这,你的代码有点看不懂,谢谢楼主给标上注释,谢谢了!!

2006-11-24 22:51
Standard
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2006-11-12
得分:0 
比较好

[glow=255,blue,2]:)Don\'t Cry for Spilt Milk!^v^[/glow]
2006-11-25 08:44
小海龟
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1068
专家分:4
注 册:2006-8-1
得分:0 

楼主是否能将你的代码,标上注释,或详细讲解一下,谢谢了,主要是如何把牌写到imagelist里面的,还有怎么显示在panel里面的,对了我还有一个疑问,怎么在你的程序文件夹里怎么找不到那些扑克牌的图片!我现在也想做个这,你的代码有点看不懂,谢谢楼主给标上注释,谢谢了!!

调用的是系统图片。


[bc09] 犯强汉者,虽远比诛!
2006-11-25 08:47
redcar
Rank: 2
等 级:论坛游民
帖 子:210
专家分:60
注 册:2006-9-13
得分:0 

请楼主加上注解吧,多谢了

2006-11-25 09:57
lovemexiaoyu
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2006-5-12
得分:0 
顶!!!请加上注释
2006-11-27 12:26
xiaoye51888
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-12-31
得分:0 
为什么我把那个压缩文件下载到同一个文件夹里,解压的时候总是提示CRC错误,就那个第二卷里的.DB的文件解压不出来,重新下载了几次都这样
2007-12-31 23:25
沉沦过迁
Rank: 2
来 自:广西百色
等 级:论坛游民
帖 子:2297
专家分:10
注 册:2007-5-8
得分:0 
下去看看

也许我没有明天,但是我拥有现在
2008-01-02 08:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-39505-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.494392 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved