drawing two ovals at the same time
Author |
Message |
ddndd
|
Posted: Sat Jan 09, 2010 10:18 pm Post subject: drawing two ovals at the same time |
|
|
hi
im trying to make 2 moving ovals, so far i created them and they are moving but the problem is that they are flashing too much, cuz i used a delay and drew them again in white
code :
var x,y,xx,yy:int
x := maxx div 2
xx := maxx div 2 + 30
y := 100
loop
y += 1
drawfilloval (x,y,10,10,black)
delay (10)
drawfilloval (x,y,10,10,white)
drawfilloval (xx,y,10,10,black)
delay (10)
drawfilloval (xx,y,10,10,white)
end loop
i use turing 4.1
any ideas ?? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TheGuardian001
|
Posted: Sat Jan 09, 2010 10:36 pm Post subject: Re: drawing two ovals at the same time |
|
|
This is where View.Update and offscreenonly comes in handy. It basically combines all of the drawing you do into a single drawing, which is only shown on screen when View.Update is called.
Turing: |
View.Set("offscreenonly") %off screen drawing mode
%all drawing is now drawn off screen until View.Update
%is called.
loop
DRAW_STUFF %offscreen
View.Update %copy everything that was drawn offscreen and
%put it onscreen
cls %clear the offscreen image. Does not affect onscreen image until next View.Update.
end loop
|
Another problem you may run into is that you don't appear to be drawing in the correct order. In your program the flow is:
code: |
loop
Draw_oval_one
clear_oval_one
Draw_oval_two
clear_oval_two
end loop
|
You may wish to consider drawing both ovals one after another without clearing, then clearing them both together, as this will also help the problem.
A note about View.Update: You should only ever be calling this once inside of a loop. The whole point of using View.Update is to reduce flickering by drawing an entire scene in one motion. If you call it more than once in a single loop, you are defeating the purpose of using it in the first place. |
|
|
|
|
![](images/spacer.gif) |
ddndd
|
Posted: Sun Jan 10, 2010 11:05 am Post subject: Re: drawing two ovals at the same time |
|
|
ohh so that is what view. update is for...
thnx ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|