package shootergame.display.bossbar; import java.util.ArrayList; import shootergame.init.Textures; import shootergame.util.gl.GlHelpers; import shootergame.util.gl.texture.TextureReference; public class BossBars { private static final ArrayList bossbars = new ArrayList(); public static void register(IBossBar bossbar) { bossbars.add(bossbar); } public static void render() { TextureReference health_fg = Textures.UI_HEALTH_FG; TextureReference health_bg = Textures.UI_HEALTH_BG; ArrayList toRemove = new ArrayList(); // Render the boss bars int i = 0; for(IBossBar bossbar : bossbars) { double max_health = bossbar.maxHealth(); double a = 1 - (bossbar.getHealth() / max_health); GlHelpers.begin(); health_bg.texCoord(0, 1); GlHelpers.vertex2(-3.2, 8.5 - i); health_bg.texCoord(0, 0); GlHelpers.vertex2(-3.2, 9.0 - i); health_bg.texCoord(1, 0); GlHelpers.vertex2(3.2, 9.0 - i); health_bg.texCoord(1, 1); GlHelpers.vertex2(3.2, 8.5 - i); health_fg.texCoord(0, 1); GlHelpers.vertex2(-3.2, 8.5 - i); health_fg.texCoord(0, 0); GlHelpers.vertex2(-3.2, 9.0 - i); health_fg.texCoord(1-a, 0); GlHelpers.vertex2(3.2-a*6.4, 9.0 - i); health_fg.texCoord(1-a, 1); GlHelpers.vertex2(3.2-a*6.4, 8.5 - i); GlHelpers.end(); i += 1; if(!bossbar.displayBossBar()) { toRemove.add(bossbar); } } for(IBossBar bossbar : toRemove) { bossbars.remove(bossbar); } } }