Wechsel auf Graphics2D mit mehr Features für später.

This commit is contained in:
Jan Philipp Timme 2014-10-28 20:32:39 +01:00
parent 04e2bcb3f2
commit 84e4ea98f0
9 changed files with 20 additions and 20 deletions

View File

@ -1,6 +1,6 @@
package de.teamteamteam.spacescooter.background; package de.teamteamteam.spacescooter.background;
import java.awt.Graphics; import java.awt.Graphics2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
@ -35,7 +35,7 @@ public class StarBackground extends Background {
} }
} }
public void paint(Graphics g) { public void paint(Graphics2D g) {
g.drawImage(StarBackground.img, (0+this.offset), 0, null); g.drawImage(StarBackground.img, (0+this.offset), 0, null);
g.drawImage(StarBackground.img, (StarBackground.img.getWidth()+this.offset), 0, null); g.drawImage(StarBackground.img, (StarBackground.img.getWidth()+this.offset), 0, null);
} }

View File

@ -1,7 +1,7 @@
package de.teamteamteam.spacescooter.entity; package de.teamteamteam.spacescooter.entity;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import de.teamteamteam.spacescooter.utility.GameConfig; import de.teamteamteam.spacescooter.utility.GameConfig;
@ -53,7 +53,7 @@ public abstract class Entity implements Updateable, Paintable {
this.img = img; this.img = img;
} }
public void paint(Graphics g) { public void paint(Graphics2D g) {
//DEBUG ONLY //DEBUG ONLY
if(GameConfig.DEBUG) { if(GameConfig.DEBUG) {
g.setColor(new Color(255,0,0)); g.setColor(new Color(255,0,0));

View File

@ -1,9 +1,9 @@
package de.teamteamteam.spacescooter.entity; package de.teamteamteam.spacescooter.entity;
import java.awt.Graphics; import java.awt.Graphics2D;
public interface Paintable { public interface Paintable {
public void paint(Graphics g); public void paint(Graphics2D g);
} }

View File

@ -1,6 +1,6 @@
package de.teamteamteam.spacescooter.gui; package de.teamteamteam.spacescooter.gui;
import java.awt.Graphics; import java.awt.Graphics2D;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.image.BufferStrategy; import java.awt.image.BufferStrategy;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -65,11 +65,11 @@ public class GameFrame extends JFrame {
* @see http://content.gpwiki.org/index.php/Java:Tutorials:Double_Buffering for details. * @see http://content.gpwiki.org/index.php/Java:Tutorials:Double_Buffering for details.
*/ */
public void draw() { public void draw() {
Graphics bufferedGraphics = null; Graphics2D bufferedGraphics = null;
do { // while bufferStrategy.contentsLost() do { // while bufferStrategy.contentsLost()
do { // bufferStrategy.contentsRestored() do { // bufferStrategy.contentsRestored()
try { try {
bufferedGraphics = this.bufferStrategy.getDrawGraphics(); bufferedGraphics = (Graphics2D) this.bufferStrategy.getDrawGraphics();
this.superScreen.doPaint(bufferedGraphics); this.superScreen.doPaint(bufferedGraphics);

View File

@ -2,7 +2,7 @@ package de.teamteamteam.spacescooter.screen;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics2D;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import de.teamteamteam.spacescooter.control.Keyboard; import de.teamteamteam.spacescooter.control.Keyboard;
@ -15,7 +15,7 @@ public class GamePausedScreen extends Screen {
} }
@Override @Override
protected void paint(Graphics g) { protected void paint(Graphics2D g) {
g.setColor(new Color(0,0,120)); g.setColor(new Color(0,0,120));
g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight); g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight);
g.setColor(new Color(255,255,255)); g.setColor(new Color(255,255,255));

View File

@ -1,6 +1,6 @@
package de.teamteamteam.spacescooter.screen; package de.teamteamteam.spacescooter.screen;
import java.awt.Graphics; import java.awt.Graphics2D;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.util.Iterator; import java.util.Iterator;
@ -25,7 +25,7 @@ public class GameScreen extends Screen {
} }
@Override @Override
protected void paint(Graphics g) { protected void paint(Graphics2D g) {
LinkedList<Entity> list = this.getEntities(); LinkedList<Entity> list = this.getEntities();
Iterator<Entity> i = list.iterator(); Iterator<Entity> i = list.iterator();
while (i.hasNext()) { while (i.hasNext()) {

View File

@ -2,7 +2,7 @@ package de.teamteamteam.spacescooter.screen;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics2D;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@ -16,7 +16,7 @@ public class MainMenuScreen extends Screen {
} }
@Override @Override
public void paint(Graphics g) { public void paint(Graphics2D g) {
g.setColor(new Color(0,0,120)); g.setColor(new Color(0,0,120));
g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight); g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight);
g.setColor(new Color(255,255,255)); g.setColor(new Color(255,255,255));

View File

@ -1,6 +1,6 @@
package de.teamteamteam.spacescooter.screen; package de.teamteamteam.spacescooter.screen;
import java.awt.Graphics; import java.awt.Graphics2D;
import java.util.LinkedList; import java.util.LinkedList;
import de.teamteamteam.spacescooter.entity.Entity; import de.teamteamteam.spacescooter.entity.Entity;
@ -32,10 +32,10 @@ public abstract class Screen {
return new LinkedList<Entity>(this.entities); return new LinkedList<Entity>(this.entities);
} }
protected abstract void paint(Graphics g); protected abstract void paint(Graphics2D g);
protected abstract void update(); protected abstract void update();
public void doPaint(Graphics g) { public void doPaint(Graphics2D g) {
this.paint(g); this.paint(g);
if(this.overlay != null) this.overlay.doPaint(g); if(this.overlay != null) this.overlay.doPaint(g);
} }

View File

@ -1,6 +1,6 @@
package de.teamteamteam.spacescooter.screen; package de.teamteamteam.spacescooter.screen;
import java.awt.Graphics; import java.awt.Graphics2D;
public class SuperScreen extends Screen { public class SuperScreen extends Screen {
@ -10,7 +10,7 @@ public class SuperScreen extends Screen {
} }
@Override @Override
public void paint(Graphics g) { public void paint(Graphics2D g) {
//nothing to paint, we're so meta meta. //nothing to paint, we're so meta meta.
} }