Java Code Examples for com.badlogic.gdx.utils.TimeUtils#millis()

The following examples show how to use com.badlogic.gdx.utils.TimeUtils#millis() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: gdx-proto   File: AbstractServer.java    License: Apache License 2.0 6 votes vote down vote up
public void update() {
	processDestroyedEntities();
	processChatMessages();
	maintainMonsterCount();
	serverEventManager.process();
	if (Main.isLocalServer()) {
		return;
	}
	processClientUpdates();
	long currentTime = TimeUtils.millis();
	long delta = currentTime - lastFrameTime;
	lastFrameTime = currentTime;
	accumulatedTime += delta;
	//Log.debug("server time delta: " + delta);
	while (accumulatedTime >= tickInterval) {
		tick();
		accumulatedTime -= tickInterval;
	}
}
 
Example 2
private void bufferTry() {
	if (startOfState) {
		lastStateTime = TimeUtils.millis();
		startOfState = false;
	}
	tryConnectText.draw();
	if (TimeUtils.millis() - lastStateTime > TIME_RETRY_CLIENT) {
		try {
			 if ( !ftc.isConnected() ) {
				  ftc.connect(adress, port);
			 }
			Header hdr = ftc.getHeader();
			nSamples = hdr.nSamples;
			fSample = hdr.fSample;
			lastUpdate = TimeUtils.millis();
			nextState();
		} catch (IOException e) {
			System.out.println(e.getMessage());
			if (e.getMessage().endsWith("517")) {
				changeState(States.WAITING_FOR_HEADER);
			} else {
				changeState(States.RETRYING_TO_CONNECT);
			}
		}
	}
}
 
Example 3
private void bufferRetry() {
	if (startOfState) {
		lastStateTime = TimeUtils.millis();
		startOfState = false;
	}
	retryingText.draw();
	if (TimeUtils.millis() - lastStateTime > TIME_RETRY_CLIENT) {
		try {
			 if ( !ftc.isConnected() ) {
				  ftc.connect(adress, port);
			 }
			Header hdr = ftc.getHeader();
			nSamples = hdr.nSamples;
			fSample = hdr.fSample;
			lastUpdate = TimeUtils.millis();
			nextState();
		} catch (IOException e) {
			System.out.println(e.getMessage());
			if (e.getMessage().endsWith("517")) {
				changeState(States.WAITING_FOR_HEADER);
			} else {
				lastStateTime = TimeUtils.millis();
			}
		}
	}
}
 
Example 4
Source Project: FruitCatcher   File: GameScreen.java    License: Apache License 2.0 5 votes vote down vote up
private void startGame() {
	st.isFinished = false;
	st.startGameTime = TimeUtils.millis();
	st.lastBadObjectTime = st.startGameTime;
	st.lastBonusItemTime = st.startGameTime;
	spawnFruit();		
}
 
Example 5
Source Project: riiablo   File: Packet.java    License: Apache License 2.0 5 votes vote down vote up
public static Packet obtain(int id, ByteBuffer buffer) {
  Packet packet = new Packet();
  packet.id = id;
  packet.time = TimeUtils.millis();
  packet.buffer = buffer;
  packet.data = D2GS.getRootAsD2GS(ByteBufferUtil.removeSizePrefix(buffer));
  return packet;
}
 
Example 6
protected void update() {
	Game.elapsed = Game.timeScale * Gdx.graphics.getDeltaTime();
	Game.timeTotal += Game.elapsed;
	
	Game.realTime = TimeUtils.millis();

	inputHandler.processAllEvents();
	
	scene.update();
	Camera.updateAll();
}
 
Example 7
@Override
public void startVibration(int duration, float strength) {
    try {
        controllerIndex.doVibration(strength, strength, duration);
        vibrationEndMs = TimeUtils.millis() + duration;
    } catch (ControllerUnpluggedException e) {
        // do nothing
    }
}
 
Example 8
private void renderFeedbackTrainingPause() {
	if (startOfState) {
		lastStateTime = TimeUtils.millis();
		startOfState = false;
	}

	drawGrid(gridGray);

	if (TimeUtils.millis() - lastStateTime > TIME_PAUSE) {
		nextState();
	}
}
 
Example 9
@Override
public boolean getButton(int i) {
    GCControllerButtonInput buttonFromConst = getButtonFromConst(i);

    if (i == BUTTON_PAUSE) {
        if (lastPausePressedMs > 0 && (TimeUtils.millis() - lastPausePressedMs) <= 250) {
            lastPausePressedMs = 0;
            return true;
        } else
            return false;
    } else if (buttonFromConst != null)
        return buttonFromConst.isPressed();
    else
        return false;
}
 
Example 10
Source Project: ud405   File: OrthographicCameraExercise.java    License: MIT License 5 votes vote down vote up
@Override
public void create() {
    renderer = new ShapeRenderer();
    timeCreated = TimeUtils.millis();

    // TODO: Initialize the camera
    camera = new OrthographicCamera();

    // TODO: Set the camera's position to the center of the circle's movement (X_CENTER, Y_CENTER)
    camera.position.set(X_CENTER, Y_CENTER, 0);
}
 
