Move RenderingHints into GameFrame method.

This commit is contained in:
Jan Philipp Timme 2014-11-10 20:40:06 +01:00
parent c37662f7f8
commit 248e5f685a
5 changed files with 11 additions and 13 deletions

View File

@ -1,8 +1,10 @@
package de.teamteamteam.spacescooter;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
import de.teamteamteam.spacescooter.control.Keyboard;
@ -97,6 +99,7 @@ public class GameFrame extends JFrame {
do { // bufferStrategy.contentsRestored()
try {
bufferedGraphics = (Graphics2D) this.bufferStrategy.getDrawGraphics();
this.applyRenderingHints(bufferedGraphics);
this.superScreen.doPaint(bufferedGraphics); //Trigger the actual paint routines.
} catch (Exception e) {
System.err.println("Exception in GameFrame.draw() gefangen:");
@ -112,4 +115,11 @@ public class GameFrame extends JFrame {
Toolkit.getDefaultToolkit().sync(); //Tell the OS to update its graphics of the window.
}
}
/**
* Apply rendering hints to the given Graphics2D.
*/
private void applyRenderingHints(Graphics2D bufferedGraphics) {
bufferedGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
bufferedGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
}

View File

@ -5,7 +5,6 @@ import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.awt.RenderingHints;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.entity.Player;
@ -40,8 +39,6 @@ public class GameOverScreen extends Screen {
@Override
protected void paint(Graphics2D g) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.drawImage(this.img, 0, 0, null);
this.entityPaintIterator.reset();
while (this.entityPaintIterator.hasNext()) {

View File

@ -5,7 +5,6 @@ import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.awt.RenderingHints;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.entity.Player;
@ -40,8 +39,6 @@ public class GamePausedScreen extends Screen {
@Override
protected void paint(Graphics2D g) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.drawImage(this.img, 0, 0, null);
this.entityPaintIterator.reset();
while (this.entityPaintIterator.hasNext()) {

View File

@ -3,7 +3,6 @@ package de.teamteamteam.spacescooter.screen;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import de.teamteamteam.spacescooter.utility.GameConfig;
/**
@ -37,8 +36,6 @@ public class LoadingScreen extends Screen {
@Override
protected void paint(Graphics2D g) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(new Color(0,0,120));
g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight);
g.setColor(new Color(255,255,255));

View File

@ -4,7 +4,6 @@ import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.RenderingHints;
import de.teamteamteam.spacescooter.background.StarBackground;
import de.teamteamteam.spacescooter.control.Keyboard;
@ -40,8 +39,6 @@ public class MainMenuScreen extends Screen {
@Override
public void paint(Graphics2D g) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
this.entityPaintIterator.reset();
while (this.entityPaintIterator.hasNext()) {
this.entityPaintIterator.next().paint(g);