<commit_before>package com.draga.manager.screen;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.*;
import com.badlogic.gdx.utils.Pools;
import com.badlogic.gdx.utils.viewport.ExtendViewport;
import com.draga.Constants;
import com.draga.Hud;
import com.draga.MaskBits;
import com.draga.entity.GameEntity;
import com.draga.entity.Planet;
import com.draga.entity.Ship;
import com.draga.entity.Star;
import com.draga.event.StarCollectedEvent;
import com.draga.manager.AssMan;
import com.draga.manager.GameContactListener;
import com.draga.manager.GameEntityManager;
import com.draga.manager.ScreenManager;
import com.google.common.eventbus.Subscribe;

import java.util.ArrayList;

public class GameScreen implements Screen
{
    private static final String LOGGING_TAG = GameScreen.class.getSimpleName();
    private Hud                hud;
    private Texture            backgroundTexture;
    private Box2DDebugRenderer box2DDebugRenderer;
    private World              box2dWorld;
    private SpriteBatch        spriteBatch;
    private OrthographicCamera orthographicCamera;
    private ExtendViewport     extendViewport;
    private Ship               ship;
    private int                width;
    private int                height;
    private ArrayList<Planet>  planets;
    private Planet             destinationPlanet;
    private boolean doUpdate       = true;
    private int     totalStars     = 0;
    private int     starsCollected = 0;

    public GameScreen(String backgroundTexturePath, SpriteBatch spriteBatch, int width, int height)
    {
        Constants.EVENT_BUS.register(this);
        box2dWorld = new World(Pools.obtain(Vector2.class), true);
        box2dWorld.setContactListener(new GameContactListener());
        planets = new ArrayList<>();
        this.backgroundTexture = AssMan.getAssetManager().get(backgroundTexturePath, Texture.class);
        this.width = width;
        this.height = height;
        this.spriteBatch = spriteBatch;
        orthographicCamera = new OrthographicCamera();
        extendViewport = new ExtendViewport(
            Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT, width, height, orthographicCamera);
        extendViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

        if (Constants.IS_DEBUGGING)
        {
            createWalls();
            box2DDebugRenderer = new Box2DDebugRenderer();
        }

        hud = new Hud();
    }

    public Planet getDestinationPlanet()
    {
        return destinationPlanet;
    }

    public void setDestinationPlanet(Planet destinationPlanet)
    {
        this.destinationPlanet = destinationPlanet;
    }

    public World getBox2dWorld()
    {
        return box2dWorld;
    }

    private void createWalls()
    {
        BodyDef bodyDef = new BodyDef();
        bodyDef.type = BodyDef.BodyType.StaticBody;

        Body body = box2dWorld.createBody(bodyDef);

        Vector2[] wallVertices = new Vector2[] {
            new Vector2(0, 0),
            new Vector2(width, 0),
            new Vector2(width, height),
            new Vector2(0, height),
            new Vector2(0, 0),};
        ChainShape chainShape = new ChainShape();
        chainShape.createChain(wallVertices);

        FixtureDef fixtureDef = new FixtureDef();
        fixtureDef.shape = chainShape;
        fixtureDef.restitution = 0;
        fixtureDef.filter.categoryBits = MaskBits.BOUNDARIES;
        fixtureDef.filter.maskBits = MaskBits.SHIP;

        body.createFixture(fixtureDef);

    }

    public void addShip(Ship ship)
    {
        this.ship = ship;
        addGameEntity(ship);
    }

    public void addPlanet(Planet planet)
    {
        this.planets.add(planet);
        addGameEntity(planet);
    }

    public void addStar(Star star)
    {
        totalStars++;
        addGameEntity(star);
        hud.addStar();
    }

    private void addGameEntity(GameEntity gameEntity)
    {
        GameEntityManager.addGameEntity(gameEntity);
        gameEntity.createBody(getBox2dWorld());
    }

