Is there a way for the dapper dasher backgrounds to not transition suddenly

The transition after the end of the two background images that have scrolled is quite sudden. Is there a way for it to be smoother?

Haven’t noticed anything sudden myself, is there a way you can show me what you’re experiencing? Should help me understand the problem.

1 Like

I propably know an answer. I took other window dimension and even when you are choosing another scalling just to fullfill the window you will see the next texture being drawn “suddenly”. I was trying to do this by changing the other values (for example the x position where it is drawn again after reseting the values for vectors) but in my case only chosing “the proper” values for window helped. Maybe there is also a solution in changing the dimensions of textures (using paint for example).

1 Like

I would recommend trying to get the positions and scaling of your background more dynamically and store it in a variable. I used the width of my screen divided by the width of my background to get the amount I need to scale by. This also lets you play around with different screen sizes easily.

Heres my setup for the background rendering.


// background
Texture2D Background{LoadTexture("textures/far-buildings.png")}; // Background texture
float BackgroundX{}; // Background screen position
int BackgroundVelocity{50}; // speed the background moves
float BackgroundScale{windowDimensions[0] / Background.width}; // scale the background image up to fill the screen

while (!WindowShouldClose())
{
        BeginDrawing();
        ClearBackground(WHITE);

        // Get deltaTime(Time since last frame)
        float dT{GetFrameTime()};

        // Update background positions
        Vector2 Background1Position{BackgroundX, 0.0};
        Vector2 Background2Position{BackgroundX + (Background.width * BackgroundScale), 0.0};
       
        // Draw new backgrounds 
        DrawTextureEx(Background, Background1Position, 0.0, BackgroundScale, WHITE);
        DrawTextureEx(Background, Background2Position, 0.0, BackgroundScale, WHITE);

        // Get ready to move background next frame
        BackgroundX -= BackgroundVelocity * dT;
        if (BackgroundX <= -Background.width * BackgroundScale)
        {
            BackgroundX = 0.0;
        }
4 Likes

My solution in end the was to just make more copies of the background images instead of just 2 images. There are some great solutions here and I will try it out.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms