[CLOSED] Images appearing while using rect()

In my game there are enemies wandering around, their draw() method is simple:

        if(facingRight) {
                    x, y + offsetY, 80, 80);
        } else {
            float tX = -core.camera.x+core.game.width/2f + x;
            float tY = -core.camera.y+core.game.height/2f+ y;
            core.displayBuffer.translate(tX, tY);
            core.displayBuffer.scale(-1, 1);
                    -80, offsetY, 80, 80);

Then when we are going to draw walls, we just draw a coloured rectangle like this:


    if(destroyed) {
        core.displayBuffer.fill(0, 0, 0, 16);
        core.displayBuffer.rect(x, y, w, h);
    } else {
        core.displayBuffer.rect(x, y - WALL_HEIGHT, w, h);
        core.displayBuffer.rect(x, y + h - WALL_HEIGHT, w, WALL_HEIGHT);

But for some reason, the walls have the texture of the enemies? Here’s the loop in which the objects are drawn:

    PMatrix displayMatrix = displayBuffer.getMatrix();
    PMatrix bloomMatrix = bloomLayer.getMatrix();
    PStyle displayStyle = displayBuffer.getStyle();
    PStyle bloomStyle = bloomLayer.getStyle();
    onScreenObjects.forEach(o -> {

Here’s example of the results, red rectangles are around the walls, that are drawn incorrectly.
Also the bullets are flickering for some reason? These 2 bugs don’t appear when I don’t draw the enemies onto the screen (or I draw just rectangles instead), so that means, that the image() is doing something weird in the background?

Ask for additional info if needed!

Nvidia Quadro 4000.
Graphics card driver is from 2016, can’t upgrade it, all other games are working fine tho.


Not sure if this is could be your issue but I’d bet it has something to do with the alpha channel at some point when redrawing your screen.

Hey there!
Could you provide sprites / a dumb down version so we can try it ourselves ? :smiley:

Take a look at the drawing loop (the third long code section). The PStyle gets reset before and after every object so when clearing the screen, the alpha doesn’t matter. The alpha only manipulates the alpha of the wall.

I’m clearing the buffers with .clear() so the alpha matter actually doesn’t matter at all.

1 Like

It will take some times to reproduce it, because the project is like 15k lines of code… But I will try my best, I will post the code here soon.

1 Like

Oh wow ! How about just give us the code with the Sprite ? Aka Just the part which is causing the bugs ?

I will take the whole project and just delete away everything that doesn’t matter, it will not be very small but the problem is… I don’t know where the bug actually is, because there are some post-processing effects and so on.

I will be done in 10 mins I guess…

1 Like

Oh so maybe you should try then locate the bug first ! Did you try stepping with a debugger on potential areas or disabling certain parts to the see doesn’t change anything?

I have tried many things, all post-processing effects are disabled and I have eliminated some stuff more, as you see there are only walls and enemies on the screen.

The only thing that I have found is not drawing enemies fixes the problem :joy:

1 Like

Still haven’t succeeded to reproduce it… I have no idea what causes it, I will try my game on another computer tomorrow, I have to go to sleep soon.

1 Like

Can you make the whole source code available in a github or something ? I be very excited to help !

1 Like

I will need to upload the entire project to github anyways, why not make it public then (temporarly). I will be home in 30 mins or more.

1 Like

Here’s the repository for the project, read the readme.md and it will tell you what to import and how to get it up and running. I’m using IntelliJ but you can use any Java IDE you want (that suits the job).

1 Like

I solved the problem… by accident, I was just rewriting some code and it was gone later when I tested it. I had a translate() that was shifting the view always but it got reset after every frame so I couldn’t see it happening, instead I saw weird glitch that seemed like images were drawn with rect(). I’m not quite sure if that was the solution, maybe there’s something hiding it, but if I see it happening again, I will repost here or make a new thread.

1 Like

Great! Good luck with the project looks great from the picture !

The bug is back… Let’s get back to work :smiley:. I will update the GitHub repository and I will tell what I did for the bug to appear.

My GitHub repository: https://github.com/Matrx007/TheLostBits. It didn’t show up last time when I included it in my reply.

Hooray! I was excited to see what this little beast of a game is ! I will have a look at it and let you know what I find.

Have you found anything? Did you saw the bug? I’m out of ideas…


Solution: https://github.com/processing/processing/issues/5863

My GitHub repo will now be made private!

1 Like