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

Username:   Password: 
 RegisterRegister   
 animation using process
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
starlight




PostPosted: Sun May 29, 2005 10:08 am   Post subject: animation using process

I am trying to do a animation using process. This is my first time using it after i read the tutorial session. This is the code that i came up with. but i don't understand why the screen is keep flickering. Did i did something wrong? Thanks

code:

setscreen("offscreenonly")
var m1,m3:int

process movement
for decreasing m:200..50

cls
m1:=m+100
drawline(m,0,300,m1,black)
delay(50)
View.Update
end for
end movement

process movements
for decreasing m2:100..70
cls
m3:=m2+100
drawline(m2,0,200,m3,black)
delay(50)
View.Update
end for
end movements

fork movement
fork movements
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Sun May 29, 2005 10:28 am   Post subject: (No subject)

The screen keeps flickering because you're updating it at two different times, and clearing it a two different times as well. use a different method, because forking sucks.

Just use 'if' statements to tel the program how long to add to a variable.

for example.



code:

var x,y:int := 0
View.Set("offscreenonly")
loop
    cls
    if x < 200 then
        x+=1
    end if
    if y <400 then
        y+=2
    end if
    drawline(0,50,x,50,black)
    drawline(0,150,y,150,2)
    View.Update
    exit when hasch
    delay(5)
end loop


Or you can create your own delay.
code:

var c1,c2,x,y:int:=0
View.Set("offscreenonly")
loop
    cls
    c1+=1
    if c1 = 5 then %Delay of 25 (5 * delay(5))
        x+=1
        c1:=0 %Reset
    end if
    c2+=1
    if c2= 3 then %Delay of 15 (3 * delay(5))
        y+=1
        c2:=0 %Reset
    end if
    drawline(0,50,x,50,black)
    drawline(0,150,y,150,2)
    View.Update
    exit when hasch
    delay(5)
end loop
starlight




PostPosted: Sun May 29, 2005 10:49 am   Post subject: (No subject)

Thanks for the advice. but our teacher want us to try out the process command. and i think the if statment is better if a line going straight , but it is harder to use if the line changes dirction.. base on ur advice. i change the code and it doesn't flicker anymore. but there is a weird shape that appear at the end of the loop. i am not sure how to get rid of it.
code:

setscreen("offscreenonly")
var m1,m3:int

process movement
for decreasing m:200..50
cls
delay(10)
m1:=m+100
drawline(m,0,300,m1,black)
View.Update
end for
end movement

process movements
for decreasing m2:300..70

delay(10)
m3:=m2+100
drawline(m2,0,400,m3,black)
end for
end movements



fork movement
fork movements


Thanks again
Cervantes




PostPosted: Sun May 29, 2005 12:10 pm   Post subject: (No subject)

That's because the process that has the View.Update and the cls finishes before the other one (less loops to go through). After that's done, it's only the other process that is working, and it doesn't have a cls or View.Update, so you don't see anything for a while until the program finishes, at which point it flips everything to the front buffer (ie. it does a View.Update automatically at the end of the program) so you see this mass of lines that was never cleared.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: