コード例 #1
0
ファイル: Game.java プロジェクト: WesRichards/ustcp
 /** Run the main game loop. */
 public void run() {
   while (gameRunning) {
     // reset drawCount
     mapCount = 0;
     drawCount = 0;
     // clear screen
     gameWindow.clearScreen();
     // get delta
     timer.update();
     long delta = timer.getDelta();
     // update state
     stateManager.input(delta);
     stateManager.update(delta);
     stateManager.draw();
     // draw DebugHUD
     debugHUD.draw();
     // if escape has been pressed, stop the game
     if ((Display.isCloseRequested()
         || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))) {
       gameRunning = false;
     }
     // update window contents
     gameWindow.update();
   }
 }
コード例 #2
0
ファイル: Game.java プロジェクト: WesRichards/ustcp
 /** Create particle for player thrust trail. */
 public void playerThrustTrail() {
   int delta = (int) timer.getDelta();
   for (int i = delta / 2; i > 0; i--) {
     double particleDX =
         (((Math.cos(Math.toRadians(player.getHeading() - 180))) * 0.05) + player.getDx())
             + Rnd.getRandomD(-0.005, 0.005);
     double particleDY =
         (((Math.sin(Math.toRadians(player.getHeading() - 180))) * 0.05) + player.getDy())
             + Rnd.getRandomD(-0.005, 0.005);
     ParticleSmoke smoke =
         new ParticleSmoke(
             this,
             player.getX(),
             player.getY(),
             particleDX,
             particleDY,
             Rnd.getRandomI(10, 70),
             0.1,
             0.2);
     particles.add(smoke);
   }
 }