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
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
pwnapple




PostPosted: Thu Dec 29, 2005 4:53 pm   Post subject: animation

i'm working on this thing and i need to know how to make the fish go back and forth, up and down etc.
thx
code:
%Fishy

setscreen ("graphics")
setscreen ("offscreenonly")

const midy := maxy div 2

%--------
%FISHY
%--------

procedure drawFish
    %Generate the fish
    drawarc (100, midy, 40, 20, 225, 135, 7)    %head
    drawfilloval (125, midy + 5, 3, 3, 7)       %eye
    drawarc (130, midy - 5, 10, 3, 200, 350, 7) %smile

    drawline (72, midy - 15, 20, midy + 15, 7)  %tail bottom
    drawline (72, midy + 15, 20, midy - 15, 7)  %tail top
    drawline (20, midy + 15, 20, midy - 15, 7)  %Tail Back

    drawfill (100, midy, 67, 7)
    drawfill (21, midy, 67, 7)
end drawFish

%-----------
%BACKGROUND
%-----------

procedure drawBackground
    %draw the waterline
    for i : 0 .. (maxx div 20 + 1)
        drawarc (i * 20, midy + 150, 10, 5, 180, 360, 7)
    end for

    drawfill (0, 0, 53, 7)
    drawfill (0, maxy, 101, 7)
end drawBackground

%------------
%Mainline
%------------
drawBackground
drawFish
Sponsor
Sponsor
Sponsor
sponsor
ecliptical




PostPosted: Thu Dec 29, 2005 6:09 pm   Post subject: How so?

Do you need to be able to control the fish with buttons or the mouse?

or

Do you just need to be able to animate the fish?
pwnapple




PostPosted: Thu Dec 29, 2005 6:12 pm   Post subject: (No subject)

just animate the fish Smile
pavol




PostPosted: Thu Dec 29, 2005 6:35 pm   Post subject: (No subject)

the same way you animated the background:
code:
for i : 0 .. (maxx div 20 + 1)
    drawarc (i * 20, midy + 150, 10, 5, 180, 360, 7)
end for


you can animate the fish. just add the value of i (in a for loop) to the x and y coordinates of your shapes.

code:
procedure drawFish
    %Generate the fish
for i : 1 .. 100
    drawarc (100+i, midy, 40, 20, 225, 135, 7)    %head
    drawfilloval (125+i, midy + 5, 3, 3, 7)       %eye
    drawarc (130+i, midy - 5, 10, 3, 200, 350, 7) %smile

    drawline (72+i, midy - 15, 20, midy + 15, 7)  %tail bottom
    drawline (72+i, midy + 15, 20, midy - 15, 7)  %tail top
    drawline (20+i, midy + 15, 20, midy - 15, 7)  %Tail Back

    drawfill (100+i, midy, 67, 7)
    drawfill (21+i, midy, 67, 7)
end for
end drawFish


this is an example in which the fish should move 100 to the right
ecliptical




PostPosted: Thu Dec 29, 2005 6:55 pm   Post subject: (No subject)

I wouldn't suggest using that method... I would rather do it this way...

code:

setscreen ("offscreenonly")
procedure DrawFish (x, y, bodyColor, outlineColor, eyeColor : int)
    drawarc (x + 100, y, 40, 20, 225, 135, 7)  %head
    drawfilloval (x + 125, y + 5, 3, 3, 7)     %eye
    drawarc (x + 130, y - 5, 10, 3, 200, 350, 7) %smile

    drawline (x + 72, y - 15, x + 20, y + 15, 7) %tail bottom
    drawline (x + 72, y + 15, x + 20, y - 15, 7) %tail top
    drawline (x + 20, y + 15, x + 20, y - 15, 7) %Tail Back

    drawfill (x + 100, y, 67, 7)
    drawfill (x + 21, y, 67, 7)

end DrawFish
%Generate the fish
for move_forward : 1 .. 400

    View.Update
    cls
    DrawFish (move_forward, 200, 4, 6, 5)

end for


I hope I haven't given away to much but you seem to have a solid understanding of the draw commands.

If you understand this type of procedure then you should be able to modifiy it enough so that you can edit the bodyColor, outlineColor, and eyeColor of the fish.
pwnapple




PostPosted: Thu Dec 29, 2005 10:18 pm   Post subject: (No subject)

thx for the help BUT
pavols way does not work
and i don't understand eliptical's way Embarassed
chrispminis




PostPosted: Thu Dec 29, 2005 10:50 pm   Post subject: (No subject)

pwnapple, neither pavol nor eliptical gave the full soure code that you need. They simply outlined the logic and basic programming needed. Try to figure out some of it on your own. I was thinking of doing Fishy as well Smile
pwnapple




