Compare commits
6 Commits
retina-dis
...
master
| Author | SHA1 | Date |
|---|---|---|
|
|
9ec7c17b54 | |
|
|
13c3448ab3 | |
|
|
96b3dd429c | |
|
|
d144576b31 | |
|
|
2fabfc9933 | |
|
|
642951ae1a |
|
|
@ -48,7 +48,6 @@ public class AppHelper implements Runnable{
|
|||
//one of us...
|
||||
if(obj instanceof BasicApp) {
|
||||
apps.add((BasicApp)(obj));
|
||||
((BasicApp)obj).initialize();
|
||||
}
|
||||
progress++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ 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;
|
||||
|
||||
|
|
@ -134,12 +136,12 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
|||
/**
|
||||
* debug level.
|
||||
*/
|
||||
public static int debug = 2;
|
||||
public static int debug = 0;
|
||||
|
||||
/**
|
||||
* because retina support
|
||||
*/
|
||||
private final boolean retina;
|
||||
private static boolean retina;
|
||||
|
||||
/**
|
||||
* SRSLY CALL DYS ONCE. DAS IT. ALL YOU GET. ONE SHOT. because this is a
|
||||
|
|
@ -171,7 +173,7 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
|||
frame.addContainerListener(this);
|
||||
frame.addComponentListener(this);
|
||||
|
||||
requestFocus();
|
||||
//requestFocus();
|
||||
|
||||
if (showLoading)
|
||||
frame.setVisible(true);
|
||||
|
|
@ -198,9 +200,7 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
|||
|
||||
switchApps(0);
|
||||
|
||||
BUFFER_HEIGHT = HEIGHT*(retina?2:1);
|
||||
BUFFER_WIDTH = WIDTH*(retina?2:1);
|
||||
createBuffer();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -233,6 +233,11 @@ 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){}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -270,14 +275,12 @@ 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].updateDimensions(BUFFER_WIDTH, BUFFER_HEIGHT);
|
||||
|
||||
frame.pack();
|
||||
|
||||
// because we now use the ONE buffer system... yeah
|
||||
// lets do something about thaaaaaaaaat...
|
||||
apps[app].initialize();
|
||||
apps[app].resumeApp();
|
||||
Engine.frame.requestFocus();
|
||||
|
||||
return true;
|
||||
|
||||
|
|
@ -304,14 +307,18 @@ 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.....
|
||||
|
|
@ -342,9 +349,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);
|
||||
|
||||
|
|
|
|||
|
|
@ -171,18 +171,15 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -191,9 +188,7 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue