坦克大战—day 44

游戏过关效果

 //开始过关动画
    public static int flashTime;
    public static final int RECT_WIDTH = 40;
    public static final int RECT_COUNT = FRAME_WIDTH/RECT_WIDTH+1;
    public static boolean isOpen = false;
  public static void startCrossLevel(){
        gameState = STATE_CROSS;
        flashTime = 0;
        isOpen = false;
    }

//绘制过关动画


    public void drawCross(Graphics g){
        gameMap.drawBk(g);
        myTank.draw(g);
        gameMap.drawCover(g);

        g.setColor(Color.BLACK);
        //关闭百叶窗的效果
        if (!isOpen){
            for(int i = 0; i < RECT_COUNT;i++){
                g.fillRect(i * RECT_WIDTH,0,flashTime,FRAME_HEIGHT);
            }
            //所有的叶片都关闭了
            if (flashTime++ - RECT_WIDTH > 5){
                isOpen = true;
                //初始化下一个地图
                gameMap.initMap(LevelInof.getInstance().getLevel()+1);
            }
        }else{
            //开百叶窗的效果
            for(int i = 0;i < RECT_WIDTH;i ++){
                g.fillRect(i * RECT_WIDTH,0,flashTime,FRAME_HEIGHT);
            }
            if(flashTime-- ==0){
                newGame(LevelInof.getInstance().getLevel());
            }
        }
    }

 

上一篇:Delphi 2010 TButtonGroup控件的使用,按钮集合


下一篇:vue中检测元素是否滚动到可视范围