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

Username:   Password: 
 RegisterRegister   
 Help! Newbie question! Put two animation in one Execution windows!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Wreathe




PostPosted: Tue Mar 29, 2011 6:37 pm   Post subject: Help! Newbie question! Put two animation in one Execution windows!

What is it you are trying to achieve?
Display two animation in one execution windows


What is the problem you are having?
Either one or the other animation stops while the other moves! I want both to move at once!


Describe what you have tried to solve this problem
I moved the second animation's code everywhere but still didn't work!


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
-----First Code-----
View.Set ("offscreenonly")


var x,y : array 1 .. 400 of int


for snow : 1 .. 400
x (snow) := Rand.Int (0, maxx)
y (snow) := Rand.Int (0, maxy)
end for
loop

Draw.FillBox (0, 0, maxx, maxy, black)

for snow : 1 .. 400

y (snow) -= Rand.Int (1, 5)

if y (snow) < 0 then
y (snow) := maxy
y (snow) := Rand.Int (0, maxx)
end if
Draw.FillOval (x (snow), y (snow), 1, 1, white)
end for

View.Update
delay (25)
end loop


-------Second Code---------


drawfillbox (1, 1, maxx, maxy, black)

setscreen ("offscreenonly")
for i : 1 .. 225
drawfilloval (i + i, i + i, i, i, white)
View.Update
delay (50)
drawfilloval (i + i, i + i, i, i, black)
end for


Turing:


<Add your code here>



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Mar 29, 2011 7:24 pm   Post subject: RE:Help! Newbie question! Put two animation in one Execution windows!

How does a loop (regular loop and for-loop) work? They run the code on the inside, until the loop exists.

This should explain why the execution never gets to the second part (loop never exists), and hopefully an idea of what needs to be done.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
goroyoshi




PostPosted: Tue Mar 29, 2011 8:04 pm   Post subject: Re: Help! Newbie question! Put two animation in one Execution windows!

try using fork and processes to get them both at the same time
Tony




PostPosted: Tue Mar 29, 2011 8:07 pm   Post subject: Re: Help! Newbie question! Put two animation in one Execution windows!

goroyoshi @ Tue Mar 29, 2011 8:04 pm wrote:
try using fork and processes to get them both at the same time

That's not at all what I was going for.

Besides, processes are guaranteed to not work correctly with offscreenonly.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
goroyoshi




PostPosted: Tue Mar 29, 2011 8:09 pm   Post subject: Re: Help! Newbie question! Put two animation in one Execution windows!

ya i just tried the second animation went all flashy
Wreathe




PostPosted: Wed Mar 30, 2011 7:44 am   Post subject: RE:Help! Newbie question! Put two animation in one Execution windows!

Tony, Even i put my second code inside the "End Loop" of the first code, some other damn error happens! Or you mean, i have to add another loop? If so, please show me where and how!
Raknarg




PostPosted: Wed Mar 30, 2011 8:48 am   Post subject: RE:Help! Newbie question! Put two animation in one Execution windows!

you only need one loop for this program. Instead of using i for your x and y, set those outside your loop and change them on the inside. You have two separate loops; it will only show one thing at a time. If you use one loop, they will work at the same time.
I'll refrain from giving code from fear of losing bits from tony Razz
Tony




PostPosted: Wed Mar 30, 2011 1:43 pm   Post subject: RE:Help! Newbie question! Put two animation in one Execution windows!

om nom nom nom bits.

@Wreathe -- what kind of an error? How do you think it could be fixed?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: