Java Code Examples for com.badlogic.gdx.graphics.OrthographicCamera

The following examples show how to use com.badlogic.gdx.graphics.OrthographicCamera. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void create() {
	batch = new SpriteBatch();
	img = new Texture("core/assets/WatchDog.png");
	camera = new OrthographicCamera();
	camera.setToOrtho(false);

	spineKeeperArray = new Array<PerSpineKeeper>();
	if (jsonType) {
		JsonReader reader = new JsonReader();
		JsonValue jsonValue = reader.parse(Gdx.files.absolute(args.get(0)));
		System.out.println();
		array = jsonValue.asStringArray();
		size = array.length;
	}
	path = System.getProperty("user.dir");

	scale=Float.parseFloat(Gdx.files.internal("core/assets/scale.txt").readString());
}
 
Example 2
Source Project: xibalba   Source File: WorldRenderer.java    License: MIT License 6 votes vote down vote up
/**
 * Setup world renderer.
 *
 * @param worldCamera Instance of camera
 * @param batch       Instance of sprite batch
 */
public WorldRenderer(OrthographicCamera worldCamera, SpriteBatch batch) {
  this.worldCamera = worldCamera;
  this.batch = batch;

  viewport = new FitViewport(960, 540, worldCamera);

  playerDetails = ComponentMappers.player.get(WorldManager.player);
  playerAttributes = ComponentMappers.attributes.get(WorldManager.player);
  playerPosition = ComponentMappers.position.get(WorldManager.player);
  god = ComponentMappers.god.get(WorldManager.god);

  shadow = Main.asciiAtlas.createSprite("1113");
  question = Main.asciiAtlas.createSprite("1503");

  BitmapFont font = new BitmapFont();
  font.getData().setScale(.25f);
}
 
Example 3
Source Project: uracer-kotd   Source File: CarStillModel.java    License: Apache License 2.0 6 votes vote down vote up
private Vector3 world2Dto3D (PerspectiveCamera camPersp, OrthographicCamera camOrtho, float posPxX, float posPxY) {
	float meshZ = -(camPersp.far - camPersp.position.z) + (camPersp.far * (1 - (camOrtho.zoom)));

	// compute position
	tmpvec.x = (this.positionOffsetPx.x - camPersp.position.x) + (camPersp.viewportWidth / 2) + posPxX;
	tmpvec.y = (this.positionOffsetPx.y + camPersp.position.y) + (camPersp.viewportHeight / 2) - posPxY;
	tmpvec.z = 1;

	tmpvec.x *= ScaleUtils.Scale;
	tmpvec.y *= ScaleUtils.Scale;

	tmpvec.x += ScaleUtils.CropX;
	tmpvec.y += ScaleUtils.CropY;

	// transform to world space
	camPersp.unproject(tmpvec, ScaleUtils.CropX, ScaleUtils.CropY, ScaleUtils.PlayWidth, ScaleUtils.PlayHeight);

	// build model matrix
	tmpvec.z = meshZ;

	return tmpvec;
}
 
Example 4
Source Project: uracer-kotd   Source File: GameWorldRenderer.java    License: Apache License 2.0 6 votes vote down vote up
private void createCams () {
	int refW = Config.Graphics.ReferenceScreenWidth;
	int refH = Config.Graphics.ReferenceScreenHeight;

	camOrtho = new OrthographicCamera(refW, refH);
	halfViewport.set(camOrtho.viewportWidth / 2, camOrtho.viewportHeight / 2);

	// creates and setup orthographic camera
	camTilemap = new OrthographicCamera(refW, refH);
	camTilemap.zoom = 1;

	// creates and setup perspective camera
	// strategically choosen near/far planes, Blender models' 14.2 meters <=> one 256px tile
	// with far plane @48
	camPersp = new PerspectiveCamera(47.27123f, refW, refH);
	camPersp.near = CamPerspPlaneNear;
	camPersp.far = CamPerspPlaneFar;
	camPersp.lookAt(0, 0, -1);
	camPersp.position.set(camTilemap.position.x, camTilemap.position.y, CamPerspElevation);
	camPersp.update();

	camController = new CameraController(Config.Graphics.CameraInterpolationMode, halfViewport, world.worldSizePx,
		world.worldSizeTiles);
}
 
