本文整理汇总了Java中org.lwjgl.Sys.getTime方法的典型用法代码示例。如果您正苦于以下问题:Java Sys.getTime方法的具体用法?Java Sys.getTime怎么用?Java Sys.getTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.Sys
的用法示例。
在下文中一共展示了Sys.getTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTimer
import org.lwjgl.Sys; //导入方法依赖的package包/类
/**
* Tests the timer
*/
private void testTimer() {
long resolution = Sys.getTimerResolution();
long time = Sys.getTime();
System.out.println("==== Test Timer ====");
System.out.println("Resolution of timer (ticks per second): " + resolution);
System.out.println("Current time: " + time);
System.out.println("Sleeping for 2 seconds, using Thread.sleep()");
pause(2000);
long time2 = Sys.getTime();
System.out.println("Current time: " + time2);
System.out.println("Actually slept for: " + ((time2 - time) / (float) resolution) + " seconds");
System.out.println("---- Test Timer ----\n");
}
示例2: reset
import org.lwjgl.Sys; //导入方法依赖的package包/类
public void reset() {
lastFrameDiff = 0;
lastFPS = 0;
lastTPF = 0;
// init to -1 to indicate this is a new timer.
oldTime = -1;
//reset time
startTime = Sys.getTime();
tpf = new long[TIMER_SMOOTHNESS];
smoothIndex = TIMER_SMOOTHNESS - 1;
invTimerRezSmooth = ( 1f / (LWJGL_TIMER_RES * TIMER_SMOOTHNESS));
// set tpf... -1 values will not be used for calculating the average in update()
for ( int i = tpf.length; --i >= 0; ) {
tpf[i] = -1;
}
}
示例3: getTime
import org.lwjgl.Sys; //导入方法依赖的package包/类
/**
* Get the high resolution time in milliseconds
*
* @return The high resolution time in milliseconds
*/
public static long getTime() {
// we get the "timer ticks" from the high resolution timer
// multiply by 1000 so our end result is in milliseconds
// then divide by the number of ticks in a second giving
// us a nice clear time in milliseconds
return ( Sys.getTime() * 1000 ) / timerTicksPerSecond;
}
示例4: getTime
import org.lwjgl.Sys; //导入方法依赖的package包/类
/**
* Get the high resolution time in milliseconds
*
* @return The high resolution time in milliseconds
*/
public static long getTime() {
// we get the "timer ticks" from the high resolution timer
// multiply by 1000 so our end result is in milliseconds
// then divide by the number of ticks in a second giving
// us a nice clear time in milliseconds
return (Sys.getTime() * 1000) / timerTicksPerSecond;
}
示例5: tick
import org.lwjgl.Sys; //导入方法依赖的package包/类
/**
* Get the next time update from the system's hires timer. This method should
* be called once per main loop iteration; all timers are updated simultaneously
* from it.
*/
public static void tick() {
currentTime = Sys.getTime();
// Periodically refresh the timer resolution:
queryCount ++;
if (queryCount > QUERY_INTERVAL) {
queryCount = 0;
resolution = Sys.getTimerResolution();
}
}
示例6: busyWait
import org.lwjgl.Sys; //导入方法依赖的package包/类
/**
* Busy waits for a specified number of seconds
*
* @param priority Priority to busy wait in
* @param seconds Number of seconds to busy wait
* @param message Message to print to user
*/
private void busyWait(int priority, int seconds, String message) {
long future = Sys.getTime() + (Sys.getTimerResolution() * seconds);
System.out.print(message);
// waste some cycles
while (Sys.getTime() < future) {
}
System.out.println("done");
}
示例7: wiggleMouse
import org.lwjgl.Sys; //导入方法依赖的package包/类
private void wiggleMouse() {
System.out.print("Please move the mouse around");
long statustime = Sys.getTime();
long endtime = Sys.getTime() + Sys.getTimerResolution() * 5;
while (Sys.getTime() < endtime) {
Display.update();
// empty mouse buffer
while(Mouse.next());
position.x += Mouse.getDX();
position.y += Mouse.getDY();
if(position.x<0) {
position.x = 0;
} else if (position.x>640-60) {
position.x = 640-60;
}
if(position.y < 0) {
position.y = 0;
} else if (position.y>480-30) {
position.y = 480-30;
}
render();
if (Sys.getTime() - statustime > Sys.getTimerResolution()) {
System.out.print(".");
statustime = Sys.getTime();
}
}
System.out.println("thank you");
}
示例8: run
import org.lwjgl.Sys; //导入方法依赖的package包/类
private void run() {
long startTime = System.currentTimeMillis() + 5000;
long fps = 0;
long time = Sys.getTime();
final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);
renderer.render(false, true, 0);
while ( run ) {
Display.processMessages();
handleInput();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
final long currTime = Sys.getTime();
final int delta = (int)(currTime - time);
if ( smooth || delta >= ticksPerUpdate ) {
renderer.render(render, animate, delta);
time = currTime;
} else
renderer.render(render, false, 0);
Display.update(false);
//Display.sync(60);
if ( startTime > System.currentTimeMillis() ) {
fps++;
} else {
long timeUsed = 5000 + (startTime - System.currentTimeMillis());
startTime = System.currentTimeMillis() + 5000;
System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
fps = 0;
}
}
}
示例9: run
import org.lwjgl.Sys; //导入方法依赖的package包/类
private void run() {
long startTime = System.currentTimeMillis() + 5000;
long fps = 0;
long time = Sys.getTime();
final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);
renderer.render(false, true, 0);
while ( run ) {
Display.processMessages();
handleInput();
glClear(GL_COLOR_BUFFER_BIT);
final long currTime = Sys.getTime();
final int delta = (int)(currTime - time);
if ( smooth || delta >= ticksPerUpdate ) {
renderer.render(render, animate, delta);
time = currTime;
} else
renderer.render(render, false, 0);
Display.update(false);
if ( startTime > System.currentTimeMillis() ) {
fps++;
} else {
long timeUsed = 5000 + (startTime - System.currentTimeMillis());
startTime = System.currentTimeMillis() + 5000;
System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
fps = 0;
}
}
}
示例10: fire
import org.lwjgl.Sys; //导入方法依赖的package包/类
@Override
public void fire() {
// Sprite sprite, int x, int y, int speed, int dir
if ((Sys.getTime() - timeSinceFire) > 300) {
timeSinceFire = Sys.getTime();
int dir = owner.getDir();
GunBullet blt = new GunBullet(bulletSprite, owner.x, owner.y, dir);
game.layer2.add(blt);
game.soundManager.playGun();
}
}
示例11: getCurrentTime
import org.lwjgl.Sys; //导入方法依赖的package包/类
private static long getCurrentTime() {
return Sys.getTime() * 1000 / Sys.getTimerResolution();
}
示例12: getSystemTime
import org.lwjgl.Sys; //导入方法依赖的package包/类
/**
* Gets the system time in milliseconds.
*/
public static long getSystemTime()
{
return Sys.getTime() * 1000L / Sys.getTimerResolution();
}
示例13: getCurrentTime
import org.lwjgl.Sys; //导入方法依赖的package包/类
private long getCurrentTime(){
return Sys.getTime()*1000/Sys.getTimerResolution();
}
示例14: getSystemTime
import org.lwjgl.Sys; //导入方法依赖的package包/类
/**
* Gets the system time in milliseconds.
*/
public static long getSystemTime() {
return Sys.getTime() * 1000L / Sys.getTimerResolution();
}
示例15: getTime
import org.lwjgl.Sys; //导入方法依赖的package包/类
private long getTime() {
return (Sys.getTime() * 1000) / Sys.getTimerResolution();
}