Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of calling circ() function inside display you could call </p> <pre><code>glutIdleFunc(nameOfYourChoice); </code></pre> <p>in your main function after keyboard function. So that function is calling again and again. In the above function (nameOfYourChoice) you can manipulate any variables you want for x's and y's. So in that function you can check if there was a collision between objects and if appear collisions you can "drop" things, in this example boxes, via x's and y's in that function. At the end of that function you have to call </p> <pre><code>glutPostRedisplay(); </code></pre> <p>Now if you want to get those boxes up again you can use timers(also with your time-step) and then after a certain amount of time you can put those boxes up again via x's and y's obviously.For that you also will need bool variables to know if there was a collision.</p> <p>So collision happens:</p> <pre><code>bool flagBox1 = true; </code></pre> <p>time passed:</p> <pre><code>bool flagBox1 = false; //code to put back the dropped object </code></pre> <p>code in (nameOfYourChoice) function:</p> <pre><code>if(flagBox1){ //proceed to your actions... } </code></pre> <p>All those changes you will pass them in your display function as you did for the circ with </p> <pre><code>glTranslatef(box1posX, box1posY, box1posZ); glTranslatef(box2posX, box2posY, box2posZ); glTranslatef(box3posX, box3posY, box3posZ); </code></pre> <p>Then render them.</p> <p>A good practice is to change all your "changeable" variables with a step like a time-step. In that way the hole movement will be depending on that time-step.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload