First of all, remove all the code that isn’t used (i.e the code that are commented out). It’s easier to read the code without half of it being commented out.
What exactly in your code isn’t working?
If you want scrolling to occur, simply move the camera to the right, at each update.
If you want to delay the scrolling, have a timer counting up (or down) and when it reaches a certain value, set a bool to true.
Check the bool and whenever that bool is true, scroll the camera to the right.
Attached updated code with removed all commented code.main.cpp (13.9 KB)
First I need to open the SDL window With background Color Black.
Based on delay , it will start the image scrolling.
Your comments
If you want scrolling to occur, simply move the camera to the right, at each update. Just open the SDL window only not scrolling.
If you want to delay the scrolling, have a timer counting up (or down) and when it reaches a certain value, set a bool to true.
Check the bool and whenever that bool is true, scroll the camera to the right. Where i have to put the timer part in the source.
Put the timer (i.e a float variable) and the bool at the top of the source code, where you’ve put the variables WindowWidth, WindowHeight, sectionWidth, numSection etc.
Set the float variable to a value, for example 5.0f and then, in the Update function, decrease the float variable.
After that, check if the variable has reached 0.0f, and if that’s the case, set the bool variable to true, which starts the camera scrolling.
your code works perfect. Many Thanks and great Support from you.
How can i retain(without closing) the SDL window for image scrolling 5 rows.
As of now after each row scroll completed SDL window closed, again i am invoking the SDL window for next row.
Update() - Scrolling from Right to Left
UpdateEvenRow() - Scrolling Left to Right.
Why does your window close when the end of the game world is reached? - Actually its not game application i just changed to Image scrolling. We have 5 row of images.
MY application do follows.
Open SDL Window
Based on timer - 1 row image scroll from right to left using update method.
Retain the SDL window without close Based on timer 2 row image scrolling from left to right using UpdateEvenRow method.
Retain the SDL window - 3 row image scrolling from right to left
Similar to 5th row image.
Once 5th row scrolling completed SDL window should be closed.
Then I understand.
You don’t really need a player then, just use a camera and control when it should scroll left and right and also when to move down to the next row of images before the next row scrolling occurs etc.
So the first row should scroll to the right, second row to the left, third to the right and so on?
Will the amount of images per row always be the same or will it vary (for example 4 images on the first row, 6 on the second etc)?
Should the camera smoothly change the row or will it be enough that the camera snaps to the next row when a horizontal scroll is completed?
**First row - Scroll - Right to Left ** Second row - Scroll - Left to Right and so on.
Will the amount of images per row always be the same or will it vary (for example 4 images on the first row, 6 on the second etc)?
– It will vary row by row.
Should the camera smoothly change the row or will it be enough that the camera snaps to the next row when a horizontal scroll is completed? – Once First row completed it will wait for next parameters from user for second row image scrolling.