[CLOSED] Overlapping sprites/surface issue

W

whale_cancer

Guest
Edit: I THINK I see the problem. Need to rework some stuff. Ignore this for now.

I have a system where I take 128x128 backgrounds, place them on surfaces, and chop those surfaces up into sprites which are assigned to buttons. These buttons are settings for the brush in my map editor. So far, this has been going perfectly. However, now that I am using backgrounds that have some transparent pixels, it is obvious that the backgrounds are actually stacking on top of each other on the surface OR something weird is going on with when I turn them into sprites.

You can see what I mean in this image (I have navigated my view to outside of my normal view where my buttons are located). The green bits in the dirt tiles are from the previous group of grass tiles. I've tested this in other spots (you can see the white oval from another test).



It seems like the surface is never being deleted and new backgrounds are just being drawn over top of the old ones? Am I not properly freeing the surface? Is it how I use my tileSprites[w, h] array?

Here is the script I use to generate my groups of buttons:

EDIT: Slight code update, same problem.
Code:
//Generate a Single PPU Table
for (w = 0; w < 8; w += 1)
{
    for (h = 0; h < 8; h += 1)
    {
        ppu_table[w, h] = 0;
    }
}

surface = surface_create(1024, 1024);
surface_set_target(surface);
draw_clear_alpha(c_black, 0);
draw_background(argument0, 0, 0);

//create sprites and assign them to the correct position in tileSprites
for (w = 0; w < 8; w += 1)
{
    for (h = 0; h < 8; h += 1)
    {
        ppu_table[w, h] = sprite_create_from_surface(surface, w * 16, h * 16, 16, 16, false, false, 0, 0);
    }  
}

ppu_nameTable = background_create_from_surface(surface, 0, 0, 1024, 1024, false, false);

surface_reset_target();
surface_free(surface);

for (w = 0; w < 8; w += 1)
{
    for (h = 0; h < 8; h += 1)
    {
        with instance_create(room_width + 160 + (w * 16) + argument1, (h * 16) + argument2, obj_tileBrush)
        {
            sprite_index = other.ppu_table[other.w, other.h];
            brush_background = argument0;
            brush_left = other.w * 16;
            brush_top = other.h * 16;
            //brush_depth = 1000000;
            //show_debug_message('creating button at ' + string(x) + ',' + string(y) + ' with sprite_index ' + string(sprite_index))
        }
    }  
}
I'm at a total loss here.

EDIT: When I actually _use_ the brush, which grabs the top, left, and background values from my brush palette buttons, they paint onto my map properly without the overlap effect.
 
Last edited:
R

RealsLife

Guest
Ugh it's confusing I don't understand what you mean after you start showing your image :x.
 
Last edited by a moderator:
Top