1.斗地主的一个界面:
2.一张Card的重要属性
坐标位置相关:
int x;-------------------x坐标
int y;-------------------y坐标
int width;-------------------宽
int height;-------------------高
boolean clicked;-------------------是否选中
界面图案相关:
Bitmap bitmap;-------------------图片
boolean rear;-------------------是否是背面
牌的名字:
String name; -------------------Card的名称,这其中包含了牌的花色和牌值
牌的花色和牌值这个一个值的探讨的问题:
牌的花色:
diamond-------方块=1
club-------------梅花=2
heart------------红色=3
spade----------黑色=4
jester------------大小王=5
牌值:
牌值 牌 3 4 5 6 7 8 9 1 0 J Q K A 2 小 王 大 王 牌 值 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7
表示牌有二种方式:
(1)一般表示
a1_3 a1_4 -------------------- a1_12 a1_13 a1_14 a1_15 (梅花3 梅花4 -------------------- 梅花Q 梅花K 梅花A 梅花2 )
a2_3 a2_4 -------------------- a2_12 a2_13 a2_14 a2_15 (方块3 方块4 -------------------- 方块Q 方块K 方块A 方块2 )
a3_3 a3_4 -------------------- a3_12 a3_13 a3_14 a3_15 (红色3 红色4 -------------------- 红色Q 红色K 红色A 红色2 )
a4_3 a4_4 -------------------- a4_12 a4_13 a4_14 a4_15 (黑色3 黑色4 -------------------- 黑色Q 黑色K 黑色A 黑色2 )
a5_16 a5_17--------------------(小王,大王)
(2)第二种表示:
牌的花色为:value/16,牌的大小值:value%16
17,18,19,----------------,26,27,28,29 (梅花3 梅花4 -------------------- 梅花Q 梅花K 梅花A 梅花2 )
33,34,35,---------------,42,43,44,45 (方块3 方块4 -------------------- 方块Q 方块K 方块A 方块2 )
49,50,51,---------------,58,59,60,61 (红色3 红色4 -------------------- 红色Q 红色K 红色A 红色2 )
65,66,67,---------------,74,75,76,77 (黑色3 黑色4 -------------------- 黑色Q 黑色K 黑色A 黑色2 )
81,82-------------------------(小王,大王)
3.这是一个参考的Card类:
public class Card {
int x; //横坐标
int y; //纵坐标
int width; //宽度
int height; //高度
Bitmap bitmap;//图片
String name; //Card的名称
boolean rear;//是否是背面
boolean clicked;//是否被点击
public Card(int width,int height,Bitmap bitmap){
this.x = 0;
this.y = 0;
this.width=width;
this.height=height;
this.bitmap=bitmap;
this.rear = true;
this.clicked = false;
}
public void setLocation(int x,int y){
this.x=x;
this.y=y;
}
public void setName(String name){
this.name=name;
}
public Rect getSRC(){
return new Rect(0,0,width,height);
}
public Rect getDST(){
return new Rect(x, y,x+width, y+height);
}
}
4.参考资料:
1.斗地主算法的设计与实现(一)--项目介绍&如何定义和构造一张牌
http://blog.youkuaiyun.com/fansunion/article/details/12516411