<commit_before>package game;

import org.newdawn.slick.*;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.BlobbyTransition;
import org.newdawn.slick.state.transition.CombinedTransition;

/**
 * Created with IntelliJ IDEA.
 * User: user360
 * Date: 30/01/14
 * Time: 4:20 PM
 * To change this template use File | Settings | File Templates.
 */
public class HighScoreState extends BasicGameState {
    boolean anyKeyPressed = false;
    String highScore = null;
    private Image skyimage;
    private StateBasedGame mainGame;



    @Override
    public int getID() {
        return Game.STATE.HISCORE;
    }

    @Override
    public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException
    {
        mainGame = stateBasedGame;
        skyimage = new Image("data/image/sky.png");
    }

    @Override
    public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException
    {
        mainGame.getState(Game.STATE.MAIN).render(gameContainer,stateBasedGame,graphics);
        //skyimage.draw();
        graphics.drawString("HIGH SCORES",
                MainGame.SCREEN_WIDTH / 2.0f - 100,
                MainGame.SCREEN_HEIGHT / 4f);


        graphics.drawString(
                highScore,
                MainGame.SCREEN_WIDTH / 2.0f - 100,
                MainGame.SCREEN_HEIGHT / 3.5f + 80.0f);


        graphics.drawString(
                "Press any key...",
                MainGame.SCREEN_WIDTH / 2.0f - 100,
                MainGame.SCREEN_HEIGHT / 1.1f);
    }

    // Called when we enter this game state, a good place to variables to initial values if needed
    public void enter(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException
    {
        anyKeyPressed = false;
        setHighScore(MainGame.SBoard.displayScore());
    }

    // Event called on key down, we just flag that a key was pressed, and let the update handle it from there
    public void keyPressed(int key, char c)
    {
        anyKeyPressed = true;
    }


    public void setHighScore(String highScores)
    {
        highScore = highScores;
    }

    @Override
    public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i) throws SlickException
    {
        if (anyKeyPressed)
        {
            stateBasedGame.enterState(Game.STATE.MENU, new CombinedTransition(), new BlobbyTransition());<commit_msg>Further improved hiscore screen<commit_after>package game;

import org.newdawn.slick.*;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.BlobbyTransition;
import org.newdawn.slick.state.transition.CombinedTransition;
import util.GameFont;

/**
 * Created with IntelliJ IDEA.
 * User: user360
 * Date: 30/01/14
 * Time: 4:20 PM
 * To change this template use File | Settings | File Templates.
 */
public class HighScoreState extends BasicGameState {
    boolean anyKeyPressed = false;
    String highScore = null;
    private GameFont fieldfont = null;
    private GameFont scorefont = null;
    private StateBasedGame mainGame;



    @Override
    public int getID() {
        return Game.STATE.HISCORE;
    }

    @Override
    public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException
    {
        mainGame = stateBasedGame;
        fieldfont = new GameFont("data/fonts/AbadiMTCondensed.fnt", "data/fonts/AbadiMTCondensed.png");
        scorefont = new GameFont("data/fonts/Corbel16.fnt", "data/fonts/Corbel16.png");

    }

    @Override
    public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException
    {
        mainGame.getState(Game.STATE.MAIN).render(gameContainer,stateBasedGame,graphics);

        fieldfont.drawString(
                MainGame.SCREEN_WIDTH / 2.0f,
                MainGame.SCREEN_HEIGHT / 4f,
                "HIGH SCORES",
                GameFont.Alignment.CENTRE,
                Color.white);


        scorefont.drawString(
                MainGame.SCREEN_WIDTH / 2.0f,
                MainGame.SCREEN_HEIGHT / 3.5f + 80.0f,
                highScore,
                GameFont.Alignment.CENTRE,
                Color.white
                );


       fieldfont.drawString(
                MainGame.SCREEN_WIDTH / 2.0f,
                MainGame.SCREEN_HEIGHT / 1.1f,
                "Press any key...",
                GameFont.Alignment.CENTRE,
                Color.white
                );
    }

    // Called when we enter this game state, a good place to variables to initial values if needed
    public void enter(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException
    {
        anyKeyPressed = false;
        setHighScore(MainGame.SBoard.displayScore());
    }

    // Event called on key down, we just flag that a key was pressed, and let the update handle it from there
    public void keyPressed(int key, char c)
    {
        anyKeyPressed = true;
    }


    public void setHighScore(String highScores)
    {
        highScore = highScores;
    }

    @Override
    public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i) throws SlickException
    {
        if (anyKeyPressed)
        {
            stateBasedGame.enterState(Game.STATE.MENU, new CombinedTransition(), new BlobbyTransition());
{'fraction_non_alphanumeric': 0.08146270818247647, 'fraction_numerical': 0.011766835626357712, 'mean_word_length': 2.5168682367918525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '333858', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1555, 'n_words': 391}