Example 5
Source Project: FruitCatcher   Source File: HelpScreen.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void show() {
       imageProvider = game.getImageProvider();
       backgroundImage = imageProvider.getBackgroundSpring();
       buttons = new Button [1];
       buttons[0] = new Button(imageProvider.getBack());        
       camera = new OrthographicCamera();
       camera.setToOrtho(false, imageProvider.getScreenWidth(), imageProvider.getScreenHeight());
       batch = new SpriteBatch();
       
       buttons[0].setPos(10, 10);
       
       font = new BitmapFont(Gdx.files.internal("fonts/poetsen.fnt"),
       			 		  Gdx.files.internal("fonts/poetsen.png"), false);
       
       startLine = 0;
       lineHeight = 30;
       lastLineIndex = game.getTextResources().getHelpLines().length - 1; 
       
       Gdx.input.setInputProcessor(this);
       Gdx.input.setCatchBackKey(true);        
}
 
Example 6
Source Project: Unlucky   Source File: TileMap.java    License: MIT License 6 votes vote down vote up
/**
 * Renders the bottom layer as the deepest part of the map
 *
 * @param batch
 */
public void renderBottomLayer(SpriteBatch batch, OrthographicCamera cam) {
    for (int i = 0; i < bottomLayer.length; i++) {
        if (tileInsideCamera(tileMap[i], cam)) {
            int r = i / mapWidth;
            int c = i % mapWidth;

            if (bottomLayer[i] != null)
                batch.draw(bottomLayer[i], origin.x + c * tileSize, origin.y + r * tileSize);
            // render animated tiles below the player
            if (tileMap[i].animated) {
                batch.draw(tileMap[i].anim.getKeyFrame(true), origin.x + c * tileSize, origin.y + r * tileSize);
            }
            // rendering non animated special tiles
            if (!tileMap[i].animated && tileMap[i].isSpecial() && tileMap[i].sprite != null) {
                batch.draw(tileMap[i].sprite, origin.x + c * tileSize, origin.y + r * tileSize);
            }
            // drawing an entity on a Tile
            if (tileMap[i].containsEntity()) {
                tileMap[i].getEntity().render(batch, true);
            }
        }
    }
}
 
Example 7
Source Project: buffer_bci   Source File: Renderer.java    License: GNU General Public License v3.0 6 votes vote down vote up
public Renderer (OrthographicCamera cam, Worm worm, Food food, Level level) {
	font = new BitmapFont(Gdx.files.internal(FONT_LOC));
	this.cam = cam;
	this.worm = worm;
	wholeWorm = worm.getAllBody();
	this.food = food;
	levelArray = level.getLevelArray();
	shapeRenderer = new ShapeRenderer();
	random = new Random();
	color = new Color();
	color.r = Color.WHITE.r;
	color.g = Color.WHITE.g;
	color.b = Color.WHITE.b;
	color.a = Color.WHITE.a;
	rect = new Rectangle();
	batch = new SpriteBatch();
}
 
Example 8
Source Project: TerraLegion   Source File: ChestBlock.java    License: MIT License 6 votes vote down vote up
/**
 * @return Whether the chest is being tapped
 */
public boolean isTapped(OrthographicCamera camera, float blockX, float blockY){
    this.mousePosition.set(Gdx.input.getX(), Gdx.input.getY(), 0);
    this.mousePosition = camera.unproject(mousePosition);

    if(this.mouseBounds == null){
        this.mouseBounds = new Rectangle(mousePosition.x, mousePosition.y, 0, 0);
    }

    this.mouseBounds.set(this.mousePosition.x, this.mousePosition.y, 0, 0);

    if(this.getBody(blockX, blockY).getBounds().overlaps(mouseBounds) && Gdx.input.isButtonPressed(Input.Buttons.LEFT)){
        return true;
    }

    return false;
}
 
Example 9
Source Project: Radix   Source File: MainMenu.java    License: MIT License 6 votes vote down vote up
public void init() {
    if (!initialized) {
        camera = new OrthographicCamera();
        batch = new SpriteBatch();
        batch.setTransformMatrix(RadixClient.getInstance().getHudCamera().combined);
        batch.setTransformMatrix(camera.combined);
        mmButtonTexture = new Texture(Gdx.files.internal("textures/gui/mmBtn.png"));

        buttonFont = new BitmapFont();

        resize();
        rerender();

        initialized = true;
    }
}
 
