<commit_before>package com.colim.anglexplore.stages;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import com.colim.anglexplore.actors.GameAngle;
import com.colim.anglexplore.actors.GameUI;
import com.colim.anglexplore.actors.Text;
import com.colim.anglexplore.utils.AssetLoaderGame;
import com.colim.anglexplore.utils.Constants;
import com.colim.anglexplore.utils.LettersTextures;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;


/*
 * Created by <NAME> on 2015.
 *
 * Copyright (c) Usbong Social Systems, Inc. All rights reserved.
 */

public class GameStage extends Stage {


    private GameUI gameUI;
    private TextureRegion pointTexture;
    private TextureRegion armTexture;
    private List<GameAngle> angles;
    private LettersTextures lettersTextures;

    private Text text;


    public GameStage(){

        super(new StretchViewport(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT,
                new OrthographicCamera(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT)));

        setupCamera();

        AssetLoaderGame.load();
        pointTexture = AssetLoaderGame.vertex;
        armTexture = AssetLoaderGame.arm;
        lettersTextures = new LettersTextures(AssetLoaderGame.letters);

        gameUI = new GameUI();
        addActor(gameUI);

        setUpText();

        angles = new ArrayList<GameAngle>();
        generateGameAngles(angles);

        gameUI.generate.addListener(new ClickListener() {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
            {
                updateGameAngles(angles);
                return true;
            }
        });

        gameUI.quit.addListener(new ClickListener() {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
            {
                Gdx.app.exit();
                return true;
            }
        });

    }

