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...
|
//one of us...
|
||||||
if(obj instanceof BasicApp) {
|
if(obj instanceof BasicApp) {
|
||||||
apps.add((BasicApp)(obj));
|
apps.add((BasicApp)(obj));
|
||||||
((BasicApp)obj).initialize();
|
|
||||||
}
|
}
|
||||||
progress++;
|
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
|
* variables to track the fps, DON'T WORRY ABOUT IT, PAST YOU HAS YOU
|
||||||
* COVERED.
|
* 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;
|
private static int framesInCurrentSecond = 0, FPS = 0;
|
||||||
|
|
||||||
|
|
@ -134,12 +136,12 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
/**
|
/**
|
||||||
* debug level.
|
* debug level.
|
||||||
*/
|
*/
|
||||||
public static int debug = 2;
|
public static int debug = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* because retina support
|
* 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
|
* 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.addContainerListener(this);
|
||||||
frame.addComponentListener(this);
|
frame.addComponentListener(this);
|
||||||
|
|
||||||
requestFocus();
|
//requestFocus();
|
||||||
|
|
||||||
if (showLoading)
|
if (showLoading)
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
@ -198,9 +200,7 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
|
|
||||||
switchApps(0);
|
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();
|
nanos = System.nanoTime();
|
||||||
|
|
||||||
//no sleeping because we now operate on delta time.
|
//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) {
|
public static boolean switchApps(int i) {
|
||||||
try {
|
try {
|
||||||
|
apps[app].pauseApp();
|
||||||
app = i;
|
app = i;
|
||||||
setWindowProperties(apps[app]);
|
setWindowProperties(apps[app]);
|
||||||
apps[app].updateDimensions(BUFFER_WIDTH, BUFFER_HEIGHT);
|
apps[app].initialize();
|
||||||
|
apps[app].resumeApp();
|
||||||
frame.pack();
|
Engine.frame.requestFocus();
|
||||||
|
|
||||||
// because we now use the ONE buffer system... yeah
|
|
||||||
// lets do something about thaaaaaaaaat...
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -304,14 +307,18 @@ public class Engine extends Canvas implements KeyListener, MouseMotionListener,
|
||||||
* @param resizable
|
* @param resizable
|
||||||
*/
|
*/
|
||||||
private static void setWindowProperties(Dimension dimension, boolean resizable) {
|
private static void setWindowProperties(Dimension dimension, boolean resizable) {
|
||||||
frame.setResizable(resizable);
|
|
||||||
staticMain.setSize(dimension);
|
staticMain.setSize(dimension);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
WIDTH = dimension.width;
|
WIDTH = dimension.width;
|
||||||
HEIGHT = dimension.height;
|
HEIGHT = dimension.height;
|
||||||
frame.setResizable(resizable);
|
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.....
|
public void paint(Graphics g) {// oh.....
|
||||||
|
|
@ -342,9 +349,9 @@ 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
|
||||||
|
g.setColor(Color.RED);
|
||||||
if (debug > 0)
|
if (debug > 0)
|
||||||
g.drawString("FPS: " + FPS, 20, 20);
|
g.drawString("FPS: " + FPS, 20, 20);
|
||||||
g.setColor(Color.RED);
|
|
||||||
if (lag)
|
if (lag)
|
||||||
g.fillOval(10, 10, 10, 10);
|
g.fillOval(10, 10, 10, 10);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,18 +171,15 @@ public class ImageCreator {
|
||||||
return Math.log(x) / Math.log(b);
|
return Math.log(x) / Math.log(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BufferedImage colorNoise(int r, int g, int b, double multMin,
|
public static BufferedImage colorNoise(int r, int g, int b, double multMin, double multMax, int width, int height) {
|
||||||
double multMax, int width, int height) {
|
|
||||||
|
|
||||||
BufferedImage image = new BufferedImage(width, height,
|
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||||
BufferedImage.TYPE_INT_ARGB);
|
|
||||||
Graphics graphics = image.getGraphics();
|
Graphics graphics = image.getGraphics();
|
||||||
|
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
for (int j = 0; j < height; j++) {
|
for (int j = 0; j < height; j++) {
|
||||||
double k = Math.random() * (multMax - multMin) + multMin;
|
double k = Math.random() * (multMax - multMin) + multMin;
|
||||||
graphics.setColor(new Color((int) (r * k), (int) (g * k),
|
graphics.setColor(new Color((int) (r * k), (int) (g * k), (int) (b * k)));
|
||||||
(int) (b * k)));
|
|
||||||
graphics.fillRect(i, j, 1, 1);
|
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,
|
public static Image colorNoise(Color c, double d, double i, int width, int height) {
|
||||||
int height) {
|
return colorNoise(c.getRed(), c.getGreen(), c.getBlue(), d, i, width, height);
|
||||||
return colorNoise(c.getRed(), c.getGreen(), c.getBlue(), d, i, width,
|
|
||||||
height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue