Compare commits

...

6 Commits

Author SHA1 Message Date
Marcus Gosselin 9ec7c17b54 non resizable windows glitch fixed
sometimes non resizable windows would have the incorrect dimensions,
causing them to render slightly incorrectly. this is cause by a margin
in windows inside the JFrame of {25, 3, 3, 3}. essentially a timing
issue.
2015-12-03 04:23:35 -05:00
Marcus Gosselin 13c3448ab3 red FPS and added sleeping 2015-12-03 03:47:25 -05:00
marcus13345 96b3dd429c okay 2015-06-03 01:42:15 -04:00
marcus13345 d144576b31 Merge remote-tracking branch 'origin/master'
Conflicts:
	src/MAndEngine/ImageCreator.java
	src/MAndEngine/Utils.java
2015-04-11 23:20:05 -04:00
marcus13345 2fabfc9933 idunno what i did wrong... 2015-04-11 23:13:20 -04:00
Marcus Gosselin 642951ae1a updating of dimensions 2015-04-11 23:00:31 -04:00
3 changed files with 27 additions and 26 deletions

View File

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

View File

@ -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);

View File

@ -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);
}
}