My main goal is to draw (or blit) 2D sprites with animations multiple times without overlapping one another. This character's main role in the game is act as a unit that the player can call upon multiple times, so overlapping and erasing a portion of the sprite's bitmap is not a good thing.
Here are some pictures to depict what I meant:
These are two units near each other, and they both can be animated.
This is what happens when they are near each other, when the correct way is to not erase the overlapped portions of the unit.
And here is the drawing code:
@Override public void render(int[] screen) { for (int yy = 0; yy < h; yy++) { int y0 = yy + yPosition; if (y0 > GameComponent.HEIGHT || y0 < 0) continue; for (int xx = 0; xx < w; xx++) { int x0 = xx + xPosition; if (x0 > GameComponent.WIDTH || x0 < 0) continue; int src = (yy + column * 16) * spriteSheetH + (xx + row * 16); int tgt = (y + y0) * GameComponent.WIDTH + (x + x0); int col = this.pixels[src]; if (col != screen[tgt]) screen[tgt] = col; } } }
Any way to fix this? Any tips you can give me? Thanks in advance.