Add an EffectMaster for fun.

This commit is contained in:
Jan Philipp Timme 2014-12-16 13:22:30 +01:00
parent 2d7c3c2f62
commit 29fc971b03
3 changed files with 61 additions and 38 deletions

View File

@ -1,38 +0,0 @@
package de.teamteamteam.spacescooter.background;
import java.awt.Graphics2D;
import de.teamteamteam.spacescooter.brain.GameConfig;
public class FuckedUpCloudBackground extends ScrollingBackground {
private double x;
/*private double x_delta;
private int percentage;
private int timer;*/
public FuckedUpCloudBackground(int x, int y) {
super(x, y);
this.setImage("images/cloudbackground.png");
this.setScrollingSpeed(-1);
}
public void paint(Graphics2D g) {
g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight);
/*if(this.timer == 0 && this.percentage < 100) {
this.percentage++;
} else if (timer > 500 && this.percentage > 0) {
this.percentage--;
} else if (this.percentage == 100){
this.timer++;
} else if (this.percentage == 0) {
this.timer--;
}*/
this.x += 0.005;
g.rotate(this.x, GameConfig.windowWidth/2, GameConfig.windowHeight/2);
super.paint(g);
}
}

View File

@ -0,0 +1,59 @@
package de.teamteamteam.spacescooter.fx;
import java.awt.Graphics2D;
import de.teamteamteam.spacescooter.brain.GameConfig;
/**
* The EffectMaster3000 is a product of pure madness.
*/
public class EffectMaster {
private static double x;
private static int percentage;
private static int timer;
static {
EffectMaster.init();
}
/**
* Private constructor - this guy does not want to be instantiated.
*/
private EffectMaster() {}
/**
* Set initial values here.
*/
public static void init() {
EffectMaster.x = 0.34;
}
/**
* Apply effects to the Graphics2D object here.
*/
public static void applyEffects(Graphics2D g) {
//EffectMaster.rotationEffect(g);
}
/**
* A very simple effect that rotates the whole screen continuously.
* @param g
*/
@SuppressWarnings("unused")
private static void rotationEffect(Graphics2D g) {
g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight);
if(EffectMaster.timer == 0 && EffectMaster.percentage < 100) {
EffectMaster.percentage++;
} else if (EffectMaster.timer > 500 && EffectMaster.percentage > 0) {
EffectMaster.percentage--;
} else if (EffectMaster.percentage == 100){
EffectMaster.timer++;
} else if (EffectMaster.percentage == 0) {
EffectMaster.timer--;
}
//EffectMaster.x += 0.005;
g.rotate(EffectMaster.x * EffectMaster.percentage / 100, GameConfig.windowWidth/2, GameConfig.windowHeight/2);
}
}

View File

@ -7,6 +7,7 @@ import de.teamteamteam.spacescooter.brain.Highscore;
import de.teamteamteam.spacescooter.brain.PlayerSession;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.entity.Player;
import de.teamteamteam.spacescooter.fx.EffectMaster;
import de.teamteamteam.spacescooter.gui.HealthBar;
import de.teamteamteam.spacescooter.gui.InterfaceBar;
import de.teamteamteam.spacescooter.gui.ScoreBar;
@ -60,6 +61,7 @@ public class GameScreen extends Screen {
*/
@Override
protected void paint(Graphics2D g) {
EffectMaster.applyEffects(g); //Apply optional effects.
this.entityPaintIterator.reset();
while (this.entityPaintIterator.hasNext()) {
this.entityPaintIterator.next().paint(g);