Computer Science Canada Moving Images |
Author: | oopsidoodles [ Thu Mar 13, 2014 12:06 pm ] | ||
Post subject: | Moving Images | ||
For the past while I have been trying to move an image (a jpeg) and I have been 50% successful. The image does move, which is what I want, but the previous copy of the image stays there, so you have the same image copying itself over a bunch of times. Nothing I tried seems to work. I tried using Pic.Free and even using cls (cleared entire screen as expected), but nothing seems to work.
Any help would be greatly appreciated, thanks. This is a very annoying issue and I'd really like to finally be able to fix it. EDIT: I did actually fix this, by clearing everything, then redrawing the background with the image, but if it's possible I'd rather just redraw the image as redrawing everything seems like an ugly way to fix the problem. |
Author: | evildaddy911 [ Thu Mar 13, 2014 2:28 pm ] | ||
Post subject: | RE:Moving Images | ||
despite seeming ugly, thats the best way to solve the problem. there is another way to do it: draw a box over the picture, then redraw. you would need to track where the mouse was last frame, draw a box the size of the picture at those coordinates (covering the pic), then redrawing the picture. Your update() would look like
|
Author: | Raknarg [ Thu Mar 13, 2014 3:33 pm ] | ||
Post subject: | RE:Moving Images | ||
The best way is to clear the screen and redraw everything. It's simple and makes the most sense. Maybe it seems ugly when you have one thing to redraw, but what if you have 500 things to redraw or more? It's more efficient to just clear your entire screen.
Now no matter how many items you have, the whole thing is reset by three easy lines of code at the end of the loop. |