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

The following examples show how to use com.badlogic.gdx.utils.TimeUtils#millis() . 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: AbstractServer.java    From gdx-proto with 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
Source File: VisSpeller.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: VisSpeller.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
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 File: GameScreen.java    From FruitCatcher with 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 File: Packet.java    From riiablo with 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
Source File: D2GSPacket.java    From riiablo with 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 7
Source File: OrthographicCameraExercise.java    From ud405 with 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 8
Source File: Game.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
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 9
Source File: JamepadController.java    From gdx-controllerutils with Apache License 2.0 5 votes vote down vote up
@Override
public void startVibration(int duration, float strength) {
    try {
        controllerIndex.doVibration(strength, strength, duration);
        vibrationEndMs = TimeUtils.millis() + duration;
    } catch (ControllerUnpluggedException e) {
        // do nothing
    }
}
 
Example 10
Source File: VisSpeller.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
private void renderFeedbackTrainingPause() {
	if (startOfState) {
		lastStateTime = TimeUtils.millis();
		startOfState = false;
	}

	drawGrid(gridGray);

	if (TimeUtils.millis() - lastStateTime > TIME_PAUSE) {
		nextState();
	}
}
 
Example 11
Source File: IosController.java    From gdx-controllerutils with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: LocalClient.java    From gdx-proto with 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 13
Source File: VisSpeller.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
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 14
Source File: IosController.java    From gdx-controllerutils with Apache License 2.0 4 votes vote down vote up
protected void onPauseButtonPressed() {
    lastPausePressedMs = TimeUtils.millis();
    notifyListenersButtonDown(BUTTON_PAUSE);
    notifyListenersButtonUp(BUTTON_PAUSE);
}
 
Example 15
Source File: GwtController.java    From gdx-controllerutils with Apache License 2.0 4 votes vote down vote up
@Override
public void startVibration(int duration, float strength) {
	Gamepad.getGamepad(index).doVibrate(duration, strength);
	vibrationEndMs = TimeUtils.millis() + duration;
}
 
Example 16
Source File: JamepadController.java    From gdx-controllerutils with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isVibrating() {
    return canVibrate() && TimeUtils.millis() < vibrationEndMs;
}
 
Example 17
Source File: EntityInterpolator.java    From gdx-proto with 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 18
Source File: Pinger.java    From riiablo with 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 19
Source File: LogEntry.java    From libgdx-inGameConsole with 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 20
Source File: OrthographicCameraExercise.java    From ud405 with 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)

}