Example 11
Source Project: riiablo   File: D2GSPacket.java    License: Apache License 2.0 5 votes vote down vote up
public static D2GSPacket obtain(ChannelHandlerContext ctx, SocketAddress from, ByteBuf bb) {
  D2GSPacket packet = new D2GSPacket();
  packet.id = Server.INVALID_CLIENT;
  packet.time = TimeUtils.millis();

  packet.ctx = ctx;
  packet.from = from;
  packet.bb = bb;

  packet.buffer = bb.nioBuffer();
  packet.data = D2GS.getRootAsD2GS(packet.buffer);
  packet.dataType = packet.data.dataType();
  return packet;
}
 
Example 12
Source Project: libgdx-inGameConsole   File: LogEntry.java    License: Apache License 2.0 4 votes vote down vote up
protected LogEntry (String msg, LogLevel level) {
	this.text = msg;
	this.level = level;
	timeStamp = TimeUtils.millis();
}
 
Example 13
Source Project: riiablo   File: Pinger.java    License: Apache License 2.0 4 votes vote down vote up
public void Ping(Ping packet) {
  ping = TimeUtils.millis() - packet.sendTime() - packet.processTime();
  rtt  = TimeUtils.millis() - packet.sendTime();
  notifyPing(packet, ping, rtt);
}
 
Example 14
Source Project: gdx-proto   File: EntityInterpolator.java    License: Apache License 2.0 4 votes vote down vote up
public float getInterpolationAlpha() {
	float alpha = (TimeUtils.millis() - lastUpdateTime) / Main.getNetClient().tickInterval;
	return MathUtils.clamp(alpha, 0f, 1.0f);
}
 
Example 15
@Override
public boolean isVibrating() {
    return canVibrate() && TimeUtils.millis() < vibrationEndMs;
}
 
Example 16
@Override
public void startVibration(int duration, float strength) {
	Gamepad.getGamepad(index).doVibrate(duration, strength);
	vibrationEndMs = TimeUtils.millis() + duration;
}
 
Example 17
protected void onPauseButtonPressed() {
    lastPausePressedMs = TimeUtils.millis();
    notifyListenersButtonDown(BUTTON_PAUSE);
    notifyListenersButtonUp(BUTTON_PAUSE);
}
 
Example 18
private void renderTrainingGrid() {
	// Setup current state
	if (startOfState) {
		for (int i = 0; i < FLASHES_PER_STIMULUS; i++) {
			Collections.shuffle(FLASHINDICES);
			currentFlashes.addAll(FLASHINDICES);
		}
		lastStateTime = TimeUtils.millis();
		startOfState = false;
		flashOn = false;
	}

	// Determine if it's a flash or normal frame
	if (TimeUtils.millis() - lastStateTime >= TIME_FLASH) {
		flashOn = !flashOn;
		lastStateTime = TimeUtils.millis();

		if (flashOn) {
			currentFlash = currentFlashes.remove(0);

			if (currentFlashes.size() > 0) {

				if (ISCOLUMNFLASH[currentFlash]) {
					sendEventNOW("stimulus.columnFlash",
							NUMBERFLASH[currentFlash]);
					if (NUMBERFLASH[currentFlash] == xCue) {
						sendEventNOW("stimulus.tgtFlash", 1);
					} else {
						sendEventNOW("stimulus.tgtFlash", 0);
					}
				} else {
					sendEventNOW("stimulus.rowFlash",
							NUMBERFLASH[currentFlash]);
					if (NUMBERFLASH[currentFlash] == yCue) {
						sendEventNOW("stimulus.tgtFlash", 1);
					} else {
						sendEventNOW("stimulus.tgtFlash", 0);
					}
				}
			} else {
				if (--nrTrainingSequences > 0) {
					changeState(States.TRAINING_PAUSE);
				} else {
					nextState();
				}
				sendEventNOW("training.sequence", "end");
				flashOn = false;
			}
		}
	}

	// Draw screen
	if (flashOn) {
		drawGrid(gridGray, ISCOLUMNFLASH[currentFlash],
				NUMBERFLASH[currentFlash], gridWhite);
	} else {
		drawGrid(gridGray);
	}
}
 
Example 19
Source Project: gdx-proto   File: LocalClient.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void sendChatMessage(ChatMessage chat) {
	chat.playerId = 0;
	chat.createTime = TimeUtils.millis();
	View.inst.hud.addChatMessage(chat);
}
 
Example 20
Source Project: ud405   File: OrthographicCameraExercise.java    License: MIT License 3 votes vote down vote up
@Override
public void create() {
    renderer = new ShapeRenderer();
    timeCreated = TimeUtils.millis();

    // TODO: Initialize the camera


    // TODO: Set the camera's position to the center of the circle's movement (X_CENTER, Y_CENTER)

}