• 管理员
    了解作者
  • Java
    开发工具
  • 29KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 744
    下载次数
  • 2001-01-18 16:26
    上传日期
24分扑克牌游戏
arith24-src.zip
  • ScoreKeeper.java
    2KB
  • www.pudn.com.txt
    218B
  • Expression.java
    8.5KB
  • SynchronizedVector.java
    1.3KB
  • Type.java
    123B
  • CardSlot.java
    836B
  • SoundList.java
    1.2KB
  • ObservableInteger.java
    870B
  • Operator.java
    2.5KB
  • Card.java
    2KB
  • Clock.java
    4.4KB
  • PlayingStatus.java
    822B
  • OperatorSlot.java
    860B
  • IllegalExpressionException.java
    1.1KB
  • DraggingArea.java
    23.6KB
  • Solution.java
    8.5KB
  • CardDeck.java
    4.3KB
  • SoundLoader.java
    1001B
  • Arithmetic24.java
    10.6KB
  • DraggingSlot.java
    3.9KB
  • DraggingImage.java
    4.4KB
  • arith24.htm
    9.6KB
内容介绍
/* * @(#)DraggingArea.java Version 1.0 98/03/12 * * Copyright (c) 1998 by Huahai Yang * * Use at your own risk. I do not guarantee the fitness of this * software for any purpose, and I do not accept responsibility for * any damage you do to yourself or others by using this software. * This file may be distributed freely, provided its contents * are not tampered with in any way. * */ import java.awt.*; import java.applet.*; import java.awt.event.*; import java.util.*; import java.lang.Math; /** * Main playing area. Cards and operators are put on it and can be * dragged around. Card deck is also put on it and caculate solutions * in a seperate thread. */ public class DraggingArea extends Panel implements Runnable { Thread dragThread; Applet applet; Dimension offScreenDimension; Image offScreenImage; Graphics offScreenGraphics; Image[] cardImages, operatorImages; Image cardDeckImage; MediaTracker tracker; int imageCount; CardDeck cardDeck; PlayingStatus status; Card [] currentCards; Operator [] operators; DraggingSlot [] draggingSlots; Vector dragImages; DraggingImage theMoving; Point grabPoint; Cursor defaultCursor, handCursor; int updateLeft, updateTop, updateRight, updateBottom; boolean animating; public DraggingArea() { setLayout(null); setForeground(new Color(0)); setBackground(new Color(32768)); handCursor = new Cursor(Cursor.HAND_CURSOR); defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR); addMouseListener(new MyMouseAdapter()); addMouseMotionListener(new MyMouseMotionAdapter()); } // constructor public void start() { applet = (Applet)getParent(); loadAllImages(); status = new PlayingStatus(); status.addObserver((Arithmetic24)applet); status.set(PlayingStatus.WAITING); animating = false; dragImages = new Vector(); theMoving = null; grabPoint = new Point(); // add cardDeck and run a seperate thread to calculate all of // this deck's 13 deal's solutions cardDeck = new CardDeck(30, 10, cardDeckImage, this); dragImages.addElement(cardDeck); // create offscreen context Dimension d = size(); if ( (offScreenGraphics == null) || (d.width != offScreenDimension.width) || (d.height != offScreenDimension.height) ) { offScreenDimension = d; offScreenImage = createImage(d.width, d.height); offScreenGraphics = offScreenImage.getGraphics(); } // if resetClip(); // add slots addSlots(); currentCards = new Card [4]; operators = new Operator [18]; // add operators, each operator has 3 copies // arrange operaters this way: // + * ( // - / ) int count = 0; for(int i = 0; i < 3; i++) { for(int j = 0; j < 6; j++) { dragImages.addElement( operators[count++] = new Operator( j, 510 + j / 2 * 30, 15 + j % 2 * 45, operatorImages[j], this ) ); } // for j } // for i if (dragThread == null) { dragThread = new Thread(this, "Dragging"); dragThread.start(); } // if } // start /** * put operaters back to original positions */ public void arrangeOperators() { for(int i = 0; i < 13; i++) { if(draggingSlots[i] instanceof OperatorSlot) { draggingSlots[i].empty(); } // if } // for for(int i = 0; i < 18; i++) { operators[i]. setLocation(510 + i % 6 / 2 * 30, 15 + i % 6 % 2 * 45); } // for } //arrangeOperators // solts arranged like this: // o c o o c o o o c o o c o // "o" is operator slot, "c" is card slot protected void addSlots() { int widthPointer; DraggingSlot slotPointer = null; draggingSlots = new DraggingSlot [13]; slotPointer = draggingSlots[0] = new OperatorSlot(10, 160); widthPointer = slotPointer.getLocation().x + OperatorSlot.WIDTH; slotPointer = draggingSlots[1] = new CardSlot(widthPointer + 6, 130); widthPointer = slotPointer.getLocation().x + CardSlot.WIDTH; slotPointer = draggingSlots[2] = new OperatorSlot(widthPointer + 6, 160); widthPointer = slotPointer.getLocation().x + OperatorSlot.WIDTH; slotPointer = draggingSlots[3] = new OperatorSlot(widthPointer + 6, 160); widthPointer = slotPointer.getLocation().x + OperatorSlot.WIDTH; slotPointer = draggingSlots[4] = new CardSlot(widthPointer + 6, 130); widthPointer = slotPointer.getLocation().x + CardSlot.WIDTH; slotPointer = draggingSlots[5] = new OperatorSlot(widthPointer + 6, 160); widthPointer = slotPointer.getLocation().x + OperatorSlot.WIDTH; slotPointer = draggingSlots[6] = new OperatorSlot(widthPointer + 6, 160); widthPointer = slotPointer.getLocation().x + OperatorSlot.WIDTH; slotPointer = draggingSlots[7] = new OperatorSlot(widthPointer + 6, 160); widthPointer = slotPointer.getLocation().x + OperatorSlot.WIDTH; slotPointer = draggingSlots[8] = new CardSlot(widthPointer + 6, 130); widthPointer = slotPointer.getLocation().x + CardSlot.WIDTH; slotPointer = draggingSlots[9] = new OperatorSlot(widthPointer + 6, 160); widthPointer = slotPointer.getLocation().x + OperatorSlot.WIDTH; slotPointer = draggingSlots[10] = new OperatorSlot(widthPointer + 6, 160); widthPointer = slotPointer.getLocation().x + OperatorSlot.WIDTH; slotPointer = draggingSlots[11] = new CardSlot(widthPointer + 6, 130); widthPointer = slotPointer.getLocation().x + CardSlot.WIDTH; slotPointer = draggingSlots[12] = new OperatorSlot(widthPointer + 6, 160); widthPointer = slotPointer.getLocation().x + OperatorSlot.WIDTH; } // addSlots /** * stop the running of dragging area */ public void stop() { animating = false; cardDeck.stop(); dragImages.removeAllElements(); if (dragThread != null) { dragThread.stop(); dragThread = null; } //if } // stop public void run() { Thread myThread = Thread.currentThread(); while (dragThread == myThread) { if( animating ) { presentSolution(); } // if else { try { clipRepaint(); Thread.sleep(200L); } // try catch(InterruptedException e) { } // catch } // else } // while } // run public Dimension getPreferredSize() { return getMinimumSize(); } // getPreferredSize public Dimension getMinimumSize() { return new Dimension(640, 250); } // getMinimumSize public Vector userCreatedExpression() { Vector expression = new Vector(); DraggingImage image = null; for(int i = 0; i < 13; i ++) { image = draggingSlots[i].getHoldenImage(); if(image != null) { if(image instanceof Card) expression.addElement(((Card)image).getValue()); else expression.addElement(((Operator)image).getValue()); } // if else { expression.addElement(new Character(' ')); } //
评论
    相关推荐
    • Java扑克游戏网络对战版
      扑克游戏,实现网络对战!程序分二部分,网络端和客户端。
    • Java编写的扑克游戏
      Java写的扑克牌小游戏,真实美国课堂作业,有兴趣的可以大家一起讨论讨论!
    • Java纸牌扑克游戏
      内容索引:JAVA源码,游戏娱乐,扑克牌,Java游戏源码 Java编写的蜘蛛扑克牌游戏,写于2005年,程序要用到swing组件,因此请确保你的JDK环境安有此组件。新手可以学习的一个参考。
    • java实现扑克游戏
      java实现扑克游戏,思路及其清晰,十分适合初学者学习与应用。
    • java 扑克.rar
      这是基于J2ME平台的扑克游戏。下载解压后直接编译运行。
    • java 扑克游戏
      这是个java写的扑克游戏,网上下载修改的,亲测可运行。
    • Java扑克游戏网络对战版
      内容索引:JAVA源码,游戏娱乐,扑克,手机游戏,j2me游戏 扑克游戏,实现网络对战!程序分二部分,网络端和客户端。
    • 扑克游戏
      java做的扑克游戏.
    • java游戏编程导学
      java游戏开发的好指导,希望能给大家帮助。java游戏开发的好指导,希望能给大家帮助。
    • java扑克游戏 源码
      java扑克游戏 源码