云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 基于java开发的蜘蛛纸牌程序设计(含源文件)

基于java开发的蜘蛛纸牌程序设计(含源文件)

  • 62 次阅读
  • 3 次下载
  • 2025/6/3 12:57:00

this.pane.setComponentZOrder(cards[c + i], 1);

Point point = new Point(lastPoint);

if (cards[c + i].getCardValue() == 1){

int n = cards[c + i].whichColumnAvailable(point); point.y -= 240;

PKCard card = (PKCard) this.table.get(point); if (card != null && card.isCardCanMove()){

this.haveFinish(n);\\\\判断纸牌是否可以回收以及回收的总次数

} }

x += 101; }

c += 10; }

4.3.4纸牌的移动以及放置

代码实现如下: 用鼠标拖动纸牌

public void mouseDragged(MouseEvent arg0){ if (canMove){

21

int x = 0; int y = 0;

Point p = arg0.getPoint(); x = p.x - point.x; y = p.y - point.y; this.moving(x, y); } }

方法:放置纸牌

public void setNextCardLocation(Point point){ PKCard card = main.getNextCard(this); if (card != null){

if (point == null){

card.setNextCardLocation(null);

main.table.remove(card.getLocation()); card.setLocation(card.initPoint); main.table.put(card.initPoint, card); } else{

point = new Point(point); point.y += 20;

card.setNextCardLocation(point); point.y -= 20;

main.table.remove(card.getLocation()); card.setLocation(point);

main.table.put(card.getLocation(), card); card.initPoint = card.getLocation(); } } }

4.3.5显示当前纸牌可行的操作: 代码实现如下: 返回值:void

方法:显示可移动的操作

public void showEnableOperator(){ int x = 0;

out: while (true){

Point point = null; PKCard card = null; do{

if (point != null){ n++;

22

}

point = this.getLastCardLocation(n); while (point == null){

point = this.getLastCardLocation(++n); if (n == 10) n = 0; x++;

if (x == 10) break out; }

card = (PKCard) this.table.get(point); }

while (!card.isCardCanMove());

while (this.getPreviousCard(card) != null

&& this.getPreviousCard(card).isCardCanMove()){ card = this.getPreviousCard(card); }

if (a == 10){ a = 0; }

for (; a < 10; a++){ if (a != n){

Point p = null; PKCard c = null; do{

if (p != null){ a++; }

p = this.getLastCardLocation(a); int z = 0;

while (p == null){

p = this.getLastCardLocation(++a); if (a == 10) a = 0; if (a == n) a++; z++;

if (z == 10) break out; }

c = (PKCard) this.table.get(p); }

while (!c.isCardCanMove());

if (c.getCardValue() == card.getCardValue() + 1){ card.flashCard(card); try{

Thread.sleep(800); }

catch (InterruptedException e){

23

e.printStackTrace(); }

c.flashCard(c); a++;

if (a == 10){ n++; }

break out; } } } n++;

if (n == 10){ n = 0; }

x++;

if (x == 10){ break out; } } }

4.3.6回收纸牌:

代码实现如下: 返回值:void

方法:判断纸牌的摆放是否完成

public void haveFinish(int column){

Point point = this.getLastCardLocation(column); PKCard card = (PKCard) this.table.get(point); do{

this.table.remove(point);

card.moveto(new Point(20 + finish * 10, 580)); //将组件移动到容器中指定的顺序索引。 pane.setComponentZOrder(card, 1); //将纸牌新的相关信息存入Hashtable

this.table.put(card.getLocation(), card);

24

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

this.pane.setComponentZOrder(cards[c + i], 1); Point point = new Point(lastPoint); if (cards[c + i].getCardValue() == 1){ int n = cards[c + i].whichColumnAvailable(point); point.y -= 240; PKCard card = (PKCard) this.table.get(point); if (card != null && card.isCardCanMove()

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com