Example 10
Source Project: Radix   Source File: RadixClient.java    License: MIT License 6 votes vote down vote up
private void setupOGL() {
    camera = new PerspectiveCamera(90, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(10f, 150f, 10f);
    camera.lookAt(0, 0, 0);
    camera.near = 0.1f;
    camera.far = 450f;
    camera.update();
    hudCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    guiBatch = new SpriteBatch();
    guiBatch.setProjectionMatrix(hudCamera.combined);

    if(android) {
        setupTouchControls();
    }

    Gdx.input.setInputProcessor(new RadixInputHandler(this));

    if(settingsManager.getVisualSettings().getNonContinuous().getValue()) {
        Gdx.graphics.setContinuousRendering(false);
    }

    sceneTheme = new SceneTheme();
    sceneTheme.init();
}
 
Example 11
Source Project: riiablo   Source File: ProfilerSystem.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void initialize() {
  camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  camera.setToOrtho(false);
  camera.update();
  renderer = new ShapeRenderer();
  stage = new Stage();
  stage.getBatch().setProjectionMatrix(camera.combined);
  skin = new Skin(Gdx.files.internal("profiler/uiskin.json"));

  // setup some static config like colors etc
  SystemProfilerGUI.GRAPH_H_LINE.set(Color.ORANGE);
  gui = new SystemProfilerGUI(skin, "default");
  gui.setResizeBorder(8);
  gui.show(stage);
  world.inject(gui, true);
  gui.initialize();
}
 
Example 12
Source Project: ud405   Source File: ViewportsDemo.java    License: MIT License 6 votes vote down vote up
/**
     * Uncomment the following viewports one at a time, and check out the effect when you resize the desktop window.
     */
    @Override
    public void create() {
        camera = new OrthographicCamera();

        // Makes the size of the world match the size of the screen
        viewport = new ScreenViewport(camera);

        // Make the world fill the screen, regardless of aspect ratio
//        viewport = new StretchViewport(WORLD_WIDTH, WORLD_HEIGHT, camera);

        // Make the world fill the screen, maintaining aspect ratio, but bits of the world may be cut off
//        viewport = new FillViewport(WORLD_WIDTH, WORLD_HEIGHT, camera);

        // Fit the world inside the screen, adding black bars to pad out the extra space, maintaining aspect ratio
//        viewport = new FitViewport(WORLD_WIDTH, WORLD_HEIGHT, camera);

        // Make the short axis of the world larger to fill the screen, maintaining aspect ratio
//        viewport = new ExtendViewport(WORLD_WIDTH, WORLD_HEIGHT, camera);


        viewport.setScreenBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        renderer = new ShapeRenderer();
    }
 
Example 13
Source Project: killingspree   Source File: WorldRenderer.java    License: MIT License 6 votes vote down vote up
public WorldRenderer(WorldManager worldManager, Client client, KillingSpree game) {
    worldMap = new ConcurrentHashMap<Short, ClientEntity>();
    this.worldManager = worldManager;
    audioPlayer = new SFXPlayer();
    stateProcessor = new StateProcessor(client, worldMap, audioPlayer,
            game.platformServices);
    if (worldManager != null) {
        debugRenderer = new WorldDebugRenderer(worldManager.getWorld());
        worldManager.setOutgoingEventListener(stateProcessor);
    } else {
        this.client = client;
    }
    camera = new OrthographicCamera();
    batch = new SpriteBatch();
    controlsSender = new ControlsSender();
    recentId = -2;
    screenShakeX = 0;
    screenShakeY = 0;
    screenShakeTime = 0;
    hudRenderer = new HUDRenderer();
    this.game = game;
}
 
Example 14
Source Project: killingspree   Source File: ClientDiscoveryScreen.java    License: MIT License 6 votes vote down vote up
@Override
public void show() {
    client = new Client();
    client.start();
    font = game.getFont(120);
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    viewport = new FitViewport(1280, 720, camera);
    camera.setToOrtho(false, 1280, 720);
    buttons = new ArrayList<MyButton>();
    ipAddresses = new ArrayList<MyButton>();
    markForDispose = false;
    addAllButtons();
    addIpButtons();
    pressedButton = false;
}
 
Example 15
Source Project: xibalba   Source File: Main.java    License: MIT License 5 votes vote down vote up
/**
 * From mouse position to tile position.
 *
 * @param camera Main world camera
 * @return A vector2 of the hovered tile position
 */
public static Vector2 mousePositionToWorld(OrthographicCamera camera) {
  Vector3 position = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
  camera.unproject(position);

  return new Vector2(
      Math.round(position.x) / Main.SPRITE_WIDTH,
      Math.round(position.y) / Main.SPRITE_HEIGHT
  );
}
 
Example 16
Source Project: xibalba   Source File: PlayScreen.java    License: MIT License 5 votes vote down vote up
/**
 * Play Screen.
 *
 * @param main Instance of Main class
 */
public PlayScreen(Main main) {
  glProfiler = new GLProfiler(Gdx.graphics);

  autoTimer = 0;
  keyHoldTimerDelay = 0;
  keyHoldTimer = 0;
  batch = new SpriteBatch();

  // Setup camera;
  OrthographicCamera worldCamera = new OrthographicCamera();

  // Setup renderers
  worldRenderer = new WorldRenderer(worldCamera, batch);
  hudRenderer = new HudRenderer(main, batch);

  // Debug console
  console = new GUIConsole(Main.skin, false);
  console.setCommandExecutor(new ConsoleCommandExecutor());
  console.setSizePercent(100, 50);

  // Setup input
  multiplexer = new InputMultiplexer();
  playerInput = new PlayerInput(worldCamera);
  multiplexer.addProcessor(hudRenderer.stage);
  multiplexer.addProcessor(playerInput);

  // Player attributes & their god
  playerAttributes = ComponentMappers.attributes.get(WorldManager.player);
  god = ComponentMappers.god.get(WorldManager.god);

  // Generate all dijkstra maps
  WorldManager.world.getCurrentMap().dijkstra.updateAll();

  // Change state to playing
  WorldManager.state = WorldManager.State.PLAYING;
}
 
Example 17
Source Project: gdx-gltf   Source File: DirectionalShadowLight.java    License: Apache License 2.0 5 votes vote down vote up
public DirectionalShadowLight(int shadowMapWidth, int shadowMapHeight, float shadowViewportWidth,
		float shadowViewportHeight, float shadowNear, float shadowFar) {
	fbo = new FrameBuffer(Format.RGBA8888, shadowMapWidth, shadowMapHeight, true);
	cam = new OrthographicCamera(shadowViewportWidth, shadowViewportHeight);
	cam.near = shadowNear;
	cam.far = shadowFar;
	textureDesc = new TextureDescriptor();
	textureDesc.minFilter = textureDesc.magFilter = Texture.TextureFilter.Nearest;
	textureDesc.uWrap = textureDesc.vWrap = Texture.TextureWrap.ClampToEdge;
}
 
Example 18
Source Project: gdx-gltf   Source File: GLTFCameraExporter.java    License: Apache License 2.0 5 votes vote down vote up
private GLTFCamera export(Camera camera) {
	GLTFCamera glCamera = new GLTFCamera();
	if(camera instanceof PerspectiveCamera){
		PerspectiveCamera pcam = (PerspectiveCamera)camera;
		glCamera.type = "perspective";
		glCamera.perspective = new GLTFPerspective();
		glCamera.perspective.yfov = pcam.fieldOfView * MathUtils.degreesToRadians; // TODO not sure
		glCamera.perspective.znear = camera.near;
		glCamera.perspective.zfar = camera.far;
		glCamera.perspective.aspectRatio = camera.viewportWidth / camera.viewportHeight; // TODO not sure
		// TODO aspect ratio and fov should be recomputed...
	}
	else if(camera instanceof OrthographicCamera){
		OrthographicCamera ocam = (OrthographicCamera)camera;
		glCamera.type = "orthographic";
		glCamera.orthographic = new GLTFOrthographic();
		glCamera.orthographic.znear = camera.near;
		glCamera.orthographic.zfar = camera.far;
		glCamera.orthographic.xmag = camera.viewportWidth * ocam.zoom; // TODO not sure
		glCamera.orthographic.ymag = camera.viewportHeight * ocam.zoom; // TODO not sure
	}
	else{
		throw new GdxRuntimeException("unsupported camera type " + camera.getClass());
	}
	
	return glCamera;
}
 
Example 19
Source Project: raycaster   Source File: Camera.java    License: MIT License 5 votes vote down vote up
public Camera(OrthographicCamera camera, double resolution, double fov) {
  this.camera = camera;
  this.batch = new SpriteBatch();
  this.batch.setProjectionMatrix(camera.combined);
  this.shapeRenderer = new ShapeRenderer();
  this.shapeRenderer.setProjectionMatrix(camera.combined);
  this.width = this.camera.viewportWidth;
  this.height = this.camera.viewportHeight;
  this.resolution = resolution;
  this.spacing = this.width / resolution;
  this.fov = fov;
  this.range = 14;
  this.lightRange = 5;
  this.scale = (this.width + this.height) / 1200;
}
 
Example 20
Source Project: Norii   Source File: BattleScreen.java    License: Apache License 2.0 5 votes vote down vote up
private void initializeVariables() {
	players = new ArrayList<TeamLeader>();
	playerSortedUnits = Player.getInstance().getUnitsSortedByIni();
	mapCamera = new OrthographicCamera();
	mapCamera.setToOrtho(false, VISIBLE_WIDTH, VISIBLE_HEIGHT);
	isPaused = false;
}
 
Example 21
Source Project: box2dlights   Source File: SimpleTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	camera = new OrthographicCamera(48, 32);
	camera.update();
	world = new World(new Vector2(0, -10), true);
	rayHandler = new RayHandler(world);
	new PointLight(rayHandler, 32);

}
 
