显示我在java中创建的高分页面继续从Highscores文件中打印随机字符串

时间:2015-11-14 22:51:47

标签: java

我正在尝试完成一个我和我的朋友用java编写的游戏,我在高分页面上遇到了很多麻烦。每当我尝试将字符串绘制到Jframe时,它只是重复从文件中绘制一个不同的字符串,我无法弄明白。

以下是游戏高分的代码。

        if(map == 12){
            g.setColor(Color.white);
            g.fillRect(0, 0, w, h);
            g.drawImage(menu[3], 0, 0, 750, 500, null);
        highscore="";
        for(int i=0; i<=1; i++){
                try{
                    if(highscore==""){
                        Scanner q = new Scanner(new File("files/bin/res/highscore.txt"));
                        int random = new Random().nextInt(highscores.size());
                        highscore = highscores.get(random);
                        g.setColor(Color.black);
                        g.drawString(highscore, 36, hsArray[i]);
                    }
                } catch(FileNotFoundException e){
                    e.printStackTrace();
                }
        }
            tick3++;
        if(hsArrayCounter >= 0 && hsArrayCounter <= 11){
            hsArrayCounter++;
        }
            if(tick3 == 1000){
                menuOptions("menu", "Ok, Back to the menu", "play", "Ok, Game loading", "Would you like to go to the menu or start playing?", 11, 0);
            }
    }

0 个答案:

没有答案