I’m trying to make smooth mouse movements across the screen for a drawing style app. More specifically its a “Powder toy”. What this means is, it draws pixel by pixel so I cant do some line trickery. I was initially thinking of checking mouse down and mouse up then put something in my game “update” loop to make it draw pixels to the screen but that didnt work out when I found I couldn’t directly get the mouse X and mouse Y without the events firing.
So does anyone know a way of smooth mouse movements, the way I have at the moment uses the mousemove event which causes this:
http://img1.uploadscreenshot.com/images/orig/9/26119184415-orig.jpg
(Notice how the pixels are spread apart)
Thank you,
Looks like your doing a world of sand clone so I imagine you need rects. I used Bresenham’s line algorithm to plot the points. Basically
onmousedownit starts painting. Thenonmousemoveit compares the current coordinates with the last coordinates and plots all of the points between.Live Demo