Bladeren bron

More Font constructors

Tankernn 8 jaren geleden
bovenliggende
commit
ef2cb63eee

+ 16 - 0
src/main/java/eu/tankernn/gameEngine/loader/font/Font.java

@@ -18,4 +18,20 @@ public class Font {
 		this.outlineColor = outlineColor;
 	}
 	
+	public Font(FontFamily family, float size, Vector3f color, Vector3f outlineColor) {
+		this(family, size, 0.5f, 0.1f, 0, 0, color, outlineColor);
+	}
+	
+	public Font(FontFamily family, float size, Vector3f color) {
+		this(family, size, color, new Vector3f(0, 0, 0));
+	}
+	
+	public Font(FontFamily family, float size) {
+		this(family, size, new Vector3f(1, 1, 1));
+	}
+	
+	public Font(FontFamily family) {
+		this(family, 1);
+	}
+	
 }

+ 18 - 19
src/main/java/eu/tankernn/gameEngine/particles/ParticleMaster.java

@@ -15,32 +15,30 @@ import eu.tankernn.gameEngine.entities.Camera;
 import eu.tankernn.gameEngine.loader.Loader;
 import eu.tankernn.gameEngine.loader.font.Font;
 import eu.tankernn.gameEngine.loader.font.GUIText;
-import eu.tankernn.gameEngine.loader.font.Word;
 import eu.tankernn.gameEngine.renderEngine.Fbo;
 import eu.tankernn.gameEngine.renderEngine.font.FontRenderer;
 import eu.tankernn.gameEngine.util.DistanceSorter;
 
 public class ParticleMaster {
 	private Loader loader;
-	
-	private Map<ParticleTexture, List<Particle>> particles = new HashMap<ParticleTexture, List<Particle>>();
-	private List<ParticleSystem> systems = new ArrayList<ParticleSystem>();
+
+	private Map<ParticleTexture, List<Particle>> particles = new HashMap<>();
+	private List<ParticleSystem> systems = new ArrayList<>();
 	private ParticleRenderer renderer;
-	private FontRenderer fontRenderer;
-	
+	private FontRenderer fontRenderer = new FontRenderer();
+
 	public ParticleMaster(Loader loader, Matrix4f projectionMatrix) {
 		this.loader = loader;
 		renderer = new ParticleRenderer(loader, projectionMatrix);
-		fontRenderer = new FontRenderer();
 	}
-	
+
 	public void update(Camera camera) {
-		for (ParticleSystem sys: systems) {
-			for (Particle particle: sys.generateParticles()) {
+		for (ParticleSystem sys : systems) {
+			for (Particle particle : sys.generateParticles()) {
 				addParticle(particle);
 			}
 		}
-		
+
 		Iterator<Entry<ParticleTexture, List<Particle>>> mapIterator = particles.entrySet().iterator();
 		while (mapIterator.hasNext()) {
 			Entry<ParticleTexture, List<Particle>> entry = mapIterator.next();
@@ -59,30 +57,31 @@ public class ParticleMaster {
 			if (!entry.getKey().usesAdditiveBlending())
 				DistanceSorter.sort(list, camera);
 		}
-		
+
 		systems.removeIf(ParticleSystem::isDead);
 	}
-	
+
 	public void renderParticles(Camera camera) {
 		renderer.render(particles, camera);
 	}
-	
+
 	@Override
 	public void finalize() {
 		renderer.finalize();
 	}
-	
+
 	public void addTextParticle(String text, Font font, Vector3f position) {
-		
+
 		GUIText guiText = new GUIText(text, font, new Vector2f(0, 0), 1.0f, false);
 		guiText.update(loader);
 		Fbo fbo = new Fbo((int) (100 * font.size), (int) (100 * font.size), 0);
 		fbo.bindFrameBuffer();
 		fontRenderer.render(guiText);
 		fbo.unbindFrameBuffer();
-		addParticle(new Particle(new ParticleTexture(fbo.getColourTexture(), 1, true), position, new Vector3f(0, 0, 0), 0.1f, 4, 0, font.size));
+		addParticle(new Particle(new ParticleTexture(fbo.getColourTexture(), 1, true), position, new Vector3f(0, 0, 0),
+				0.1f, 4, 0, font.size));
 	}
-	
+
 	public void addParticle(Particle particle) {
 		List<Particle> list = particles.get(particle.getTexture());
 		if (list == null) {
@@ -91,7 +90,7 @@ public class ParticleMaster {
 		}
 		list.add(particle);
 	}
-	
+
 	public void addSystem(ParticleSystem system) {
 		this.systems.add(system);
 	}