Compare commits

..

1 Commits

Author SHA1 Message Date
Marcus Gosselin cd7de99a80 Merge branch 'master' into retina-display 2015-04-05 21:11:08 -04:00
3 changed files with 26 additions and 27 deletions

View File

@ -48,6 +48,7 @@ public class AppHelper implements Runnable{
//one of us...
if(obj instanceof BasicApp) {
apps.add((BasicApp)(obj));
((BasicApp)obj).initialize();
}
progress++;
}

View File

@ -52,8 +52,6 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
/**
* variables to track the fps, DON'T WORRY ABOUT IT, PAST YOU HAS YOU
* COVERED.
* present me here, im trusting you. and since i just implemented a way to have
* like 100k fps, thanks man for doing this right.
*/
private static int framesInCurrentSecond = 0, FPS = 0;
@ -136,12 +134,12 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
/**
* debug level.
*/
public static int debug = 0;
public static int debug = 2;
/**
* because retina support
*/
private static boolean retina;
private final boolean retina;
/**
* SRSLY CALL DYS ONCE. DAS IT. ALL YOU GET. ONE SHOT. because this is a
@ -173,7 +171,7 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
frame.addContainerListener(this);
frame.addComponentListener(this);
//requestFocus();
requestFocus();
if (showLoading)
frame.setVisible(true);
@ -200,7 +198,9 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
switchApps(0);
BUFFER_HEIGHT = HEIGHT*(retina?2:1);
BUFFER_WIDTH = WIDTH*(retina?2:1);
createBuffer();
}
@ -233,11 +233,6 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
nanos = System.nanoTime();
//no sleeping because we now operate on delta time.
//future marcus is amazed at your lack of comprehension here
//you see, by unlocking fps you render a good 2M fps...
//wasted power, so much wasted power.
//TODO remake the past marcus' system... man.
try{Thread.sleep(60);}catch(Exception e){}
}
}
@ -275,12 +270,14 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
*/
public static boolean switchApps(int i) {
try {
apps[app].pauseApp();
app = i;
setWindowProperties(apps[app]);
apps[app].initialize();
apps[app].resumeApp();
Engine.frame.requestFocus();
apps[app].updateDimensions(BUFFER_WIDTH, BUFFER_HEIGHT);
frame.pack();
// because we now use the ONE buffer system... yeah
// lets do something about thaaaaaaaaat...
return true;
@ -307,18 +304,14 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
* @param resizable
*/
private static void setWindowProperties(Dimension dimension, boolean resizable) {
frame.setResizable(resizable);
staticMain.setSize(dimension);
frame.pack();
frame.setLocationRelativeTo(null);
WIDTH = dimension.width;
HEIGHT = dimension.height;
frame.setResizable(resizable);
BUFFER_HEIGHT = HEIGHT*(retina?2:1);
BUFFER_WIDTH = WIDTH*(retina?2:1);
apps[app].updateDimensions(BUFFER_WIDTH, BUFFER_HEIGHT);
staticMain.createBuffer();
frame.setResizable(resizable);
frame.pack();
}
public void paint(Graphics g) {// oh.....
@ -349,9 +342,9 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
g.setColor(Color.WHITE);
// show fps if debug level high enough
g.setColor(Color.RED);
if (debug > 0)
g.drawString("FPS: " + FPS, 20, 20);
g.setColor(Color.RED);
if (lag)
g.fillOval(10, 10, 10, 10);

View File

@ -171,15 +171,18 @@ public class ImageCreator {
return Math.log(x) / Math.log(b);
}
public static BufferedImage colorNoise(int r, int g, int b, double multMin, double multMax, int width, int height) {
public static BufferedImage colorNoise(int r, int g, int b, double multMin,
double multMax, int width, int height) {
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
Graphics graphics = image.getGraphics();
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
double k = Math.random() * (multMax - multMin) + multMin;
graphics.setColor(new Color((int) (r * k), (int) (g * k), (int) (b * k)));
graphics.setColor(new Color((int) (r * k), (int) (g * k),
(int) (b * k)));
graphics.fillRect(i, j, 1, 1);
}
}
@ -188,7 +191,9 @@ public class ImageCreator {
}
public static Image colorNoise(Color c, double d, double i, int width, int height) {
return colorNoise(c.getRed(), c.getGreen(), c.getBlue(), d, i, width, height);
public static Image colorNoise(Color c, double d, double i, int width,
int height) {
return colorNoise(c.getRed(), c.getGreen(), c.getBlue(), d, i, width,
height);
}
}