Example 22
Source Project: ashley-superjumper   Source File: HelpScreen3.java    License: Apache License 2.0 5 votes vote down vote up
public HelpScreen3 (SuperJumper game) {
	this.game = game;

	guiCam = new OrthographicCamera(320, 480);
	guiCam.position.set(320 / 2, 480 / 2, 0);
	nextBounds = new Rectangle(320 - 64, 0, 64, 64);
	touchPoint = new Vector3();
	helpImage = Assets.loadTexture("data/help3.png");
	helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}
 
Example 23
Source Project: mini2Dx   Source File: LibgdxGraphics.java    License: Apache License 2.0 5 votes vote down vote up
public LibgdxGraphics(GameWrapper gameWrapper, LibgdxSpriteBatchWrapper spriteBatch, PolygonSpriteBatch polygonSpriteBatch, ShapeRenderer shapeRenderer) {
	this.gameWrapper = gameWrapper;
	this.spriteBatch = spriteBatch;
	this.shapeRenderer = shapeRenderer;
	this.shapeRenderer.setAutoShapeType(true);
	this.polygonSpriteBatch = polygonSpriteBatch;

	this.windowWidth = Gdx.graphics.getWidth();
	this.windowHeight = Gdx.graphics.getHeight();

	defaultTint = new LibgdxReadOnlyColor(spriteBatch.getColor().cpy());
	font = Mdx.fonts.defaultFont();
	tint = defaultTint;

	lineHeight = 1;
	color = new LibgdxColor(1f, 1f, 1f, 1f);
	defaultColor = new LibgdxReadOnlyColor(1f, 1f, 1f, 1f);
	backgroundColor = new LibgdxColor(0f, 0f, 0f, 1f);
	colorTextureCache = new ShapeTextureCache();

	translationX = 0;
	translationY = 0;
	scaleX = 1f;
	scaleY = 1f;
	rotation = 0f;
	rotationX = 0f;
	rotationY = 0f;

	/* Create Ortho camera so that 0,0 is in top-left */
	camera = new OrthographicCamera();
}
 
