@Override
  public void render(GameContainer container, Graphics g) throws SlickException {
    sheet1.startUse();

    sheet1.renderInUse(50, 50, 0, 0);
    sheet1.renderInUse(100, 50, 1, 2);
    sheet1.renderInUse(150, 50, 64, 64, 1, 2);
    sheet1.renderInUse(250, 50, 64, 64, rot1, 1, 2); // rotates around top left
    sheet1.renderInUse(350, 50, 64, 64, rot2, 3, 2); // rotates around top middle
    sheet1.renderInUse(450, 50, rot1, 4, 4); // default; rotates around center

    sheet1.renderInUse(250, 50, 64, 64, rot1, 1, 2);

    sheet1.endUse();

    sheet2.startUse();
    subImage.drawEmbedded(100, 200, subImage.getWidth(), subImage.getHeight(), rot1);
    subImage.drawEmbedded(300, 200, subImage.getWidth() * 4f, subImage.getHeight() * 2f, rot2);
    sheet2.endUse();
  }
Exemple #2
0
  /**
   * Render the particles in the system
   *
   * @param x The x coordinate to render the particle system at (in the current coordinate space)
   * @param y The y coordinate to render the particle system at (in the current coordiante space)
   */
  public void render(float x, float y) {
    if ((sprite == null) && (defaultImageName != null)) {
      loadSystemParticleImage();
    }

    if (!visible) {
      return;
    }

    GL.glTranslatef(x, y, 0);

    if (blendingMode == BLEND_ADDITIVE) {
      GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE);
    }
    if (usePoints()) {
      GL.glEnable(SGL.GL_POINT_SMOOTH);
      TextureImpl.bindNone();
    }

    // iterate over all emitters
    for (int emitterIdx = 0; emitterIdx < emitters.size(); emitterIdx++) {
      // get emitter
      ParticleEmitter emitter = (ParticleEmitter) emitters.get(emitterIdx);

      // check for additive override and enable when set
      if (emitter.useAdditive()) {
        GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE);
      }

      // now get the particle pool for this emitter and render all particles that are in use
      ParticlePool pool = (ParticlePool) particlesByEmitter.get(emitter);
      Image image = emitter.getImage();
      if (image == null) {
        image = this.sprite;
      }

      if (!emitter.isOriented() && !emitter.usePoints(this)) {
        image.startUse();
      }

      for (int i = 0; i < pool.particles.length; i++) {
        if (pool.particles[i].inUse()) pool.particles[i].render();
      }

      if (!emitter.isOriented() && !emitter.usePoints(this)) {
        image.endUse();
      }

      // reset additive blend mode
      if (emitter.useAdditive()) {
        GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE_MINUS_SRC_ALPHA);
      }
    }

    if (usePoints()) {
      GL.glDisable(SGL.GL_POINT_SMOOTH);
    }
    if (blendingMode == BLEND_ADDITIVE) {
      GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE_MINUS_SRC_ALPHA);
    }

    Color.white.bind();
    GL.glTranslatef(-x, -y, 0);
  }