home *** CD-ROM | disk | FTP | other *** search
Wrap
package com.next.gt; import java.applet.Applet; import java.awt.Component; import java.awt.Event; import java.awt.Graphics; public abstract class Gamelet extends Applet implements Runnable { public Thread runner; public long currentTickTimeMillis = System.currentTimeMillis(); public long lastTickTimeMillis; public ActorManager actorManager = new ActorManager(this); public DisplayManager displayManager = new DisplayManager(this); public ScoreManager scoreManager; public EventManager eventManager = new EventManager(); public int SLEEP_MILLIS = 50; public static double randBetween(double var0, double var2) { if (var0 > var2) { double var8 = var0; var0 = var2; var2 = var8; } double var6 = var2 - var0; double var4 = var6 * Math.random(); return var0 + var4; } public void init() { } public void start() { if (this.runner == null) { this.runner = new Thread(this); this.runner.start(); } } public void stop() { if (this.runner != null) { this.runner.stop(); } this.runner = null; } public long sleepMillis() { return (long)this.SLEEP_MILLIS; } public void run() { for(; this.runner != null; this.tick()) { try { Thread.sleep(this.sleepMillis()); } catch (InterruptedException var1) { } } this.runner = null; } public void tick() { this.lastTickTimeMillis = this.currentTickTimeMillis; this.currentTickTimeMillis = System.currentTimeMillis(); this.actorManager.tick(); ((Component)this).repaint(); } public boolean handleEvent(Event var1) { boolean var2 = false; if (this.eventManager != null) { var2 = this.eventManager.handleEvent(var1); } return var2; } public double deltaTickTimeMillis() { return (double)(this.currentTickTimeMillis - this.lastTickTimeMillis); } public void update(Graphics var1) { this.paint(var1); } public void paint(Graphics var1) { this.displayManager.paint(var1); } public String getAppletInfo() { return "The Gamelet Toolkit\nVersion 0.8\nWritten by Mark Tacchi, mtacchi@NeXT.COM\n\nYou are free to use, copy, and modify the source without restriction. However, it is requested that the author is mentioned in any pertinent credit sections released with code developed with the Gamelet Toolkit."; } }