Java Code Examples for com.badlogic.gdx.utils.TimeUtils#timeSinceMillis()
The following examples show how to use
com.badlogic.gdx.utils.TimeUtils#timeSinceMillis() .
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
Source File: OrthographicCameraExercise.java From ud405 with MIT License | 6 votes |
@Override public void render() { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // TODO: Call update() on the camera // TODO: Set the SceneRenderer's projection matrix equal to the camera's combined matrix renderer.begin(ShapeType.Filled); float interval = TimeUtils.timeSinceMillis(timeCreated); float x = X_CENTER + X_AMPLITUDE * MathUtils.sin(MathUtils.PI2 * interval /PERIOD); float y = Y_CENTER + Y_AMPLITUDE * MathUtils.sin(2* MathUtils.PI2 * interval / PERIOD); renderer.circle(x, y, BALL_RADIUS); renderer.end(); }
Example 2
Source File: OrthographicCameraExercise.java From ud405 with MIT License | 6 votes |
@Override public void render() { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // TODO: Call update() on the camera camera.update(); // TODO: Set the SceneRenderer's projection matrix equal to the camera's combined matrix renderer.setProjectionMatrix(camera.combined); renderer.begin(ShapeType.Filled); float interval = TimeUtils.timeSinceMillis(timeCreated); float x = X_CENTER + X_AMPLITUDE * MathUtils.sin(MathUtils.PI2 * interval /PERIOD); float y = Y_CENTER + Y_AMPLITUDE * MathUtils.sin(2* MathUtils.PI2 * interval / PERIOD); renderer.circle(x, y, BALL_RADIUS); renderer.end(); }
Example 3
Source File: HUD.java From gdx-proto with Apache License 2.0 | 6 votes |
public void showChatMessages(StringBuilder sb) { for (ChatMessage chat : chatMessages) { long elapsed = TimeUtils.timeSinceMillis(chat.createTime); if (elapsed >= chatMessageLifeTime) { chatMessages.removeValue(chat, true); } else { sb.append("\n["); if (chat.playerId == -1) { sb.append("Server"); } else { sb.append("Player ").append(chat.playerId); } sb.append("]: ").append(chat.text); } } }
Example 4
Source File: Main.java From gdx-proto with Apache License 2.0 | 6 votes |
public void updateWorld() { long start = TimeUtils.millis(); if (lastPhysicsTime == -1) { lastPhysicsTime = start; return; } float delta = (start - lastPhysicsTime) / 1000f; lastPhysicsTime = start; accumulatedPhysicsTime += delta; //Log.debug("physics delta: " + delta); //Log.debug("accumualted physics time: " + accumulatedPhysicsTime); while (accumulatedPhysicsTime >= Physics.TIME_STEP) { physics.run(); accumulatedPhysicsTime -= Physics.TIME_STEP; Main.updateSubModules(Physics.TIME_SCALE); Entity.updateAll(Physics.TIME_SCALE); } physicsTime = (int) TimeUtils.timeSinceMillis(start); }
Example 5
Source File: View.java From gdx-proto with Apache License 2.0 | 4 votes |
public void render() { if (debugRenderPerformance) { debugRenderTimes(); } long start = TimeUtils.millis(); boolean profileGL = Toggleable.profileGL(); updateLights(); if (profileGL) { Profiler.reset(); } gl.glViewport(0, 0, width(), height()); gl.glClearColor(fogColor.r, fogColor.g, fogColor.b, fogColor.a); gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); camera.up.set(Vector3.Y); updateCamera(); long skyStart = TimeUtils.millis(); updateSky(); modelBatch.begin(camera); if (Sky.isEnabled()) { modelBatch.render(Sky.modelInstance); } skyTimes.add((int) TimeUtils.timeSinceMillis(skyStart)); // includes 3d models and billboards long entityStart = TimeUtils.millis(); visibleEntities = 0; for (EntityModel entityModel : EntityModel.list) { entityModel.update(); // don't draw self when in FPS mode if (!entityModel.isClientEntity() || Toggleable.freeCamera()) { if (entityVisibilityCheck(entityModel)) { visibleEntities++; modelBatch.render(entityModel.modelInstance, environ); } } } entityTimes.add((int) TimeUtils.timeSinceMillis(entityStart)); long boxStart = TimeUtils.millis(); if (Box.instance != null) { modelBatch.render(Box.instance, environ); } boxTimes.add((int) TimeUtils.timeSinceMillis(boxStart)); long staticStart = TimeUtils.millis(); if (LevelBuilder.staticGeometry != null) { for (ModelInstance staticGeo : LevelBuilder.staticGeometry) { modelBatch.render(staticGeo, environ); } } staticTimes.add((int) TimeUtils.timeSinceMillis(staticStart)); long groundStart = TimeUtils.millis(); visibleGroundPieces = 0; for (ModelInstance groundPiece : LevelBuilder.groundPieces) { if (groundPieceVisibilityCheck(groundPiece)) { visibleGroundPieces++; modelBatch.render(groundPiece, environ); } } groundTimes.add((int) TimeUtils.timeSinceMillis(groundStart)); modelBatch.end(); // draw particle effects in a separate batch to make depth testing work better modelBatch.begin(camera); for (Shadow shadow : Shadow.list) { modelBatch.render(shadow.modelInstance, environ); } drawParticleEffects(); modelBatch.end(); if (profileGL) { Profiler.tick(); } if (Toggleable.debugDraw() && Main.isClient()) { Physics.inst.debugDraw(); } long hudStart = TimeUtils.millis(); hud.draw(); long hudTime = TimeUtils.timeSinceMillis(hudStart); hudTimes.add((int) hudTime); long time = TimeUtils.timeSinceMillis(start); renderTimes.add((int) time); }