public void render(GameContainer gc, Graphics g) throws SlickException { // clears g.clear(); // backgrond g.setColor(new Color(103, 194, 240)); g.fillRect(0, 0, MainApp.SCREEN_WIDTH, MainApp.SCREEN_HEIGHT); // compute shift right shiftRight += computeShiftRight(); // draws every object ObjectBoilerplate object; for (int x = 0; x < WORLD_LENGTH; x++) { for (int y = 0; y < WORLD_HEIGHT; y++) { object = tileArray[x][y]; if (object != null) { object.render(shiftRight); g.setColor(Color.red); // g.fillRect(object.rect.getX() - shiftRight, MainApp.SCREEN_HEIGHT - // object.rect.getY(), object.rect.getWidth(), object.rect.getHeight()); } } } // g.setColor(Color.red); // g.fillRect(player.rect.getX() - shiftRight, MainApp.SCREEN_HEIGHT - // player.rect.getY(), player.rect.getWidth(), -player.rect.getHeight()); player.render(shiftRight); }
@Override protected void renderImpl(Graphics graphicContext, Image frameBuffer) { super.renderImpl(graphicContext, frameBuffer); fbGraphics.clear(); fbGraphics.drawImage(frameBuffer, 0, 0); // Player-Glow Post Processing Effect Player player = this.getCurrentPlayer(); if (player != null && Constants.Debug.shadersActive) { // Get Player Position on Screen relative to LOWER left corner float px = player.getData()[Player.X] + player.getData()[Player.CENTER_X] + getData(X); float py = player.getData()[Player.Y] + player.getData()[Player.CENTER_Y] + getData(Y); Color playercol = StateColor.constIntoColor(player.getState().color); Color weaponcol = StateColor.constIntoColor(player.getState().weaponColor); float health = player.getState().health * params.spielerLeuchtstaerke / 10.0f; float ammo = player.getState().ammo * params.waffenLeuchtstaerke / 10.0f; int playerlook = 1; if (player.getState().shootDirection == PlayerActionState.RunLeft) playerlook = -1; // Horizontal Blur Shader.setActiveShader(blur1D); blur1D.initialize(JumpNRun.SCREENWIDTH, JumpNRun.SCREENHEIGHT); fbGraphics.drawImage(frameBuffer, 0, 0); fbGraphics.flush(); // Vertical Blur blur1D.setVertical(); fbGraphics.drawImage(frameBuffer, 0, 0); fbGraphics.flush(); // Draw Glow effects graphicContext.setColor(Color.white); if (params.additiveBlending == true) Shader.activateAdditiveBlending(); Shader.setActiveShader(glowshader); glowshader.setValue("range", params.waffenLeuchtWeite * 10); glowshader.setValue("target", px + 5 * playerlook, py + 40); glowshader.setValue("strength", ammo); glowshader.setValue("playercolor", weaponcol); glowshader.setValue("focus", playerlook * 10.0f / params.waffenLeuchtFocus); graphicContext.drawImage(frameBuffer, 0, 0); Shader.setActiveShader(glowshader2); glowshader2.setValue("range", params.spielerLeuchtWeite * 10); glowshader2.setValue("target", px, py); glowshader2.setValue("strength", health); glowshader2.setValue("playercolor", playercol); glowshader2.setValue("focus", 0); graphicContext.drawImage(frameBuffer, 0, 0); Shader.activateDefaultBlending(); Shader.setActiveShader(null); } }