Recently, I have been thinking about a hangout game, not really need to go into detail, because I am focusing on creating the engine itself. Basically just to make my brain not hurt while making the core game altogether.

I found a little problem, though.

Whenever I have two sprites EXACTLY next to each other, there's a weird small gap between them.

Here's a picture:

enter image description here

Here's another picture with the background white instead of black (eye strain warning for those dark mode users lol):

enter image description here

As you can see, there's a tiny little gap between the sprites.

I know a very simple and easy solution would just be to subtract the position by like one pixel, but it kind of ticks me off that it's not evenly spaced.

Here's my code containing the sprites and the rendering:

    public static void render() {
        test.setSpriteX(test2.getSpriteX() + 125f);
    public static void update() {

        test2 = new Sprite(-50, 0, new SpriteTexture[] {new SpriteTexture("res/Tileset/wood.png")}, 0.1f, 125, 125, 100, false, true, "center");
        test = new Sprite(-50, 0, new SpriteTexture[] {new SpriteTexture("res/Tileset/wood.png")}, 0.35f, 125, 125, 100, true, true, "center");
        button = new Sprite(0, 0, new SpriteTexture[] {new SpriteTexture("res/buttonplacehold/button_trig_1.png")}, 0.0f, 125, 125, 100, false, true, "center");
        Logo = new Sprite(0, 0, new SpriteTexture[] {}, 0.35f, 250, 250, 100, true, false, "center");
        T = new Sprite(0, 0, new SpriteTexture[] {}, 0.35f, 50, 50, 100, true, false, "center");
        while (!Display.isCloseRequested()) {
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

You don't need to worry about the button sprite.

public Sprite(float sx, float sy, SpriteTexture[] t, float speed, int w, int h, int dms, boolean isStatic, boolean isDevMode, String o)

where sx is sprite x, sy is sprite y, t is the list of textures for it, speed is just player speed if it's a player, w is width, h is height, dms is delay in milliseconds, isStatic just makes it a player or not, isDevMode just turns on some debugging and fun things, and o is the origin, which isn't even implemented yet or won't be at all.

Hope somebody can help,


Also here are the parameter definitions for the Sprite class, so you don't get mixed up:

  • \$\begingroup\$ LWJGL has no control over rendering sprites, much less the position where those sprites would be rendered on screen … you appear to be using some other classes for actually calculating the positions of your sprites on the screen and rendering them. The bug must be in those classes, which are not part of LWJGL or OpenGL \$\endgroup\$
    – Jan
    Commented Sep 10, 2021 at 14:10

1 Answer 1


Sorry for the late answer. Perhaps OpenGL, your matrix maths library, or your code is exclusive for positions rather than inclusive? As for a fix, as you said, you could just subtract one from the position.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .