rain loop

Discussion in 'C++' started by Mike, Apr 28, 2010.

  1. Mike

    Mike Guest

    Hi
    for a rainsimulation i do new drops(class) and set x/y. finally at the
    end of loop I do delete the pointers.
    Now:
    - how could i increase the life span of the drops? Actually they are
    drawn and immediately (loop end?) gone.
    - how to add a trail? i load another image slightly below in y but to
    make it longer(repeate) with wind.
    I don't understand how to shape the loop.
    Many thanks
    Michael
     
    Mike, Apr 28, 2010
    #1
    1. Advertising

  2. Mike

    Mike Guest

    the loop is alike:
    for(int i=0;i<num;i++)
    {
    drops = new droplet
    .........
    if(drops->
    ...........
    // then i tried a fadout before draw but that's not working as
    always new drops at different x/y are created
    FadeOUT();
    }
    //after we are done, clean the mess
    for(drawed=0;drawed<num;drawed++) delete drops

    How should i take it out the loop? I want to show the drops ~2 second
    and fade away
    Thanks
     
    Mike, Apr 28, 2010
    #2
    1. Advertising

  3. Mike

    Mike Guest

    ok now i try without pointers but get:

    cannot convert ‘GLfloat*’ to ‘GLfloat’ for argument ‘1’ to ‘void
    glVertex2f(GLfloat, GLfloat)’

    thanks
     
    Mike, Apr 29, 2010
    #3
  4. On 28 Apr, 11:39, Mike <> wrote:

    > for a rainsimulation i do new drops(class) and set x/y. finally at the
    > end of loop I do delete the pointers.


    which doesn't need dynamic allocation...

    > Now:
    > - how could i increase the life span of the drops?


    don't call delete. I'm serious if calling delete at the end of the
    loop is giving you raindrops the wrong lifetime then move the deletion
    point.

    > Actually they are
    > drawn and immediately (loop end?) gone.
    > - how to add a trail? i load another image slightly below in y but to
    > make it longer(repeate) with wind.
    > I don't understand how to shape the loop.


    we don't know enough about your application/OS/graphics lib. But
    something like this:

    void timerEvent(Time time)
    {
    if (time_to_create_a drop (time))
    add_to_drop_collection (drop_collection, new_drop());

    if (time_to_remove_drops (time))
    remove_old_drops (drop_collection);

    if (time_to_draw (time))
    draw_stuff (drop_collection);
    }
     
    Nick Keighley, Apr 30, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VGltOjouLg==?=

    Loop the loop...

    =?Utf-8?B?VGltOjouLg==?=, Feb 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,385
    Karl Seguin
    Feb 16, 2005
  2. Steven

    while loop in a while loop

    Steven, Mar 24, 2005, in forum: Java
    Replies:
    5
    Views:
    2,238
    Tim Slattery
    Mar 30, 2005
  3. -
    Replies:
    12
    Views:
    696
    Remon van Vliet
    Jun 15, 2005
  4. littlegirl

    rain

    littlegirl, Mar 29, 2006, in forum: C++
    Replies:
    6
    Views:
    554
    Gernot Frisch
    Mar 30, 2006
  5. Isaac Won
    Replies:
    9
    Views:
    382
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page