Computer Science Canada better way than cls? |
Author: | Saad85 [ Thu Jan 05, 2006 3:06 pm ] |
Post subject: | better way than cls? |
k, boredom got the better of me lately, and i decided to program something. well i have run into a problem. my code involves moving particles, and drawn-in lines using the mouse. i have use offscreenonly and cls to get the particles moving, that part works fine. the thing is, whenever it clears screen, it also clears anything that the mouse has drawn. is there any way to fix this so the particles move fine but anything drawn by the mouse stays on screen? |
Author: | Cervantes [ Thu Jan 05, 2006 3:13 pm ] | ||||
Post subject: | |||||
Learn about Flexible Arrays. There's a link to the tutorial in the Turing Walkthrough. You can make a flexible array of two points, like this:
Or better yet,
Failing that, you erase the particles by, after the View.Update but before you modify their position, drawing a circle of the same size in the background colour. However, this isn't foolproof, as when a particle passes over a line, it will erase part of the line. |
Author: | Saad85 [ Fri Jan 06, 2006 2:58 am ] | ||
Post subject: | |||
Cervantes wrote:
i understand everything but that part. also, is there a way i can make lines any shape(squiggles) instead of straight lines or other premade shapes? if not, or if it would lag too much (lag is an issue here) then thats fine, straight lines work fine. other than that, i just have one question. is there any practical way of erasing these lines after they have been created? |
Author: | Cervantes [ Fri Jan 06, 2006 8:54 am ] |
Post subject: | |
Check out the Records and Types Tutorial You could do the squiggly line thing, but it would slow things down somwhat. The easiest way to do it would probably be to make a 2D array of pixels that stretch across the entire Run Window. If you're only drawing in white and black (or any two colours), you could use an array of boolean values. There is a practical way of removing the lines. You just have to remove that element from the flexible array. This is discussed in the Flexible Arrays Tutorial If you're talking about removing the squiggly lines, it's still possible, but you wouldn't be using the 2D array anymore. You'd probably be using a flexible array of.. a flexible array of points. Scratch that: Turing won't let you create flexible arrays within records. |
Author: | Saad85 [ Fri Jan 06, 2006 2:01 pm ] |
Post subject: | |
i get that perfectly now, dont know why i didnt yesterday. guess i was just sleepy. the thing is, the say you said to remove the lines deasn't seem practical. either the user would have to know which line in the array they want to remove (which is just plain mean, seeing as how it is graphical) or i would have to go through every line, and see which one they clicked on, and remove it (waay better) but im not sure how to distinguish between left and right clicks in turing. |
Author: | Saad85 [ Fri Jan 06, 2006 2:03 pm ] |
Post subject: | |
sorry double post, but i cant seem to edit my last one.. anyway, i thought it might help to have the code http://www.compsci.ca/v2/viewtopic.php?p=104405#104405 |