当前位置: 首页>>代码示例>>Java>>正文


Java Sys.getTime方法代码示例

本文整理汇总了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"); 
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:SysTest.java

示例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;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:LwjglTimer.java

示例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;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:PickingTest.java

示例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;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:Game.java

示例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();
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:Timer.java

示例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");
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:SysTest.java

示例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");
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:37,代码来源:MouseCreationTest.java

示例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;
		}
	}
}
 
开发者ID:ryancwilliams,项目名称:SpaceStationAlpha,代码行数:37,代码来源:SpriteShootout2P.java

示例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;
		}
	}
}
 
开发者ID:ryancwilliams,项目名称:SpaceStationAlpha,代码行数:36,代码来源:SpriteShootoutCL.java

示例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();
	}
}
 
开发者ID:MiFF-Stockholm,项目名称:szo,代码行数:12,代码来源:GunWeapon.java

示例11: getCurrentTime

import org.lwjgl.Sys; //导入方法依赖的package包/类
private static long getCurrentTime() {
	return Sys.getTime() * 1000 / Sys.getTimerResolution();
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:4,代码来源:DisplayManager.java

示例12: getSystemTime

import org.lwjgl.Sys; //导入方法依赖的package包/类
/**
 * Gets the system time in milliseconds.
 */
public static long getSystemTime()
{
    return Sys.getTime() * 1000L / Sys.getTimerResolution();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:8,代码来源:Minecraft.java

示例13: getCurrentTime

import org.lwjgl.Sys; //导入方法依赖的package包/类
private long getCurrentTime(){
	return Sys.getTime()*1000/Sys.getTimerResolution();
}
 
开发者ID:TheThinMatrix,项目名称:OcclusionQueries,代码行数:4,代码来源:DisplayManager.java

示例14: getSystemTime

import org.lwjgl.Sys; //导入方法依赖的package包/类
/**
 * Gets the system time in milliseconds.
 */
public static long getSystemTime() {
	return Sys.getTime() * 1000L / Sys.getTimerResolution();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:7,代码来源:Minecraft.java

示例15: getTime

import org.lwjgl.Sys; //导入方法依赖的package包/类
private long getTime() {
	return (Sys.getTime() * 1000) / Sys.getTimerResolution();
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:4,代码来源:UsingEntities.java


注:本文中的org.lwjgl.Sys.getTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。