Original Post
I`m using SDL\OpenGL in C++, and the task is to render an array of objects, that will move in column one after another, in the straight line.
So, my curret code:
I will skip all initialization, so that i need only the idea how to realise this
I have an idea, but it`s need to be improved
The problem of this loop - when it goes to another object, the previous object stoppes, becouse we started to operate with another one.
Sorry, It
Will be waiting for some ideas.s.
So, my curret code:
I will skip all initialization, so that i need only the idea how to realise this
struct object
{
//Elements are used for x and y position of an object and its width and height
float x = 0;
float y = 200;
float width = 40;
float height = 40;
};
int const objects = 20;
object array[objects];
for ( int n = 0; n <= objects; n++)
{
array[n].x+=0.02; // current 'n' object will move for 0.02 pixels left
// but this loop moves all objects together, and i need to move them one after another
}
I have an idea, but it`s need to be improved
while( n <= objects)
{
array[n].x+=0.02;
if(array[n] == 41) // if current object is situated in 41 pixel, we will go to another object 'n+1'
n++;
}The problem of this loop - when it goes to another object, the previous object stoppes, becouse we started to operate with another one.
Sorry, It
s rather complicated to introduce and my english isnt so good, but if you have read and understand all of this, huge Thanks to you.Will be waiting for some ideas.s.