PostPosted: Thu Dec 29, 2005 11:26 pm   Post subject: (No subject)

oh i see, could you possibly explain it?
Sponsor
Sponsor
Sponsor
sponsor
ecliptical




PostPosted: Thu Dec 29, 2005 11:45 pm   Post subject: (No subject)

pwnapple,
like chrispminis said we just created the outline... and if you don't understand something play with it change things, change them back, check the reference, ask questions...etc.

It's a great way to learn !


And this forum is probably the best place you'll find the best of Turing is here.
ecliptical




PostPosted: Fri Dec 30, 2005 12:01 am   Post subject: (No subject)

Here's how it works....

Lets say I want to draw a circle, not an oval that requires a x Radius and a y Radius just a circle. Currently turing doesn't have a built in "drawcircle"...that sucks... so lets MAKE ONE!

code:

procedure drawcircle
drawoval(maxx div 2, maxy div 2, 50,50,red)
end drawcircle
drawcircle


ok well that works pretty much in the same way that you fish does.
But what if I want to move this circle to draw it in a different location?
Does this mean I have to create a new procedure with a new location ?
NO!

Now some of this code is alright the circle (actually an oval - much like you fish isn't really a fish but a combination of arcs, lines and ovals..) is a circle that is it's perfectly round, so that concept will stay the same.

But we need to be able to draw it at different locations, and while we're at it draw it with different colors too!



code:

procedure drawcircle (x,y,circlecolor:int)
drawoval(x,y,50,50,circlecolor)
end drawcircle
drawcircle(200,100,red)


See what we did?
When we created the procedure we also gave it some values you can change...

So what this procedure is really saying is...

when the "drawcircle" procedure is called get the x,y, and color values from the user of where we draw the oval with a x and y radius of 50.

but of course we won't always want a circle that has a Radius of 50 will we... so lets make some additional changes so we have total control over drawing a circle.

code:

procedure drawcircle (x,y,size,circlecolor:int)
drawoval(x,y,size,size,circlecolor)
end drawcircle
drawcircle(200,100,10,red)


And THAT is all... now I can user drawcircle where ever I have included this procedure.
Mr. T




PostPosted: Fri Dec 30, 2005 12:45 am   Post subject: Alex's Opinion

I've seen an animation like this before on compsci.
I think this code might be stolen.
ecliptical




PostPosted: Fri Dec 30, 2005 10:55 am   Post subject: (No subject)

Or teachers could be handing out similair assignments... i know there are some Turing Teacher guides or something...so lets not assume the worst first.
Saad85




PostPosted: Fri Dec 30, 2005 11:10 am   Post subject: (No subject)

does it really matter if its stolen? hes not trying to take credit for it, hes trying to learn from it
ecliptical




PostPosted: Fri Dec 30, 2005 3:37 pm   Post subject: (No subject)

and the source code to a fish isn't all that of an impressive thing to steal anyway =)
jeo77




PostPosted: Sun Jan 01, 2006 3:13 pm   Post subject: (No subject)

Here's ecliptical's way put into you'r source code, mabey it'll make more sence when you see it there Razz

code:
%Fishy

setscreen ("graphics")
setscreen ("offscreenonly")

const midy := maxy div 2

%--------
%FISHY
%--------

procedure DrawFish (x, y, bodyColor, outlineColor, eyeColor : int)
    drawarc (x + 100, y, 40, 20, 225, 135, 7)  %head
    drawfilloval (x + 125, y + 5, 3, 3, 7)     %eye
    drawarc (x + 130, y - 5, 10, 3, 200, 350, 7) %smile

    drawline (x + 72, y - 15, x + 20, y + 15, 7) %tail bottom
    drawline (x + 72, y + 15, x + 20, y - 15, 7) %tail top
    drawline (x + 20, y + 15, x + 20, y - 15, 7) %Tail Back

    drawfill (x + 100, y, 67, 7)
    drawfill (x + 21, y, 67, 7)

end DrawFish
%Generate the fish


%-----------
%BACKGROUND
%-----------

procedure drawBackground
    %draw the waterline
    for i : 0 .. (maxx div 20 + 1)
        drawarc (i * 20, midy + 150, 10, 5, 180, 360, 7)
    end for

    drawfill (0, 0, 53, 7)
    drawfill (0, maxy, 101, 7)
end drawBackground

%------------
%Mainline
%------------
for move_forward : 1 .. 400

    View.Update
    cls
    DrawFish (move_forward, 200, 4, 6, 5)
    drawBackground
end for
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 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: