<commit_before>package com.sopwithredux;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.sopwithredux.gameobjects.*;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Carl on 08/03/2017.
 */
public class World
{
    private AssetManager assetManager;
    private List<GameObject> activeGameObjects, inactiveGameObjects, activeGameObjectsToAdd, activeGameObjectsToRemove;
    private CollisionHandler collisionHandler;
    private Texture background;

    public World(AssetManager assetManager)
    {
        this.assetManager = assetManager;
        activeGameObjects = new ArrayList<GameObject>();
        inactiveGameObjects = new ArrayList<GameObject>();
        activeGameObjectsToAdd = new ArrayList<GameObject>();
        activeGameObjectsToRemove = new ArrayList<GameObject>();
        collisionHandler = new CollisionHandler();
        background = assetManager.get("background.png", Texture.class);

        createGameObjects();

        for(GameObject gameObject : activeGameObjects)
        {
            if(gameObject instanceof CollidableObject)
            {
                collisionHandler.add((CollidableObject)gameObject);
            }
        }
    }

    public void update()
    {
        for(GameObject gameObject : activeGameObjects)
        {
            gameObject.update();
        }

        if(!activeGameObjectsToRemove.isEmpty())
        {
            activeGameObjects.removeAll(activeGameObjectsToRemove);
            activeGameObjectsToRemove.clear();
        }

        if(!activeGameObjectsToAdd.isEmpty())
        {
            activeGameObjects.addAll(activeGameObjectsToAdd);
            activeGameObjectsToAdd.clear();
        }
    }

    public void handleCollisions()
    {
        collisionHandler.handleCollisions();
    }

