Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have an image, where I have a round soft white feathered ball in the center of it. I plan to use it for my lighting in my 2D game.

I could not find any proper way to drawing lighting with many colors, look at my question here Slick2D/LWJGL Drawing coloured lights problem

However, I did find a way to change the colors of the light, and blend it with OpenGL to the tiled map.

I am just stuck with one problem, when I use Graphics#drawFlash(float, float, float, float, Color) and add an alpha lower than 1.0f, the color will be gone, and the image will go back to it's real color (white ball).

Example when I don't add alpha:

this.lightSurface.drawFlash(x, y, w, h, new Color(55, 14, 255));

img

And examplew when I add an alpha:

this.lightSurface.drawFlash(x, y, w, h, new Color(55, 14, 255, 0.6f));

img

This is my whole draw method:

public void render(GameContainer c, Graphics g) throws SlickException {
    for (int i = 0; i < this.lights.size(); i++) {
        Light light = this.lights.get(i);

        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);


        int w = (int) (this.getWidth() * light.getScale());
        int h = (int) (this.getHeight() * light.getScale());
        int x = (int) (light.getX() - w / 2f);
        int y = (int) (light.getX() - h / 2f);

        this.lightSurface.drawFlash(x, y, w, h, new Color(55, 14, 255, 0.6f));


        this.map.render(g);

        g.setDrawMode(Graphics.MODE_NORMAL);
    }

    g.setDrawMode(Graphics.MODE_NORMAL);
}

this.map.render(g) is just 2 for loops and draw tiles.

Why is it doing that? is there a way to hack around it?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.