java   台球代码

     private final int FPS = 15;                //游戏帧率
    private byte nBalls = 16;                //所有球个数   
    private Ball[] balls;                    //台球数组
    private BallPlayer[] players = new BallPlayer[2];
    private byte PLAYER_STATE;                //0为玩家一,1为玩家二  谁是先手
    private boolean isIntoHole;                //玩家是否进球
    private byte intoID;                    //进球的ID值
    private Image imgBall[];                //桌球图片数组
    private final short maxLine = 228;        //白色球不能超过的临界值
    private final double ball_r = 5.555555D;//球的半径 图片高的一半
    private final double rate = 0.97777777D;//速度衰减比率
    private final double minRate = 0.5D;     //速度衰减比率
    private double angle = 90;                //球杆初始角度
    private double power;                    //力度 最大值为10
    private int sL = 120;                    //球杆的长度
    private boolean allStop = true;            //所有球是否停止
    private double[] nextX;                    //球下一点横坐标
    private double[] nextY;                    //球下一点纵坐标
    private double[] lastX;                    //球最后一次横坐标
    private double[] lastY;                    //球最后一次纵坐标
    private final byte SETBALL     = 1;        //设置球
    private final byte SETHITANGLE = 2;        //设置碰撞角度
    private final byte SETHTIPOINT = 3;        //设置碰撞的点(位置)
    private final byte WAITTOHIT   = 4;        //等待击球,正在发力
    public static final byte BALLSMOVE   = 5;        //移动球
    public static byte STATE;                        //当前进行状态
    int[] holesX = {85,220,80,225,85,220};    //每个洞的横坐标
    int[] holesY = {20,20,157,157,293,293};    //每个洞的纵坐标
    int[] tableX = {84,216};                //桌子对角线X坐标
    int[] tableY = {19,292};                //桌子对角线Y坐标

posted @ 2010-12-09 18:08  刘竹青  阅读(368)  评论(0编辑  收藏  举报