Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 drawing two ovals at the same time
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ddndd




PostPosted: 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 ??
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: 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.
ddndd




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: