Murga-Projects Forums

Full Version: Timing and drawing ... UPDATED
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

There has been a lot of conversation around timing and drawing ... Use of wait (which isn't at all reliable for timing), and nasty busy loops.

You will also find examples of the socket.sleep function, but this only gives you 1 second intervals ... murgaLua 0.5 will have a propper 1/1000 of a second sleep, and maybe timeouts, but what do you do now ...

Try this (updated draw demo)

delay = 0.1 -- Delay is rounded up to closest 0.2 of a second.
counter = 0

function draw_callback(eventValue)

      -- Linux will SOMETIMES segfault unless we set the display
      -- BEFORE doing any drawing related stuff ...

      -- Linux will segfault unless we set the font before using fl_draw
      fltk.fl_font(fltk.FL_COURIER, 20)
      fltk.fl_draw("this is a test",20,80+counter)

      fltk.fl_loop( 20,20,80+counter,80+counter, 200,0)

      if counter > 120 then counter=2 end


w=fltk:Fl_Window(0,0, 210, 220, "draw demo")

timer = fltk:Fl_Timer(FL_HIDDEN_TIMER, 0,0,0,0,"0")





Now that animation is surely possible, i guess it's time to start playing around with some unnecessary eyecandy =o)

Thanks very much for this.
And thanks in advance for murgaLua.sleep()
Reference URL's