Yeah here’s my main setup of repainting and updating:
public void run() {
long lastLoopTime = System.nanoTime();
final int TARGET_FPS = 100;
final long OPTIMAL_TIME = 1000000000 / TARGET_FPS;
while (inRealGame) {
updateParticles();
if (inGame) {
long now = System.nanoTime();
long updateLength = now - lastLoopTime;
lastLoopTime = now;
delta = updateLength / ((double) OPTIMAL_TIME);
lastFpsTime += updateLength;
fps++;
gamePhysic(delta);
if (lastFpsTime >= 1000000000) {
realFPS = fps;
// frame.setTitle("(FPS: " + fps + ")");
// System.out.println("(FPS: " + fps + ")");
lastFpsTime = 0;
fps = 0;
}
try {
Thread.sleep((lastLoopTime - System.nanoTime() + OPTIMAL_TIME) / 1000000);
} catch (Exception e) {
e.printStackTrace();
}
}
repaint();
}
}
public void updateParticles() {
for (int i = 0; i <= particles.size() - 1; i++) {
Particle part = particles.get(i);
if (part != null) {
if (part.update()) {
particles.remove(i);
}
if (part != null) {
if (part.getLoc().x <= 0) {
part.getLoc().x = 0;
part.getVel().x *= -.9;
}
if (part.getLoc().x >= 700) {
part.getLoc().x = 700;
part.getVel().x *= -.9;
}
if (part.getLoc().y <= 0) {
part.getLoc().y = 0;
part.getVel().y *= -.9;
}
if (part.getLoc().y >= 550) {
part.getLoc().y = 550;
part.getVel().y *= -.9;
}
}
}
}
for (int i = 0; i <= overParticles.size() - 1; i++) {
Particle part = overParticles.get(i);
if (part != null) {
if (part.update()) {
overParticles.remove(i);
}
if (part != null) {
if (part.getLoc().x <= 0) {
part.getLoc().x = 0;
part.getVel().x *= -.9;
}
if (part.getLoc().x >= 700) {
part.getLoc().x = 700;
part.getVel().x *= -.9;
}
if (part.getLoc().y <= 0) {
part.getLoc().y = 0;
part.getVel().y *= -.9;
}
if (part.getLoc().y >= 550) {
part.getLoc().y = 550;
part.getVel().y *= -.9;
}
}
}
}
}
public void gamePhysic(double delta) {
if (!isFirst) {
room.physic();
mobSpawner();
for (int i = 0; i < currLevel.mobs.length; i++) {
if (currLevel.mobs[i].inGame) {
currLevel.mobs[i].physic();
}
}
if (currLevel.levelOver) {
getNextLevel(currLevel);
}
}
}
and for drawing things, I use the generic g.drawImage/fillOval(for some particles) and such. So you think I should have a variable that by default is one and when I maximize it set it to 3, 4, 5, 6 or whatever works and say g.drawImage(img, x, y, width * Screen.screenSizeMultiplier, height * Screen.screenSizeMultiplier, null);?