public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); world.step(Math.min(0.032f, Gdx.graphics.getDeltaTime()), 3, 4); cam.update(); renderer.render(world, cam.combined); }
@Override public void render () { // update the world with a fixed time step long startTime = TimeUtils.nanoTime(); world.step(Gdx.app.getGraphics().getDeltaTime(), 3, 3); float updateTime = (TimeUtils.nanoTime() - startTime) / 1000000000.0f; startTime = TimeUtils.nanoTime(); // clear the screen and setup the projection matrix Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); // render the world using the debug renderer renderer.render(world, camera.combined); float renderTime = (TimeUtils.nanoTime() - startTime) / 1000000000.0f; batch.begin(); font.draw(batch, "fps:" + Gdx.graphics.getFramesPerSecond() + ", update: " + updateTime + ", render: " + renderTime, 0, 20); batch.end(); }
world.step(Gdx.graphics.getDeltaTime(), 4, 4);
world.step(Gdx.graphics.getDeltaTime(), 8, 3); float updateTime = (TimeUtils.nanoTime() - start) / 1000000000.0f;
@Override public void act(float delta) { super.act(delta); if (PhysicalWorld.WORLD != null) { PhysicalWorld.WORLD.step(delta, 3, 3); } }
@Override public void update(float delta) { world.step(delta, 3, 3); super.update(delta); }
@Override protected void onTick () { GameEvents.physicsStep.trigger(this, Type.onBeforeTimestep); world.step(Config.Physics.Dt, 10, 10); GameEvents.physicsStep.trigger(this, Type.onAfterTimestep); }
@Override public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // If the game doesn't render at 60fps, the physics will go mental. That'll be covered in Box2DFixedTimeStepSample world.step(1/60f, 6, 2); debugRenderer.render(world, viewport.getCamera().combined); }
@Override public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // If the game doesn't render at 60fps, the physics will go mental. That'll be covered in Box2DFixedTimeStepSample world.step(1/60f, 6, 2); debugRenderer.render(world, viewport.getCamera().combined); }
public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); world.step(delta, 10, 10); paddle.setPosition(paddleBody.getPosition().x*scale, paddleBody.getPosition().y*scale); ball.setPosition(ballBody.getPosition().x*scale, ballBody.getPosition().y*scale); Iterator iter = blocks.keySet().iterator(); while (iter.hasNext()) { Body b = (Body) iter.next(); Image i = (Image) blocks.get(b); if (i.hasParent() == false) { world.destroyBody(b); iter.remove(); } } stage.act(delta); stage.draw(); }
@Override public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); world.step(1/60f, 6, 2); raycastManager.update(); debugRenderer.render(world, viewport.getCamera().combined); } }
@Override public void update(float deltaTime) { super.update(deltaTime); float frameTime = Math.min(deltaTime, 0.25f); accumulator += frameTime; if(accumulator >= MAX_STEP_TIME) { world.step(MAX_STEP_TIME, 6, 2); accumulator -= MAX_STEP_TIME; //Entity Queue for (Entity entity : bodiesQueue) { TransformComponent tfm = tm.get(entity); BodyComponent bodyComp = bm.get(entity); Vector2 position = bodyComp.body.getPosition(); tfm.position.x = position.x; tfm.position.y = position.y; tfm.rotation = bodyComp.body.getAngle() * MathUtils.radiansToDegrees; } } bodiesQueue.clear(); }
@Override public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); world.step(1/60f, 6, 2); updateCamera(); renderer.setView(camera); renderer.render(); debugRenderer.render(world, camera.combined); } }
@Override public void act(float delta) { super.act(delta); Array<Body> bodies = new Array<Body>(world.getBodyCount()); world.getBodies(bodies); for (Body body : bodies) { update(body); } // Fixed timestep accumulator += delta; while (accumulator >= delta) { world.step(TIME_STEP, 6, 2); accumulator -= TIME_STEP; } //TODO: Implement interpolation }
@Override public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Update timer float delta = Gdx.graphics.getDeltaTime(); if((time += delta) >= 1f) { //Every second time-=1f; createBalloon(); } for(Body balloon : balloons) // Keep balloons flying balloon.applyForceToCenter(buoyancyForce, true); world.step(1/60f, 6, 2); debugRenderer.render(world, viewport.getCamera().combined); freeBalloons(); }
/** * Called to advance the game's state by the specified number of nanoseconds. iters is the * number of times to call the Box2D World.step method; more iterations produce better accuracy. * After updating physics, processes element collisions, calls tick() on every FieldElement, * and performs scheduled actions. */ void tick(long nanos, int iters) { float dt = (nanos/1e9f) / iters; for(int i=0; i<iters; i++) { clearBallContacts(); world.step(dt, 10, 10); processBallContacts(); } gameTime += nanos; processElementTicks(); processScheduledActions(); processGameMessages(); checkForStuckBall(nanos); getDelegate().tick(this, nanos); }
@Override public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); world.step(1/60f, 6, 2); if(title != null) { batch.begin(); viewport.getCamera().project(point.set(SCENE_WIDTH*0.5f, 6.8f, 0)); font.draw(batch, title, point.x - titleWidth, point.y); batch.end(); } debugRenderer.render(world, viewport.getCamera().combined); } }
public void render(float dt){ if(shot != null) camera.position.add(shot.getVelocity().x*VELOCITY_SCALAR*dt, shot.getVelocity().y*VELOCITY_SCALAR*dt, 0); camera.update(); rayHandler.setCombinedMatrix(camera); spriteBatch.setProjectionMatrix(camera.combined); spriteBatch.begin(); gdxRenderer.render(assetManager, spriteBatch, gdxLevel, camera, struct.bodies.entrySet()); spriteBatch.end(); tiledMeshRenderer.render(camera); world.step(dt, 10, 10); if(Properties.getBool("lighting.draw", false)) rayHandler.updateAndRender(); timeTransition -= dt; if(!signalled && timeTransition <= 0f){ listener.transition(); signalled = true; } }
@Override public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); world.step(1/60f, 6, 2); batch.begin(); batch.setProjectionMatrix(viewport.getCamera().combined); // Draw actors player1.draw(batch); player2.draw(batch); dinosaur1.draw(batch); dinosaur2.draw(batch); batch.end(); debugRenderer.render(world, viewport.getCamera().combined); }
@Override public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); world.step(1/60f, 6, 2); sr.setProjectionMatrix(viewport.getCamera().combined); sr.begin(ShapeType.Filled); sr.setColor(Color.RED); sr.rect(0, 0, SCENE_WIDTH, 1f); sr.end(); rayHandler.setCombinedMatrix(viewport.getCamera().combined); rayHandler.updateAndRender(); debugRenderer.render(world, viewport.getCamera().combined); }