@Override public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { int nb = 0; if (server != null) { nb = server.getPartie().size(); g.drawString("Server : ON", 5, 5); } else g.drawString("Server : OFF", 5, 5); g.drawString( "Listes des parties ouvertes : " + nb, shapeListeServers.getX() + shapeListeServers.getWidth() / 2 - container.getDefaultFont().getWidth("Listes des parties ouvertes :" + nb) / 2, shapeListeServers.getY() - container.getDefaultFont().getHeight("Listes des parties ouvertes :" + nb) - 2); g.setDrawMode(Graphics.MODE_COLOR_MULTIPLY); g.setColor(Color.gray); g.fill(shapeListeServers); g.setDrawMode(Graphics.MODE_NORMAL); g.setColor(Color.white); g.draw(shapeListeServers); listeServers.renderString(container, g); butRetour.render(container, g); butCreerServer.render(container, g); super.render(container, game, g); }
private void renderAmmo() { Ammo ammo = ammoMapper.get(player); g.translate(container.getWidth() - 64, container.getHeight() - 45); { font.drawString(-16, 8, "Ammo"); g.rotate(0, 0, -90); float ammoStatus = ammo.getAmmoStatus(); g.setDrawMode(Graphics.MODE_ADD); statusBar.draw( 0, 0, statusBar.getWidth() * ammoStatus, statusBar.getHeight(), 0, 0, statusBar.getWidth() * ammoStatus, statusBar.getHeight(), ammoStatus < 0.25 ? Color.red : ammoStatus < 0.6 ? Color.yellow : Color.green); statusBar.draw( statusBar.getWidth() * ammoStatus, 0, statusBar.getWidth(), statusBar.getHeight(), statusBar.getWidth() * ammoStatus, 0, statusBar.getWidth(), statusBar.getHeight(), new Color(0.15f, 0.15f, 0.15f)); g.setDrawMode(Graphics.MODE_NORMAL); g.rotate(0, 0, 90); } g.translate(-container.getWidth() + 64, -container.getHeight() + 45); }
private void renderHealth() { Health health = healthMapper.get(player); g.translate(35, container.getHeight() - 45); { font.drawString(-26, 8, "Health"); g.rotate(0, 0, -90); float healthStatus = health.getHealthStatus(); g.setDrawMode(Graphics.MODE_ADD); statusBar.draw( 0, 0, statusBar.getWidth() * healthStatus, statusBar.getHeight(), 0, 0, statusBar.getWidth() * healthStatus, statusBar.getHeight(), healthStatus < 0.25 ? Color.red : healthStatus < 0.6 ? Color.yellow : Color.green); statusBar.draw( statusBar.getWidth() * healthStatus, 0, statusBar.getWidth(), statusBar.getHeight(), statusBar.getWidth() * healthStatus, 0, statusBar.getWidth(), statusBar.getHeight(), new Color(0.15f, 0.15f, 0.15f)); g.setDrawMode(Graphics.MODE_NORMAL); g.rotate(0, 0, 90); } g.translate(-35, -container.getHeight() + 45); }
@Override public void draw(GameContainer gc, Graphics g) { g.setDrawMode(Graphics.MODE_ADD); particleEngine.draw(gc, g); g.setDrawMode(Graphics.MODE_NORMAL); if (alive) { image.setCenterOfRotation(image.getWidth() / 2, image.getHeight() / 2); image.setRotation(rotation); // g.setColor(new org.newdawn.slick.Color(0,0,120)); // g.drawRect(position.x, position.y - image.getHeight() / 2, image.getWidth(), // 4); // g.fillRect(position.x, position.y - image.getHeight() / 2, image.getWidth() // * sheld / 100, 4); // g.setColor(new org.newdawn.slick.Color(0, 120, 23)); g.drawRect(position.x, position.y - image.getHeight() / 2 - 6, image.getWidth(), 4); g.fillRect( position.x, position.y - image.getHeight() / 2 - 6, image.getWidth() * hull / 100, 4); // // g.drawRect(position.x + image.getWidth() / 2 - 16, position.y + // image.getHeight() / 2 - 16, 32, 32); g.drawImage(image, position.x, position.y); for (int i = 0; i < 50; i++) { bullet[i].draw(gc, g); } } }
public void setBlendMode(int mode) { oldBlendMode = blendMode; blendMode = mode; GL14.glBlendEquation(GL14.GL_FUNC_ADD); if (mode < 100) { g.setDrawMode(mode); return; } try { Reflection.invokePrivateMethod(mPredraw, g); } catch (Exception e) { App.getApp().handle(e); } gl.glEnable(SGL.GL_BLEND); gl.glColorMask(true, true, true, true); if (mode == BM_ADD || mode == BM_SUBTRACT) { gl.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE); if (mode == BM_SUBTRACT) { GL14.glBlendEquation(GL14.GL_FUNC_SUBTRACT); GL14.glBlendEquation(GL14.GL_FUNC_REVERSE_SUBTRACT); } } try { Reflection.invokePrivateMethod(mPostdraw, g); } catch (Exception e) { App.getApp().handle(e); } }
public void render(Graphics g) { // g.setDrawMode(Graphics.MODE_ADD); for (int i = 0; i < snowFlakes.length; i++) { snowFlakes[i].render(g); if (snowFlakes[i].life == 1) { makeSnow(i, snowLife); } } g.setDrawMode(Graphics.MODE_NORMAL); }
private void drawLight(Entity entity, int lightSize, int x, int y) { Graphics g = container.getGraphics(); ResourceManager manager = ResourceManager.getInstance(); String resName = resourceMapper.get(entity).getResourceName(); Resource res = manager.getResource(resName); Image entityFrame = getFrame(res); int ew = entityFrame.getWidth(); int eh = entityFrame.getHeight(); float invSize = 1f / lightSize; g.clearAlphaMap(); g.scale(lightSize, lightSize); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); Image light = (Image) manager.getResource("light").getObject(); light.drawCentered((x) * invSize, (y) * invSize); g.scale(invSize, invSize); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_DST_ALPHA); g.setColor(new Color(0, 0, 0, 255)); g.fillRect(0, 0, container.getWidth(), container.getHeight()); g.setDrawMode(Graphics.MODE_NORMAL); }