Re: Silly Scribble Program
- Posted by "Cuny, David" <David.Cuny at DSS.CA.GOV> Nov 16, 1998
- 567 views
I just got around to looking at Hawke's version of TruScribble, and noticed that he made many of the mistakes that I documented in my prior post. Specifically: - not using and_bits to test the mouse state - making the tests mutually exclusive As a result, the code ignores certain mouse events (such as MOVE+LEFT_UP) and continues to draw lines after the mouse has been released. Of course, he could always rewrite TruMouse to return the mouse events as *seperate* events, like I did in the WinLib library I wrote for my version of Scribble. Here's the code with the errors: -- BEGIN SNIPPET OF HAWKE'S CODE -- if event = MOVE then if draw then x = mouse[2] y = mouse[3] drawline(oldx,oldy,x,y) oldx = x oldy = y end if elsif event = LEFT_DOWN then oldx = mouse[2] oldy = mouse[3] draw = TRUE elsif event = LEFT_UP then x = mouse[2] y = mouse[3] draw = FALSE end if -- END SNIPPET OF HAWKE'S CODE -- The corrected version might look something like: -- BEGIN FIXED SNIPPET OF HAWKE'S CODE -- if and_bits( event, MOVE ) then if draw then x = mouse[2] y = mouse[3] drawline(oldx,oldy,x,y) oldx = x oldy = y end if end if if and_bits( event, LEFT_DOWN ) then oldx = mouse[2] oldy = mouse[3] draw = TRUE end if if and_bits( event = LEFT_UP ) then x = mouse[2] y = mouse[3] drawline(oldx,oldy,x,y) draw = FALSE end if -- END FIXED SNIPPET OF HAWKE'S CODE -- -- David Cuny