public OrthoCamera() { this(new VirtualViewport(Settings.getWidth(), Settings.getHeight())); }
public void update(EntityController entityController) { if (Timer.getGameTimeElapsed() - lastSpawnTime >= SPAWN_TIME_BASE - (currentRound * SPAWN_TIME_DIF_RATE)) { if (enemiesSpawned < totalEnemies) { entityController.addEntity(new BasicEnemyShip(MathUtils.random(0, Settings.getWidth() - 50), MathUtils.random(Settings.getHeight(), Settings.getHeight() * 2))); enemiesSpawned++; lastSpawnTime = Timer.getGameTimeElapsed(); System.out.println("Added entity"); } } }
public void focusCamera(int width, int height, OrthoCamera camera) { float camX = 0, camY = 0; if (width * Settings.getTileSize() - pos.x >= (Settings.getWidth() / 2) * camera.zoom) camX = pos.x; else if (width * Settings.getTileSize() - pos.x <= (Settings.getWidth() / 2) * camera.zoom && pos.x > (Settings.getWidth() / 2) * camera.zoom) camX = width * Settings.getTileSize() - (Settings.getWidth() / 2) * camera.zoom; if (pos.x <= (Settings.getWidth() / 2) * camera.zoom) camX = (Settings.getWidth() / 2) * camera.zoom; else if (pos.x > (Settings.getWidth() / 2) * camera.zoom && pos.x < width * Settings.getTileSize() - (Settings.getWidth() / 2) * camera.zoom) camX = pos.x; if (height * Settings.getTileSize() - pos.y > (Settings.getHeight() / 2) * camera.zoom) camY = pos.y; else if (height * Settings.getTileSize() - pos.y <= (Settings.getHeight() / 2) * camera.zoom) camY = height * Settings.getTileSize() - (Settings.getHeight() / 2) * camera.zoom; if (pos.y <= (Settings.getHeight() / 2) * camera.zoom) camY = (Settings.getHeight() / 2) * camera.zoom; else if (pos.y > (Settings.getHeight() / 2) * camera.zoom && pos.y < height * Settings.getTileSize() - (Settings.getHeight() / 2) * camera.zoom) camY = pos.y; if (camX != camera.getPos().x || camY != camera.getPos().y) camera.setPosition(camX, camY); }
public void resize(int width, int height) { VirtualViewport virtualViewport = new VirtualViewport(width, height); setVirtualViewport(virtualViewport); updateViewport(Settings.getWidth(), Settings.getHeight()); }
public static void main (String[] arg) { GalacticInvaders.instantiateSettings(); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.width = Settings.getWidth(); config.height = Settings.getHeight(); new LwjglApplication(new GalacticInvaders(), config); } }
public boolean isOnScreen(AbstractEntity entity) { return entity.getPos().x > -entity.getWidth() && entity.getPos().x < Settings.getWidth() && entity.getPos().y > -entity.getHeight() && entity.getPos().y < Settings.getHeight(); }