iQuality

Members
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

101 Neutral

About iQuality

  • Rank
    Newbie
  1. C++. A loop for rendering array of blocks

    The problem is solved... I use timer. Thanks for attention. The topic may be closed
  2. C++. A loop for rendering array of blocks

    [quote name='Servant of the Lord' timestamp='1345268296' post='4970744'] Are you wanting to move one object, and then a few seconds later, the next object? Are you wanting a delay/pause in time before each object moves? [/quote] Yes, your understand me correctly. But the problem of delay - it`s stoppes all the "game loop", it will just pause for a while all loop, at as a result it would do nothing except of changing the speed of movement. I`ll explain it in code: [CODE]while( n <= objects) { array[n].x+=0.02; SDL_Delay(2000) // the code stoppes for 2 seconds, so the iterations stops too. As a result the 'n = 0' object moves fo "0.02" pixels, //then stoppes for 2 seconds, and after it another 'n = 1'object moves for "0.02" pixels and stoppes. n++; }[/CODE] [quote name='Goran Milovanovic' timestamp='1345267116' post='4970735'] [quote name='iQuality' timestamp='1345257092' post='4970722'] that will move in column one after another [/quote] I think this part needs to be explained in a little more detail. If you want to "see" anything move, you'll have to render your scene after every single displacement. Also, it might help to position your objects in different locations; Right now, they're all initialized to the exact same values, so x and y are set to 0 and 200, respectively. [/quote] Yes, with rendering scenes all correct, the problem is with movement objects, like Goran Milovanovic says, I need a delay after all of my objects. In another word, i`m making like simple "tower defence game", and i need to generate my enemies, that will move in column, without collision.
  3. 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[CODE] 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 } [/CODE] I have an idea, but it`s need to be improved [CODE]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++; }[/CODE] 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 isn`t so good, but if you have read and understand all of this, huge Thanks to you. Will be waiting for some ideas.s.