    private void setupCamera() {
        OrthographicCamera camera;
        camera = new OrthographicCamera(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT);
        camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0f);
        camera.update();
    }

    private void setUpText() {
        text = new Text("", new Label.LabelStyle(new BitmapFont(), Color.FIREBRICK));
        text.setWrap(true);
        text.setWidth(Constants.WORLD_WIDTH);
        addActor(text);
    }

    public void generateGameAngles(List<GameAngle> angles){
        float angle_x = ((float) Math.random()) * 90f;
        float angle_y = ((float) Math.random()) * 180f;

        // ugly hack
        List<Character> letters = new LinkedList<Character>();
        for (char n = 'A'; n <= 'F'; n++)
            letters.add(n);
        Collections.shuffle(letters);
        System.out.print(letters);

        // must randomize letter Texture
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(0)), letters.get(0), new Vector2(Constants.WORLD_WIDTH /4 , 3* Constants.WORLD_HEIGHT /4 ), angle_x));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(1)), letters.get(1), new Vector2(2 * Constants.WORLD_WIDTH /4 , 3* Constants.WORLD_HEIGHT /4 ), 90 - angle_x));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(2)), letters.get(2), new Vector2(3 * Constants.WORLD_WIDTH /4 , 3* Constants.WORLD_HEIGHT /4 ), angle_y));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(3)), letters.get(3), new Vector2(Constants.WORLD_WIDTH /4 , 2* Constants.WORLD_HEIGHT /4 ), 180-angle_y));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(4)), letters.get(4), new Vector2(2 * Constants.WORLD_WIDTH /4 , 2* Constants.WORLD_HEIGHT /4 ),((float) Math.random()) * 180f));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(5)), letters.get(5), new Vector2(3 * Constants.WORLD_WIDTH /4 , 2* Constants.WORLD_HEIGHT /4 ), ((float) Math.random()) * 180f));

        for (GameAngle angle : angles) {
            addActor(angle);
        }
    }

    // Really dirty hack.
    public void updateGameAngles(List<GameAngle> angles){
        float angle_x = ((float) Math.random()) * 90f;
        float angle_y = ((float) Math.random()) * 180f;

        for (GameAngle angle : angles){
            angle.resetPosition();
        }
        angles.get(0).newRotation(angle_x);
        angles.get(1).newRotation(90 - angle_x);
        angles.get(2).newRotation(angle_y);
        angles.get(3).newRotation(180 - angle_y);
        angles.get(4).newRotation(((float) Math.random()) * 180f);
        angles.get(5).newRotation(((float) Math.random()) * 180f);<commit_msg>Randomized starting positions of angles<commit_after>package com.colim.anglexplore.stages;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import com.colim.anglexplore.actors.GameAngle;
import com.colim.anglexplore.actors.GameUI;
import com.colim.anglexplore.actors.Text;
import com.colim.anglexplore.utils.AssetLoaderGame;
import com.colim.anglexplore.utils.Constants;
import com.colim.anglexplore.utils.LettersTextures;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;


/*
 * Created by <NAME> on 2015.
 *
 * Copyright (c) Usbong Social Systems, Inc. All rights reserved.
 */

public class GameStage extends Stage {


    private GameUI gameUI;
    private TextureRegion pointTexture;
    private TextureRegion armTexture;
    private List<GameAngle> angles;
    private LettersTextures lettersTextures;

    private Text text;


    public GameStage(){

        super(new StretchViewport(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT,
                new OrthographicCamera(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT)));

        setupCamera();

        AssetLoaderGame.load();
        pointTexture = AssetLoaderGame.vertex;
        armTexture = AssetLoaderGame.arm;
        lettersTextures = new LettersTextures(AssetLoaderGame.letters);

        gameUI = new GameUI();
        addActor(gameUI);

        setUpText();

        angles = new ArrayList<GameAngle>();
        generateGameAngles(angles);

        gameUI.generate.addListener(new ClickListener() {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
            {
                updateGameAngles(angles);
                return true;
            }
        });

        gameUI.quit.addListener(new ClickListener() {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
            {
                Gdx.app.exit();
                return true;
            }
        });

    }

    private void setupCamera() {
        OrthographicCamera camera;
        camera = new OrthographicCamera(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT);
        camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0f);
        camera.update();
    }

    private void setUpText() {
        text = new Text("", new Label.LabelStyle(new BitmapFont(), Color.FIREBRICK));
        text.setWrap(true);
        text.setWidth(Constants.WORLD_WIDTH);
        addActor(text);
    }

    public void generateGameAngles(List<GameAngle> angles){
        float angle_x = ((float) Math.random()) * 90f;
        float angle_y = ((float) Math.random()) * 180f;

        // ugly hack
        List<Character> letters = new LinkedList<Character>();
        for (char n = 'A'; n <= 'F'; n++)
            letters.add(n);
        Collections.shuffle(letters);
        System.out.print(letters);

        List<Vector2> initialPositions = new LinkedList<Vector2>();
        initialPositions.add(new Vector2(Constants.WORLD_WIDTH /4 , 3* Constants.WORLD_HEIGHT /4 ));
        initialPositions.add(new Vector2(2 * Constants.WORLD_WIDTH /4 , 3* Constants.WORLD_HEIGHT /4 ));
        initialPositions.add(new Vector2(3 * Constants.WORLD_WIDTH /4 , 3* Constants.WORLD_HEIGHT /4 ));
        initialPositions.add(new Vector2(Constants.WORLD_WIDTH /4 , 2* Constants.WORLD_HEIGHT /4 ));
        initialPositions.add(new Vector2(2 * Constants.WORLD_WIDTH /4 , 2* Constants.WORLD_HEIGHT /4 ));
        initialPositions.add(new Vector2(3 * Constants.WORLD_WIDTH /4 , 2* Constants.WORLD_HEIGHT /4 ));
        Collections.shuffle(initialPositions);

        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(0)), letters.get(0), initialPositions.get(0) , angle_x));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(1)), letters.get(1), initialPositions.get(1), 90 - angle_x));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(2)), letters.get(2), initialPositions.get(2), angle_y));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(3)), letters.get(3), initialPositions.get(3), 180-angle_y));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(4)), letters.get(4), initialPositions.get(4),((float) Math.random()) * 180f));
        angles.add(new GameAngle(pointTexture, armTexture, lettersTextures.getLetter(letters.get(5)), letters.get(5), initialPositions.get(5), ((float) Math.random()) * 180f));

        for (GameAngle angle : angles) {
            addActor(angle);
        }
    }

    // Really dirty hack.
    public void updateGameAngles(List<GameAngle> angles){
        float angle_x = ((float) Math.random()) * 90f;
        float angle_y = ((float) Math.random()) * 180f;

        for (GameAngle angle : angles){
            angle.resetPosition();
        }
        angles.get(0).newRotation(angle_x);
        angles.get(1).newRotation(90 - angle_x);
        angles.get(2).newRotation(angle_y);
        angles.get(3).newRotation(180 - angle_y);
        angles.get(4).newRotation(((float) Math.random()) * 180f);
        angles.get(5).newRotation(((float) Math.random()) * 180f);
{'fraction_non_alphanumeric': 0.1217188061848256, 'fraction_numerical': 0.017259978425026967, 'mean_word_length': 3.241326725123904, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '2397815', 'n_tokens_mistral': 3634, 'n_tokens_neox': 3378, 'n_words': 655}