Created
November 4, 2016 20:16
-
-
Save zacharycarter/b95f090fa57700dc4fe202b187d463fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.carterza.system.camera; | |
import com.artemis.Aspect; | |
import com.artemis.ComponentMapper; | |
import com.artemis.systems.IteratingSystem; | |
import com.carterza.component.CameraFocusComponent; | |
import com.carterza.component.PositionComponent; | |
import net.mostlyoriginal.api.system.camera.CameraSystem; | |
public class CameraFocusSystem extends IteratingSystem { | |
private ComponentMapper<PositionComponent> positionComponentMapper; | |
private CameraSystem cameraSystem; | |
public CameraFocusSystem() { | |
super(Aspect.all(PositionComponent.class, CameraFocusComponent.class)); | |
} | |
@Override | |
protected void process(int entityId) { | |
final PositionComponent positionComponent = positionComponentMapper.get(entityId); | |
cameraSystem.camera.position.x = (int)(positionComponent.getX()); | |
cameraSystem.camera.position.y = (int)(positionComponent.getY()); | |
cameraSystem.camera.update(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.mostlyoriginal.api.system.camera; | |
import com.artemis.BaseSystem; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.graphics.OrthographicCamera; | |
/** | |
* Setup and manages basic orthographic camera. | |
* | |
* @author Daan van Yperen | |
*/ | |
public class CameraSystem extends BaseSystem { | |
public OrthographicCamera camera; | |
public OrthographicCamera guiCamera; | |
public final float zoom; | |
public CameraSystem( float width, float height ) | |
{ | |
this.zoom = 1; | |
setupViewport(width,height); | |
} | |
/** | |
* @param zoom How much | |
*/ | |
public CameraSystem( float zoom ) { | |
this.zoom = zoom; | |
float zoomFactorInverter = 1f/zoom; | |
setupViewport(Gdx.graphics.getWidth() * zoomFactorInverter, Gdx.graphics.getHeight() * zoomFactorInverter); | |
} | |
protected void setupViewport( float width, float height) { | |
camera = new OrthographicCamera(width, height); | |
camera.setToOrtho(false, width, height); | |
camera.update(); | |
guiCamera = new OrthographicCamera(width, height); | |
guiCamera.setToOrtho(false, width, height); | |
guiCamera.update(); | |
} | |
@Override | |
protected void processSystem() { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.carterza.system.debug; | |
import com.artemis.BaseSystem; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.graphics.Color; | |
import com.badlogic.gdx.graphics.g2d.BitmapFont; | |
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | |
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | |
import com.badlogic.gdx.math.Matrix4; | |
import com.badlogic.gdx.utils.FloatArray; | |
import com.badlogic.gdx.utils.ShortArray; | |
import com.carterza.generation.ship.Spacecraft; | |
import com.carterza.generation.ship.graph.ComparablePoint2i; | |
import com.carterza.system.generation.ShipGenerationSystem; | |
import com.carterza.system.map.render.MapRenderSystem; | |
import com.carterza.utils.ColorUtils; | |
import com.stewsters.shipwright.Edge; | |
import com.stewsters.shipwright.Room; | |
import com.stewsters.shipwright.Symbol; | |
import com.stewsters.util.math.Point2i; | |
import net.mostlyoriginal.api.system.camera.CameraSystem; | |
import org.delaunay.algorithm.Triangulation; | |
import org.delaunay.model.Triangle; | |
import org.delaunay.model.Vertex; | |
public class DebugSystem extends BaseSystem { | |
private ShipGenerationSystem shipGenerationSystem; | |
private CameraSystem cameraSystem; | |
private MapRenderSystem mapRenderSystem; | |
ShapeRenderer shapeRenderer; | |
SpriteBatch batch; | |
BitmapFont font; | |
float scale = 1; | |
@Override | |
protected void initialize() { | |
shapeRenderer = new ShapeRenderer(); | |
shapeRenderer.setProjectionMatrix(mapRenderSystem.getRenderer().getBatch().getProjectionMatrix()); | |
batch = new SpriteBatch(); | |
font = new BitmapFont(); | |
font.setColor(Color.RED); | |
} | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.carterza.system.map.render; | |
import com.artemis.BaseSystem; | |
import com.artemis.annotations.Wire; | |
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; | |
import com.carterza.system.map.MapGenerationSystem; | |
import net.mostlyoriginal.api.system.camera.CameraSystem; | |
import net.mostlyoriginal.api.system.core.PassiveSystem; | |
@Wire | |
public class MapRenderSystem extends BaseSystem { | |
private OrthogonalTiledMapRenderer renderer; | |
MapGenerationSystem mapGenerationSystem; | |
CameraSystem cameraSystem; | |
@Override | |
protected void initialize() { | |
renderer = new OrthogonalTiledMapRenderer(mapGenerationSystem.getMap()); | |
} | |
@Override | |
protected void processSystem() { | |
renderer.setView(cameraSystem.camera); | |
renderer.render(); | |
} | |
public OrthogonalTiledMapRenderer getRenderer() { | |
return this.renderer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment