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

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




PostPosted: Sat Dec 15, 2012 3:38 pm   Post subject: Animation

What is it you are trying to achieve?
run multiple animations at once

so basically i have an animation goign but i want to run another animation while this one is running so that hteir working at hte same time, is there a way i can do this? i cant seem to figure it out


Please specify what version of Turing you are using
4.1
Sponsor
Sponsor
Sponsor
sponsor
Panphobia




PostPosted: Sat Dec 15, 2012 3:48 pm   Post subject: RE:Animation

Post your code on here, we need to see the problem first Razz
Insectoid




PostPosted: Sat Dec 15, 2012 3:50 pm   Post subject: RE:Animation

Don't think of it as running multiple animations at the same time, but as one large animation. If that doesn't help, well, I'm trying to dig up a tutorial. I know we've got one somewhere.
bvbjules13




PostPosted: Sat Dec 15, 2012 3:51 pm   Post subject: Re: Animation

Turing:


View.Set ("graphics: 1100, 600")
View.Set ("offscreenonly")

var xx : int
var yy : int


procedure Snow
    xx := Rand.Int (1, 1100)
    yy := 599
    loop
        yy := yy - 1
        Draw.Fill (1, 1, 16, 44)
        Draw.FillOval (xx, yy, 2, 2, 0)
        delay (5)
        View.Update
        Draw.FillOval (xx, yy, 2, 2, 16)
    end loop
end Snow




thats what i have atm, i need to run that a bunch of times; ik that to make snow you normally do it another way but i couldnt figure it out
Panphobia




PostPosted: Sat Dec 15, 2012 3:58 pm   Post subject: RE:Animation

i dont think you need a procedure, but this is what id do, make a loop with a random x than set yy to the same thing within that loop, then make another loop within that loop which exits when y = 0
Insectoid




PostPosted: Sat Dec 15, 2012 3:59 pm   Post subject: RE:Animation

code:
Draw.Fill (1, 1, 16, 44)
        Draw.FillOval (xx, yy, 2, 2, 0)
        delay (5)
        View.Update
        Draw.FillOval (xx, yy, 2, 2, 16)


There's a problem with your draw order, for one thing.

You need at least one X and Y variable per thing that moves (hint: arrays are your friend). For example, here's how you move 2 things at once.

code:

var ball1X : int := 10
var ball1Y : int := 10
var ball2X : int := 10
var ball2Y : int := 10

proc Animate
    ball1X += 1 %move ball1 right
    ball2Y += 1 %move ball2 up
    Draw.FillOval (ball1X, ball1Y, 5, 5, blue)
    Draw.FillOval (ball2X, ball2Y, 5, 5, red)
end Animate

loop
    Animate
end loop


This is 2 animations running at the same time. Or, it's 1 complicated animation.

To animate snow, you'll need hundreds of X and Y variables, but that's way too much code to write. Instead, use an array and a for loop.
Panphobia




PostPosted: Sat Dec 15, 2012 4:01 pm   Post subject: RE:Animation

ohh yea (facepalm) insectoid I did not account for hundreds of snow flakes Razz
bvbjules13




PostPosted: Sat Dec 15, 2012 4:04 pm   Post subject: Re: Animation

oh ok thxs! that makes a lot more sense now; thank you!
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: