how to make the flame move like a candle

edited October 2013 in How To...

Hi guys, i'm new to this. could someone help me on how to move the flame side by side like a candle. That is what I've done so far. thankyou.

void setup()
{
size(640,400);
stroke(255);
rect(250,115,60,120);
stroke(0,100,255);
fill(255,120,0);
}

void draw()
{
bezier(260,38,226,169,362,109,254,35);
}

Answers

  • I would try using a sine wave like in this example ( only vertical instead of horizontal ;)

    http://processing.org/examples/sinewave.html

  • seems to be difficult, i dont know which variable to change

  • Answer ✓

    I am not sure what you mean by "side by side".

    What variable to change: try replacing one of the parameters with mouseX or mouseY. These variables change when you move the mouse.

    Simple example to get you started:

    void setup()
    {
      size(640, 400);
      stroke(255);
    }
    
    void draw()
    {
      background(255); // Necessary to see the movement
    
      // Then you have to redraw the candle each time
      rect(250, 115, 60, 120);
    
      stroke(0, 100, 255);
      fill(255, 120, 0);
      bezier(mouseX, 38, 226, 169, 362, 109, 254, 35);
    }
    

    Note: the C button above the textarea allows to format the selected code.

  • thankyou, however it wasn't what i meant but you gave me a good idea using the mouseX command i will try play around with it and try to solve it.

Sign In or Register to comment.