<commit_before>package com.github.dreamsnatcher;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.physics.box2d.*;
import com.github.dreamsnatcher.entities.*;
import com.github.dreamsnatcher.screens.ScreenManager;
import com.github.dreamsnatcher.utils.AudioManager;
import com.github.dreamsnatcher.utils.CameraHelper;
import com.github.dreamsnatcher.utils.CollisionObjectHelper;


public class WorldController extends InputAdapter implements ContactListener {
    public static final int MAX_ACCELERATION = 30;
    private static final float MAX_V = 3;
    public static final float DRAIN_ENERGY_STEP = 0.1f;

    public CameraHelper cameraHelper;
    private boolean zoomIn;
    private boolean finish;
    public boolean finalAnimationFinished;
    public boolean switchToMainMenu;

    public void setWorldRenderer(WorldRenderer worldRenderer) {
        this.worldRenderer = worldRenderer;
    }

    public WorldRenderer worldRenderer;
    public long timeElapsed;
    private World b2World;
    public GameWorld gameWorld;
    private boolean debug = false;
    private Vector2 curTouchPos;
    private String map = "map1.map";

    public WorldController(String level) {
        this.map = level;
        init();
    }

    public void init() {
        ScreenManager.multiplexer.addProcessor(this);
        cameraHelper = new CameraHelper();
        b2World = new World(new Vector2(0, 0f), true);
        b2World.setContactListener(this);
        // You can open this file and edit it via
        // Editor in the desktop project. You can of course
        // also create new files.
        gameWorld = GameWorldSerializer.deserialize(Gdx.files.internal(map));
        gameWorld.init(b2World);
        cameraHelper.setTarget(gameWorld.spaceShip.getBody());
    }

    public void update(float deltaTime) {
        if(!finish) {
            timeElapsed += deltaTime * 1000;
        }
        cameraHelper.update(deltaTime);
        gameWorld.spaceShip.update(deltaTime);
        for (GameObject object : gameWorld.objects) {
            object.update(deltaTime);
        }
        b2World.step(1 / 60f, 3, 8); //timeStep, velocityIteration, positionIteration
        if (Gdx.input.isTouched() && gameWorld.spaceShip.getEnergy() > 0 && !finish) {
            accelerate(curTouchPos.x, curTouchPos.y);
        }
        if (zoomIn) {
            cameraHelper.setZoom(cameraHelper.getZoom() - 0.002f);
        }
        if(gameWorld.spaceShip.getEnergy() <= 0f && gameWorld.spaceShip.getBody().getLinearVelocity().len() <= 0.01f ){
            finalAnimationFinished = true;
            AudioManager.stop();
        }
    }

    @Override
    public boolean keyDown(int keycode) {
        switch (keycode) {
            case Input.Keys.PLUS:
                cameraHelper.addZoom(-0.2f);
                break;
            case Input.Keys.MINUS:
                cameraHelper.addZoom(0.2f);
                break;
            case Input.Keys.D:
                debug = !debug;
                break;
            case Input.Keys.R:
                reset();
                break;
        }
        return true;
    }

    @Override
    public boolean touchDown(int screenX, int screenY, int pointer, int button) {
        curTouchPos = new Vector2(screenX, screenY);
        if(this.finalAnimationFinished) {<commit_msg>stopping all<commit_after>package com.github.dreamsnatcher;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.physics.box2d.*;
import com.github.dreamsnatcher.entities.*;
import com.github.dreamsnatcher.screens.ScreenManager;
import com.github.dreamsnatcher.utils.AudioManager;
import com.github.dreamsnatcher.utils.CameraHelper;
import com.github.dreamsnatcher.utils.CollisionObjectHelper;


public class WorldController extends InputAdapter implements ContactListener {
    public static final int MAX_ACCELERATION = 30;
    private static final float MAX_V = 3;
    public static final float DRAIN_ENERGY_STEP = 0.1f;

    public CameraHelper cameraHelper;
    private boolean zoomIn;
    private boolean finish;
    public boolean finalAnimationFinished;
    public boolean switchToMainMenu;

    public void setWorldRenderer(WorldRenderer worldRenderer) {
        this.worldRenderer = worldRenderer;
    }

    public WorldRenderer worldRenderer;
    public long timeElapsed;
    private World b2World;
    public GameWorld gameWorld;
    private boolean debug = false;
    private Vector2 curTouchPos;
    private String map = "map1.map";

    public WorldController(String level) {
        this.map = level;
        init();
    }

    public void init() {
        ScreenManager.multiplexer.addProcessor(this);
        cameraHelper = new CameraHelper();
        b2World = new World(new Vector2(0, 0f), true);
        b2World.setContactListener(this);
        // You can open this file and edit it via
        // Editor in the desktop project. You can of course
        // also create new files.
        gameWorld = GameWorldSerializer.deserialize(Gdx.files.internal(map));
        gameWorld.init(b2World);
        cameraHelper.setTarget(gameWorld.spaceShip.getBody());
    }

    public void update(float deltaTime) {
        if(!finish) {
            timeElapsed += deltaTime * 1000;
        }
        cameraHelper.update(deltaTime);
        gameWorld.spaceShip.update(deltaTime);
        for (GameObject object : gameWorld.objects) {
            object.update(deltaTime);
        }
        b2World.step(1 / 60f, 3, 8); //timeStep, velocityIteration, positionIteration
        if (Gdx.input.isTouched() && gameWorld.spaceShip.getEnergy() > 0 && !finish) {
            accelerate(curTouchPos.x, curTouchPos.y);
        }
        if (zoomIn) {
            cameraHelper.setZoom(cameraHelper.getZoom() - 0.002f);
        }
        if(gameWorld.spaceShip.getEnergy() <= 0f && gameWorld.spaceShip.getBody().getLinearVelocity().len() <= 0.01f ){
            finalAnimationFinished = true;
            AudioManager.stopAll();
        }
    }

    @Override
    public boolean keyDown(int keycode) {
        switch (keycode) {
            case Input.Keys.PLUS:
                cameraHelper.addZoom(-0.2f);
                break;
            case Input.Keys.MINUS:
                cameraHelper.addZoom(0.2f);
                break;
            case Input.Keys.D:
                debug = !debug;
                break;
            case Input.Keys.R:
                reset();
                break;
        }
        return true;
    }

    @Override
    public boolean touchDown(int screenX, int screenY, int pointer, int button) {
        curTouchPos = new Vector2(screenX, screenY);
        if(this.finalAnimationFinished) {
{'fraction_non_alphanumeric': 0.0945868945868946, 'fraction_numerical': 0.011680911680911682, 'mean_word_length': 2.4930348258706467, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '672826', 'n_tokens_mistral': 2094, 'n_tokens_neox': 1997, 'n_words': 447}