    public void render(SpriteBatch batch)
    {
        batch.draw(background, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        for(GameObject gameObject : activeGameObjects)
        {
            gameObject.render(batch);
        }
    }

    private void createGameObjects()
    {
        createClouds();
        createPlanes();
    }

    private void createClouds()
    {
        activeGameObjects.add(new Cloud(this, assetManager.get("cloud.png", Texture.class),
          new Vector2(Gdx.graphics.getWidth() - Gdx.graphics.getWidth() / 4, Gdx.graphics.getHeight() / 2),
          new Vector2(Gdx.graphics.getWidth() / 20, Gdx.graphics.getHeight() / 20),
          new Vector2(256, 128),
          100.0, 0.0, false, false));
    }

    private void createPlanes()
    {
        activeGameObjects.add(new Plane(this, assetManager.get("plane1.png", Texture.class),
          new Vector2(Gdx.graphics.getWidth() / 3, Gdx.graphics.getHeight() / 2),
          new Vector2(Gdx.graphics.getWidth() / 10, Gdx.graphics.getWidth() / 20),
          new Vector2(512, 256),
          200.0, false, false,
          Input.Keys.W, Input.Keys.S, Input.Keys.A, Input.Keys.D, Input.Keys.E));

        activeGameObjects.add(new Plane(this, assetManager.get("plane2.png", Texture.class),
          new Vector2(Gdx.graphics.getWidth() - Gdx.graphics.getWidth() / 3, Gdx.graphics.getHeight() / 2),
          new Vector2(Gdx.graphics.getWidth() / 10, Gdx.graphics.getWidth() / 20),
          new Vector2(512, 256),
          200.0, true, false,
          Input.Keys.UP, Input.Keys.DOWN, Input.Keys.LEFT, Input.Keys.RIGHT, Input.Keys.SHIFT_RIGHT));
    }

    public void add(GameObject gameObject)
    {
        activeGameObjectsToAdd.add(gameObject);

        if(gameObject instanceof CollidableObject)
        {
            collisionHandler.add((CollidableObject)gameObject);
        }
    }
<commit_msg>Added Clouds with random initial properties<commit_after>package com.sopwithredux;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.sopwithredux.gameobjects.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by Carl on 08/03/2017.
 */
public class World
{
    private AssetManager assetManager;
    private List<GameObject> activeGameObjects, inactiveGameObjects, activeGameObjectsToAdd, activeGameObjectsToRemove;
    private CollisionHandler collisionHandler;
    private Texture background;

    public World(AssetManager assetManager)
    {
        this.assetManager = assetManager;
        activeGameObjects = new ArrayList<GameObject>();
        inactiveGameObjects = new ArrayList<GameObject>();
        activeGameObjectsToAdd = new ArrayList<GameObject>();
        activeGameObjectsToRemove = new ArrayList<GameObject>();
        collisionHandler = new CollisionHandler();
        background = assetManager.get("background.png", Texture.class);

        createGameObjects();

        for(GameObject gameObject : activeGameObjects)
        {
            if(gameObject instanceof CollidableObject)
            {
                collisionHandler.add((CollidableObject)gameObject);
            }
        }
    }

    public void update()
    {
        for(GameObject gameObject : activeGameObjects)
        {
            gameObject.update();
        }

        if(!activeGameObjectsToRemove.isEmpty())
        {
            activeGameObjects.removeAll(activeGameObjectsToRemove);
            activeGameObjectsToRemove.clear();
        }

        if(!activeGameObjectsToAdd.isEmpty())
        {
            activeGameObjects.addAll(activeGameObjectsToAdd);
            activeGameObjectsToAdd.clear();
        }
    }

    public void handleCollisions()
    {
        collisionHandler.handleCollisions();
    }

    public void render(SpriteBatch batch)
    {
        batch.draw(background, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        for(GameObject gameObject : activeGameObjects)
        {
            gameObject.render(batch);
        }
    }

    private void createGameObjects()
    {
        createClouds();
        createPlanes();
    }

    private void createClouds()
    {
        Random rand = new Random();
        int randomWidth, randomHeight, randomPositionHeight, randomSpeed;

        for(int i = 0; i < 30; ++i)
        {
            randomWidth = rand.nextInt(120) + 80;
            randomHeight = rand.nextInt(75) + 20;
            randomPositionHeight = rand.nextInt(Gdx.graphics.getHeight());
            randomSpeed = rand.nextInt(200) + 20;

            activeGameObjects.add(new Cloud(this, assetManager.get("cloud.png", Texture.class),
              new Vector2(Gdx.graphics.getWidth() + randomWidth / 2, randomPositionHeight),
              new Vector2(randomWidth, randomHeight),
              new Vector2(256, 128),
              randomSpeed, 0.0, false, false));
        }

//        activeGameObjects.add(new Cloud(this, assetManager.get("cloud.png", Texture.class),
//          new Vector2(Gdx.graphics.getWidth() - Gdx.graphics.getWidth() / 4, Gdx.graphics.getHeight() / 2),
//          new Vector2(Gdx.graphics.getWidth() / 20, Gdx.graphics.getHeight() / 20),
//          new Vector2(256, 128),
//          100.0, 0.0, false, false));
    }

    private void createPlanes()
    {
        activeGameObjects.add(new Plane(this, assetManager.get("plane1.png", Texture.class),
          new Vector2(Gdx.graphics.getWidth() / 3, Gdx.graphics.getHeight() / 2),
          new Vector2(Gdx.graphics.getWidth() / 10, Gdx.graphics.getWidth() / 20),
          new Vector2(512, 256),
          200.0, false, false,
          Input.Keys.W, Input.Keys.S, Input.Keys.A, Input.Keys.D, Input.Keys.E));

        activeGameObjects.add(new Plane(this, assetManager.get("plane2.png", Texture.class),
          new Vector2(Gdx.graphics.getWidth() - Gdx.graphics.getWidth() / 3, Gdx.graphics.getHeight() / 2),
          new Vector2(Gdx.graphics.getWidth() / 10, Gdx.graphics.getWidth() / 20),
          new Vector2(512, 256),
          200.0, true, false,
          Input.Keys.UP, Input.Keys.DOWN, Input.Keys.LEFT, Input.Keys.RIGHT, Input.Keys.SHIFT_RIGHT));
    }

    public void add(GameObject gameObject)
    {
        activeGameObjectsToAdd.add(gameObject);

        if(gameObject instanceof CollidableObject)
        {
            collisionHandler.add((CollidableObject)gameObject);
        }
    }

{'fraction_non_alphanumeric': 0.1137794357659128, 'fraction_numerical': 0.020401025880158546, 'mean_word_length': 2.589539748953975, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, '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': '4921440', 'n_tokens_mistral': 2610, 'n_tokens_neox': 2448, 'n_words': 446}