Example 24
Source Project: Unlucky   Source File: UI.java    License: MIT License 5 votes vote down vote up
public UI(GameScreen gameScreen, TileMap tileMap, Player player, ResourceManager rm) {
    this.game = gameScreen.getGame();
    this.gameScreen = gameScreen;
    this.tileMap = tileMap;
    this.player = player;
    this.rm = rm;

    viewport = new StretchViewport(Unlucky.V_WIDTH, Unlucky.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, gameScreen.getBatch());

    shapeRenderer = new ShapeRenderer();
}
 
Example 25
Source Project: Unlucky   Source File: AbstractScreen.java    License: MIT License 5 votes vote down vote up
public AbstractScreen(final Unlucky game, final ResourceManager rm) {
    this.game = game;
    this.rm = rm;

    cam = new OrthographicCamera(Unlucky.V_WIDTH, Unlucky.V_HEIGHT);
    cam.setToOrtho(false);
    // the game will retain it's scaled dimensions regardless of resizing
    viewport = new StretchViewport(Unlucky.V_WIDTH, Unlucky.V_HEIGHT, cam);

    stage = new Stage(viewport, game.batch);
}
 
Example 26
Source Project: Unlucky   Source File: GameScreen.java    License: MIT License 5 votes vote down vote up
public GameScreen(final Unlucky game, final ResourceManager rm) {
    super(game, rm);

    currentEvent = EventState.MOVING;

    gameMap = new GameMap(this, game.player, rm);
    battle = new Battle(this, gameMap.tileMap, gameMap.player);
    hud = new Hud(this, gameMap.tileMap, gameMap.player, rm);
    battleUIHandler = new BattleUIHandler(this, gameMap.tileMap, gameMap.player, battle, rm);
    transition = new TransitionScreen(this, battle, battleUIHandler, hud, gameMap.player, rm);
    levelUp = new LevelUpScreen(this, gameMap.tileMap, gameMap.player, rm);
    dialog = new DialogScreen(this, gameMap.tileMap, gameMap.player, rm);

    // create bg
    bg = new Background[2];
    // sky
    bg[0] = new Background((OrthographicCamera) battleUIHandler.getStage().getCamera(), new Vector2(0.3f, 0));
    // field
    bg[1] = new Background((OrthographicCamera) battleUIHandler.getStage().getCamera(), new Vector2(0, 0));


    // input multiplexer
    multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(hud.getStage());
    multiplexer.addProcessor(battleUIHandler.getStage());
    multiplexer.addProcessor(levelUp.getStage());
    multiplexer.addProcessor(dialog.getStage());
}
 