    public void update(float elapsed)
    {
        while (!GameEntityManager.getGameEntitiesToCreate().isEmpty())
        {<commit_msg>Start game camera at ship<commit_after>package com.draga.manager.screen;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.*;
import com.badlogic.gdx.utils.Pools;
import com.badlogic.gdx.utils.viewport.ExtendViewport;
import com.draga.Constants;
import com.draga.Hud;
import com.draga.MaskBits;
import com.draga.entity.GameEntity;
import com.draga.entity.Planet;
import com.draga.entity.Ship;
import com.draga.entity.Star;
import com.draga.event.StarCollectedEvent;
import com.draga.manager.AssMan;
import com.draga.manager.GameContactListener;
import com.draga.manager.GameEntityManager;
import com.draga.manager.ScreenManager;
import com.google.common.eventbus.Subscribe;

import java.util.ArrayList;

public class GameScreen implements Screen
{
    private static final String LOGGING_TAG = GameScreen.class.getSimpleName();
    private Hud                hud;
    private Texture            backgroundTexture;
    private Box2DDebugRenderer box2DDebugRenderer;
    private World              box2dWorld;
    private SpriteBatch        spriteBatch;
    private OrthographicCamera orthographicCamera;
    private ExtendViewport     extendViewport;
    private Ship               ship;
    private int                width;
    private int                height;
    private ArrayList<Planet>  planets;
    private Planet             destinationPlanet;
    private boolean doUpdate       = true;
    private int     totalStars     = 0;
    private int     starsCollected = 0;

    public GameScreen(String backgroundTexturePath, SpriteBatch spriteBatch, int width, int height)
    {
        Constants.EVENT_BUS.register(this);
        box2dWorld = new World(Pools.obtain(Vector2.class), true);
        box2dWorld.setContactListener(new GameContactListener());
        planets = new ArrayList<>();
        this.backgroundTexture = AssMan.getAssetManager().get(backgroundTexturePath, Texture.class);
        this.width = width;
        this.height = height;
        this.spriteBatch = spriteBatch;
        orthographicCamera = new OrthographicCamera();
        extendViewport = new ExtendViewport(
            Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT, width, height, orthographicCamera);
        extendViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

        if (Constants.IS_DEBUGGING)
        {
            createWalls();
            box2DDebugRenderer = new Box2DDebugRenderer();
        }

        hud = new Hud();
    }

    public Planet getDestinationPlanet()
    {
        return destinationPlanet;
    }

    public void setDestinationPlanet(Planet destinationPlanet)
    {
        this.destinationPlanet = destinationPlanet;
    }

    public World getBox2dWorld()
    {
        return box2dWorld;
    }

    private void createWalls()
    {
        BodyDef bodyDef = new BodyDef();
        bodyDef.type = BodyDef.BodyType.StaticBody;

        Body body = box2dWorld.createBody(bodyDef);

        Vector2[] wallVertices = new Vector2[] {
            new Vector2(0, 0),
            new Vector2(width, 0),
            new Vector2(width, height),
            new Vector2(0, height),
            new Vector2(0, 0),};
        ChainShape chainShape = new ChainShape();
        chainShape.createChain(wallVertices);

        FixtureDef fixtureDef = new FixtureDef();
        fixtureDef.shape = chainShape;
        fixtureDef.restitution = 0;
        fixtureDef.filter.categoryBits = MaskBits.BOUNDARIES;
        fixtureDef.filter.maskBits = MaskBits.SHIP;

        body.createFixture(fixtureDef);

    }

    public void addShip(Ship ship)
    {
        this.ship = ship;
        addGameEntity(ship);

        orthographicCamera.position.x = ship.getX();
        orthographicCamera.position.y = ship.getY();
    }

    public void addPlanet(Planet planet)
    {
        this.planets.add(planet);
        addGameEntity(planet);
    }

    public void addStar(Star star)
    {
        totalStars++;
        addGameEntity(star);
        hud.addStar();
    }

    private void addGameEntity(GameEntity gameEntity)
    {
        GameEntityManager.addGameEntity(gameEntity);
        gameEntity.createBody(getBox2dWorld());
    }

    public void update(float elapsed)
    {
        while (!GameEntityManager.getGameEntitiesToCreate().isEmpty())
        {
{'fraction_non_alphanumeric': 0.08927190365705447, 'fraction_numerical': 0.006850071815269031, 'mean_word_length': 2.759136212624585, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2006258', 'n_tokens_mistral': 2678, 'n_tokens_neox': 2618, 'n_words': 524}