SHARE
TWEET

Untitled

a guest Oct 1st, 2016 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  @Override
  2.     public void show() {
  3.         MapManager.loadMap("maps/ortho.tmx");
  4.  
  5.         Engine engine = new Engine();
  6.         batch = new SpriteBatch();
  7.  
  8.         world = new World(new Vector2(0, 0), false);
  9.  
  10.         rayHandler = new RayHandler(world);
  11.         rayHandler.setAmbientLight(.5f);
  12.  
  13.         entityManager = new EntityManager(engine, batch);          
  14.  
  15.         renderer = new OrthogonalTiledMapRenderer(MapManager.map);
  16.  
  17.         camera = new OrthographicCamera();
  18.         camera.setToOrtho(false,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
  19.  
  20.         b2dr = new Box2DDebugRenderer();
  21.  
  22.         Gdx.input.setInputProcessor(gameInput);
  23.  
  24.         myLight = new PointLight(rayHandler, 100, Color.WHITE, 600, 1500, 1000);
  25.         myLight.setSoftnessLength(0);
  26.  
  27.         SpawnGenerator.spawnPlayer(world, map, engine, 20f);
  28.         SpawnGenerator.spawnAI(world, map, engine, "Enemy", 20f);
  29.  
  30.         setTileBodies();
  31.     }
  32.  
  33.     public void render(float delta) {
  34.         Vector2 mp = screenToMap(unproject(camera, mousePosition));
  35.         Matrix4 debugMatrix = batch.getProjectionMatrix().cpy().scale(SteeringUtils.pixelsToMeters(), SteeringUtils.pixelsToMeters(), 0);
  36.  
  37.         Gdx.gl20.glClearColor(0, 0, 0, 1);
  38.         Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
  39.  
  40.         Gdx.gl20.glEnable(GL20.GL_DEPTH_TEST);
  41.         Gdx.gl20.glDepthFunc(GL20.GL_ALWAYS);
  42.         Gdx.gl20.glDepthMask(true);
  43.  
  44.         world.step(Gdx.graphics.getDeltaTime(), 6, 2);
  45.         rayHandler.update();
  46.  
  47.         camera.position.x = Math.min(Math.max(EntityManager.getPlayer().getComponent(PositionComponent.class).x, Gdx.graphics.getWidth() / 2), mapPixelWidth - (Gdx.graphics.getWidth() / 2));
  48.         camera.position.y = Math.min(Math.max(EntityManager.getPlayer().getComponent(PositionComponent.class).y, Gdx.graphics.getHeight() / 2), mapPixelHeight - (Gdx.graphics.getHeight() / 2));
  49.  
  50.         camera.update();
  51.  
  52.         renderer.setView(camera);
  53.         renderer.render();
  54.         renderer.getBatch().begin();
  55.         renderer.renderTileLayer((TiledMapTileLayer) renderer.getMap().getLayers().get(0));
  56.         renderer.renderTileLayer((TiledMapTileLayer) renderer.getMap().getLayers().get(1));
  57.         renderer.getBatch().end();
  58.  
  59.         batch.begin();
  60.         entityManager.update();
  61.         batch.setProjectionMatrix(camera.combined);
  62.         batch.end();
  63.         rayHandler.setCombinedMatrix(camera);
  64.  
  65.         b2dr.render(world, debugMatrix);
  66.         rayHandler.render();
  67.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top