ctrl shift f is a b word for github
parent
0da6133239
commit
fa71eb436b
|
|
@ -19,7 +19,8 @@ import java.util.Stack;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class Engine extends Canvas implements KeyListener, MouseMotionListener, MouseListener, ContainerListener, ComponentListener {
|
public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
|
MouseListener, ContainerListener, ComponentListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to track the x and y
|
* to track the x and y
|
||||||
|
|
@ -61,7 +62,8 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
/**
|
/**
|
||||||
* more framerate stuff, again, chill.
|
* more framerate stuff, again, chill.
|
||||||
*/
|
*/
|
||||||
private static long nextSecond = System.currentTimeMillis() + 1000, startTime = 0;
|
private static long nextSecond = System.currentTimeMillis() + 1000,
|
||||||
|
startTime = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if our current framerate is below our expected. its not directly
|
* if our current framerate is below our expected. its not directly
|
||||||
|
|
@ -121,8 +123,7 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
public static boolean[] keys;
|
public static boolean[] keys;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SOMETHING NEW I JUST DID NOW GUISE!
|
* SOMETHING NEW I JUST DID NOW GUISE! TODO properly document this?
|
||||||
* TODO properly document this?
|
|
||||||
*/
|
*/
|
||||||
private static BufferedImage buffer;
|
private static BufferedImage buffer;
|
||||||
private static Graphics2D g2;
|
private static Graphics2D g2;
|
||||||
|
|
@ -139,8 +140,8 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
public static int debug = 0;
|
public static int debug = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SRSLY CALL DYS ONCE. DAS IT. ALL YOU GET. ONE SHOT.
|
* SRSLY CALL DYS ONCE. DAS IT. ALL YOU GET. ONE SHOT. because this is a
|
||||||
* because this is a static engine, yeah
|
* static engine, yeah
|
||||||
*/
|
*/
|
||||||
public Engine(String[] classes, boolean showLoading) {
|
public Engine(String[] classes, boolean showLoading) {
|
||||||
|
|
||||||
|
|
@ -184,7 +185,8 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
}
|
}
|
||||||
// this is the later part referred to by a few lines back
|
// this is the later part referred to by a few lines back
|
||||||
repaint();
|
repaint();
|
||||||
progress += (appInitializer.getProgress() - progress) / ANIMATION_CONSTANT;
|
progress += (appInitializer.getProgress() - progress)
|
||||||
|
/ ANIMATION_CONSTANT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we done now, gather the loot.
|
// we done now, gather the loot.
|
||||||
|
|
@ -196,8 +198,8 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO at some point redo this to allow frame drop
|
// TODO at some point redo this to allow frame drop
|
||||||
//if it gets laggy....
|
// if it gets laggy....
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// REALLY????
|
// REALLY????
|
||||||
|
|
@ -224,7 +226,8 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
// FRAMERATE OVERCLOCKING AND SUCH, MOVE ALONG.
|
// FRAMERATE OVERCLOCKING AND SUCH, MOVE ALONG.
|
||||||
try {
|
try {
|
||||||
if (!overclock)
|
if (!overclock)
|
||||||
Thread.sleep((long) Math.floor(sleepTime - (System.currentTimeMillis() - startTime)));
|
Thread.sleep((long) Math.floor(sleepTime
|
||||||
|
- (System.currentTimeMillis() - startTime)));
|
||||||
else
|
else
|
||||||
Thread.sleep(0);
|
Thread.sleep(0);
|
||||||
lag = false;
|
lag = false;
|
||||||
|
|
@ -249,7 +252,7 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
public void update(Graphics g) {
|
public void update(Graphics g) {
|
||||||
// Graphics g2 = buffer.getGraphics();
|
// Graphics g2 = buffer.getGraphics();
|
||||||
|
|
||||||
if(buffer.getWidth() != WIDTH || buffer.getHeight() != HEIGHT) {
|
if (buffer.getWidth() != WIDTH || buffer.getHeight() != HEIGHT) {
|
||||||
System.out.println("bork " + buffer.getWidth());
|
System.out.println("bork " + buffer.getWidth());
|
||||||
System.out.println("bork " + WIDTH);
|
System.out.println("bork " + WIDTH);
|
||||||
createBuffer();
|
createBuffer();
|
||||||
|
|
@ -297,7 +300,8 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
* @param app
|
* @param app
|
||||||
*/
|
*/
|
||||||
private static void setWindowProperties(BasicApp app) {
|
private static void setWindowProperties(BasicApp app) {
|
||||||
setWindowProperties(app.getResolution(), app.getFramerate(), app.getResizable());
|
setWindowProperties(app.getResolution(), app.getFramerate(),
|
||||||
|
app.getResizable());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -307,7 +311,8 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
* @param fps
|
* @param fps
|
||||||
* @param resizable
|
* @param resizable
|
||||||
*/
|
*/
|
||||||
private static void setWindowProperties(Dimension dimension, int fps, boolean resizable) {
|
private static void setWindowProperties(Dimension dimension, int fps,
|
||||||
|
boolean resizable) {
|
||||||
frame.setResizable(resizable);
|
frame.setResizable(resizable);
|
||||||
staticMain.setSize(dimension);
|
staticMain.setSize(dimension);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
|
|
@ -329,8 +334,10 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
|
|
||||||
private static void render(Graphics2D g) {
|
private static void render(Graphics2D g) {
|
||||||
|
|
||||||
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||||
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
g.setFont(defaultFont);
|
g.setFont(defaultFont);
|
||||||
|
|
||||||
|
|
@ -347,7 +354,8 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
g.setColor(Color.WHITE);
|
g.setColor(Color.WHITE);
|
||||||
|
|
||||||
// show fps if debug level high enough
|
// show fps if debug level high enough
|
||||||
if(debug > 0) g.drawString("FPS: " + FPS, 20, 20);
|
if (debug > 0)
|
||||||
|
g.drawString("FPS: " + FPS, 20, 20);
|
||||||
if (overclock)
|
if (overclock)
|
||||||
g.drawString("Overclocking!", 20, 35);
|
g.drawString("Overclocking!", 20, 35);
|
||||||
g.setColor(Color.RED);
|
g.setColor(Color.RED);
|
||||||
|
|
@ -355,9 +363,11 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
g.fillOval(10, 10, 10, 10);
|
g.fillOval(10, 10, 10, 10);
|
||||||
|
|
||||||
g.setColor(Color.WHITE);
|
g.setColor(Color.WHITE);
|
||||||
if (!(log.size() == 0))
|
if (debug > 0)
|
||||||
for (int i = log.size() - 1; i >= 0; i--)
|
if (!(log.size() == 0))
|
||||||
log.elementAt(i).render(g, WIDTH - 200, HEIGHT - 10 - (i * 12));
|
for (int i = log.size() - 1; i >= 0; i--)
|
||||||
|
log.elementAt(i).render(g, WIDTH - 200,
|
||||||
|
HEIGHT - 10 - (i * 12));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
g.setFont(largerFont);
|
g.setFont(largerFont);
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue