gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Drawing smoothly with the stylus

#157832 - Jeremysr - Fri May 30, 2008 5:22 am

I have a loop with
Code:
stylus = touchReadXY();
, but it seems like it only updates every vblank, so when I slide the stylus quickly it only draws a few pixels along the line. How do I make it nice and smooth? PAlib has a function for this but I don't want to use PAlib.
_________________
viewsourcecode

#157833 - eKid - Fri May 30, 2008 5:44 am

What you want to do is draw a line from the previous stylus position to the new stylus position.

Here is a cool algorithm:
http://en.wikipedia.org/wiki/Bresenham's_line_algorithm

#157836 - Jeremysr - Fri May 30, 2008 6:14 am

Thank you, I'll try that. :)
_________________
viewsourcecode