⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gamecanvas.java

📁 这是一款益智类经典游戏
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                        break;
                    case 3://菜单弹出后
                        if (keyPre && key_GameCode==Canvas.UP){
                            m_status--;
                            if (m_status<0){
                                m_status=3;
                            }
                        } else if (keyPre && key_GameCode==Canvas.DOWN){
                            m_status++;
                            if (m_status>3){
                                m_status=0;
                            }
                        }else if(keyPre && key_GameCode==Canvas.FIRE){
                            switch(m_status){
                                case 0:
                                    g_status=4;
                                    break;
                                case 1:
                                    g_status=6;
                                    p_status=0;
                                    break;
                                case 2:
                                    sta=2;
                                    g_sta=3;
                                    status=5;
                                    g_status=-1;
                                    break;
                                case 3:
                                    bgImg=null;
                                    grids=null;
                                    gridSelImg=null;
                                    numberImg=null;
                                    pupMenuImg=null;
                                    pupSelImg=null;
                                    status=1;
                                    g_status=0;
                                    break;
                            }
                        } else if(keyPre && key_Code==-6){
                            g_status=4;
                        }
                        break;
                    case 4://卸去弹出菜单
                        i_status-=5;
                        if (i_status<=-45){
                            pupMenuImg=null;
                            pupSelImg=null;
                            g_status=1;
                            
                        }
                        break;
                    case 5://GameOver
                        switch(p_status){
                            case 0:
                                highScoreRms=new HighScoreRms();
                                try{
                                    gameOverImg=Image.createImage("/res/gameover.png");
                                }catch(Exception e){}
                                p_status=1;
                                break;
                            case 1:
                                if(keyPre){
                                    p_status=2;
                                    gameOverImg=null;
                                }
                                break;
                            case 2:
                                if (totalCursor>highScoreRms.getMaxPoint()){
                                    highScoreRms.isInputing=true;
                                    PlumberMidlet.mainMidlet.disp.setCurrent(highScoreRms.frm);
                                }
                                p_status=3;
                                break;
                            case 3:
                                if (!highScoreRms.isInputing){
                                    highScoreRms=null;
                                    status=1;
                                    g_status=0;
                                }
                                break;
                        }
                        break;
                    case 6://弹出二级(存档菜单)
                        switch(p_status){
                            case 0://装载存档菜单
                                try{
                                    pupMenu2Img=Image.createImage("/res/dossier.png");
                                }catch(Exception e){}
                                j_status=-45;
                                p_status=1;
                                break;
                            case 1:
                                j_status+=5;
                                if (j_status>=5){
                                    j_status=5;
                                    n_status=0;
                                    p_status=2;
                                }
                                break;
                            case 2:
                                if (keyPre && key_GameCode==Canvas.UP){
                                    n_status--;
                                    if (n_status<0){
                                        n_status=3;
                                    }
                                } else if (keyPre && key_GameCode==Canvas.DOWN){
                                    n_status++;
                                    if (n_status>3){
                                        n_status=0;
                                    }
                                }else if(keyPre && key_GameCode==Canvas.FIRE){
                                    DossierRms.writeDossier(n_status+1);
                                    p_status=3;
                                } else if(keyPre && key_Code==-6){
                                    p_status=3;
                                }
                                break;
                            case 3:
                                j_status-=5;
                                if (j_status<=-45){
                                    pupMenu2Img=null;
                                    g_status=3;
                                }
                                break;
                        }
                        break;
                }
                break;
            case 3://记录排行
                switch(g_status){
                    case 0:
                        try{
                            highScoreImg=Image.createImage("/res/highscore.png");
                        }catch(Exception e){}
                        if(highScoreRms==null){
                            highScoreRms=new HighScoreRms();
                        }
                        playerListNum=highScoreRms.setHighScoreList();
                        g_status=1;
                        break;
                    case 1:
                        if (keyPre){
                            highScoreImg=null;
                            highScoreRms=null;
                            status=1;
                            g_status=0;
                        }
                        break;
                }
                break;
            case 4:// 装载游戏存档
                switch(g_status){
                    case 0:
                        try{
                            saveBgImg=Image.createImage("/res/save.png");
                            saveSelImg=Image.createImage("/res/pupSel.png");
                        }catch(Exception e){}
                        DossierRms.setDossierIdList();
                        if (DossierRms.dossierIdList!=null){
                            saveImg=new Image[DossierRms.dossierIdList.length];
                            for (int i=0;i<DossierRms.dossierIdList.length;i++){
                                try{
                                    saveImg[i]=Image.createImage("/res/save"+String.valueOf(DossierRms.dossierIdList[i])+".png");
                                }catch(Exception e){
                                    //System.out.println("sfsdfdsfsfsfsssssssssssssss");
                                }
                            }
                        }
                        m_status=0;
                        g_status=1;
                        break;
                    case 1:
                        if(DossierRms.dossierIdList!=null){
                            if (keyPre && key_GameCode==Canvas.UP){
                                m_status--;
                                if (m_status<0){
                                    m_status=DossierRms.dossierIdList.length-1;
                                }
                            } else if (keyPre && key_GameCode==Canvas.DOWN){
                                m_status++;
                                if (m_status>DossierRms.dossierIdList.length-1){
                                    m_status=0;
                                }
                            }else if(keyPre && key_GameCode==Canvas.FIRE){
                                g_status=2;
                            }
                        }
                        if(keyPre && key_Code==-7){
                            saveBgImg=null;
                            saveSelImg=null;
                            saveImg=null;
                            status=1;
                            g_status=0;
                        }
                        break;
                    case 2:
                        grids=new Grids();
                        loadGame();
                        int dossierId=DossierRms.dossierIdList[m_status];
                        DossierRms.readDossier(dossierId);
                        DossierRms.transDataOut();
                        grids.changeColor();
                        grids.passWaitTime=0;
                        System.gc();
                        status=2;
                        g_status=1;
                        break;
                }
                break;
            case 5://帮助
                fontHeight=font.getHeight();
                switch(g_status){
                    case 0:
                        howplayString="你在游戏中扮演一个辛苦的管道维修工,需要保持所有的下水管道畅通。注意左侧的时间条,在限定的时间内一定要维修好其中的一条管道。如果没有完成,就会被环卫公司解雇……使用方向键选择管道,然后使用OK键调整它的方向。当完成水管的上下连通后,限定时间会重新计算。当你的分数上升到一个阶段后,你需要用更快的时间完成管道的畅通。GOOD LUCK!";
                        char[] data = new char[howplayString.length()];
                        howplayString.getChars(0, howplayString.length(), data, 0);
                        int lineWidth = 0;
                        int charWidth = 0;
                        char ch;
                        for(int ccnt=0; ccnt < data.length; ccnt++) {
                            ch = data[ccnt];
                            //测量要绘制的字符
                            charWidth = font.charWidth(ch);
                            lineWidth = lineWidth + charWidth;
                            //看是否需要新的行
                            if (lineWidth > screenWidth) {
                                linesHeight = linesHeight + fontHeight;
                                lineWidth = 0;
                            }
                        }
                        g_status=1;
                        p_status=0;
                        break;
                    case 1:
                        if (keyPre && key_GameCode==Canvas.UP){
                            if (p_status<0){
                                p_status+=fontHeight;
                            }
                            
                        } else if (keyPre && key_GameCode==Canvas.DOWN){
                            if (p_status+linesHeight>=screenHeight){
                                p_status-=fontHeight;
                            }
                        } else if (keyPre && key_Code==-7){
                            howplayString=null;
                            font=null;
                            status=sta;
                            g_status=g_sta;
                        }
                        break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -