Android Open Source - Infinite World Controller






From Project

Back to project page Infinite.

License

The source code is released under:

GNU General Public License

If you think the Android project Infinite listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.detel.infinite.controllers;
// w w w  . java 2s .c  o  m
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.detel.infinite.models.Chunk;
import com.detel.infinite.models.World;

/**
 * Created by Derick on 2/21/14.
 */
public class WorldController {

    private World world;

    private PlayerController playerController;
    private EnemyController enemyController;
    private KnifeController knifeController;

    private CameraController cameraController;
    private ChunkController chunkController;

    public WorldController(World world){
        this.world = world;

        playerController = new PlayerController(world);
        enemyController = new EnemyController(world);
        knifeController = new KnifeController(world);

        cameraController = new CameraController(world);
        chunkController = new ChunkController(world);

        createWorld();
    }

    private void createWorld(){
        world.addChunks(chunkController.generateFirstChunk());
        world.addChunks(chunkController.generateSecondChunk());
    }

    private void createNewChunk(){
        int i = world.getChunks().size();
        world.addChunks(chunkController.generateChunk(i));
    }

    public void update(float v){
        playerController.update(v);
        enemyController.update(v);
        knifeController.update(v);

        cameraController.update();

        if(world.getPlayer().getPosition().x > (Chunk.getSIZE().x - 10) * (world.getChunks().size() - 1)) createNewChunk();
    }

    public PlayerController getPlayerController(){
        return playerController;
    }

}




Java Source Code List

com.detel.infinite.Infinite.java
com.detel.infinite.MainActivity.java
com.detel.infinite.Main.java
com.detel.infinite.controllers.CameraController.java
com.detel.infinite.controllers.ChunkController.java
com.detel.infinite.controllers.EnemyController.java
com.detel.infinite.controllers.KnifeController.java
com.detel.infinite.controllers.PlayerController.java
com.detel.infinite.controllers.WorldController.java
com.detel.infinite.models.BlockAir.java
com.detel.infinite.models.Block.java
com.detel.infinite.models.Chunk.java
com.detel.infinite.models.Enemy.java
com.detel.infinite.models.Player.java
com.detel.infinite.models.ThrowingKnife.java
com.detel.infinite.models.World.java
com.detel.infinite.screens.ScreenBase.java
com.detel.infinite.screens.ScreenGameOver.java
com.detel.infinite.screens.ScreenGame.java
com.detel.infinite.screens.ScreenMainMenu.java
com.detel.infinite.screens.ScreenPause.java
com.detel.infinite.views.WorldRenderer.java