Example 27
Source Project: Unlucky   Source File: ParticleFactory.java    License: MIT License 5 votes vote down vote up
public ParticleFactory(OrthographicCamera cam, final ResourceManager rm) {
    this.cam = cam;
    this.viewWidth = (int) cam.viewportWidth;
    this.viewHeight = (int) cam.viewportHeight;
    this.rm = rm;

    particles = new Array<Particle>();
    particlePool = new Pool<Particle>() {
        @Override
        protected Particle newObject() {
            return new Particle();
        }
    };
}
 
Example 28
Source Project: libgdx-2d-tutorial   Source File: GameCamera.java    License: MIT License 5 votes vote down vote up
public GameCamera (int width, int height) {
	cam = new OrthographicCamera();
	viewport = new StretchViewport(width, height, cam);
	viewport.apply();
	cam.position.set(width / 2, height / 2, 0);
	cam.update();
}
 
Example 29
Source Project: fluid-simulator-v2   Source File: FluidSimulatorSPH.java    License: Apache License 2.0 5 votes vote down vote up
public FluidSimulatorSPH(FluidSimulatorStarter fluidSimulatorStarter) {
	super(fluidSimulatorStarter);
	batch = new SpriteBatch(IS_DESKTOP ? 5460 : ANDROID_SIZE);
	font = new BitmapFont();
	camera = new OrthographicCamera(WORLD_WIDTH, WORLD_HEIGHT);
	camera.position.set(0, (WORLD_HEIGHT / 2) - 1, 0);
}
 
Example 30
Source Project: TerraLegion   Source File: PlantBlock.java    License: MIT License 5 votes vote down vote up
@Override
public void render(OrthographicCamera camera, SpriteBatch sb, float x, float y, float lightValue){
    super.render(camera, sb, x, y, lightValue);

    Vector2 tilePosition = new Vector2(chunkManager.pixelToTilePosition(x), chunkManager.pixelToTilePosition(y));
    Vector2 belowTilePosition = new Vector2(tilePosition.x, tilePosition.y - 1);

    if(chunkManager.getBlockFromTilePos((int) belowTilePosition.x, (int) belowTilePosition.y) == BlockType.AIR){
        chunkManager.setBlock(BlockType.AIR, (int) tilePosition.x, (int) tilePosition.y, true);
    }
}