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

Username:   Password: 
 RegisterRegister   
 Drew and animated car, has to drive foreward, flip and back
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Leftover




PostPosted: Sat Nov 13, 2004 12:00 am   Post subject: Drew and animated car, has to drive foreward, flip and back

Ok, I'm sure someone knows here. I'm supposed to draw a car, make it drive forewards, flip, then drive back and loop. Bonus was to make the wheels look like their spinning but I don't really care about that part, I'm sure I could do it but I'm crunched for time. Anyhow, I have the animation going back and forth, but it isn't flipping properly (or rather, I'm not entering the flip commands correctly) and it's frustrating me. Curious if anyone can help? Don't laugh at my ugly retro like car Razz

code:

setscreen ("graphics:800;200,nobuttonbar")

var picture : int

% Body
Draw.FillOval (100, 100, 100, 25, 12)
Draw.FillOval (190, 100, 8, 5, 0)
Draw.FillOval (3, 108, 3, 10, 12)

% Tires
Draw.FillOval (50, 75, 22, 22, 0)
Draw.FillOval (50, 75, 20, 20, 255)
Draw.FillOval (50, 75, 2, 2, 236)
Draw.FillOval (150, 75, 22, 22, 0)
Draw.FillOval (150, 75, 20, 20, 255)
Draw.FillOval (150, 75, 2, 2, 236)

% Cab
Draw.ThickLine (50, 120, 70, 150, 4, 12)
Draw.ThickLine (150, 120, 130, 150, 4, 12)
Draw.ThickLine (130, 150, 70, 150, 4, 12)
Draw.ThickLine (100, 120, 100, 150, 4, 12)
Draw.Line (99, 75, 99, 152, 0)
Draw.FillOval (60, 115, 4, 1, 0)
Draw.FillOval (110, 115, 4, 1, 0)

picture := Pic.New (0, 0, 220, 199)
Draw.Cls

loop
    for i : 0 .. 600 by 10
        Pic.Draw (picture, 0 + i, 0, picCopy)
        Time.Delay (30)
        Draw.Cls
    end for

%had the crappy flipping in right here if that matters any

    for decreasing i : 600 .. 1 by 10
        Pic.Draw (picture, 0 + i, 0, picCopy)
        Time.Delay (30)
        Draw.Cls
    end for
end loop


Anyhow any help would be aprecieated, as it is really stumping me right now. Thanks, Leftover
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Nov 13, 2004 9:18 am   Post subject: (No subject)

code:

picID := Pic.Mirror(picID)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Leftover




PostPosted: Sun Nov 14, 2004 10:56 pm   Post subject: (No subject)

Holy crap tony, you rock. Thanks again bud.
Martin




PostPosted: Mon Nov 15, 2004 7:57 am   Post subject: (No subject)

To make the wheels look like they are moving, draw a line from the middle of each wheel:

Draw.Line (wheelx, wheely, wheelx + wheelradius*cos(theta), wheely + wheelradius*sin(theta), colour)

Then just update theta every frame.
Leftover




PostPosted: Tue Nov 16, 2004 1:09 am   Post subject: (No subject)

Ya lost me on that one Shocked I know I should know that but wow it's too late... Anyhow, I gave it a try, and it worked in my head, but not on turing's screen. Too late to hand er in now, but I'm damn curious to know how to make that work.

I basically drew 1 wheel 4 times (didn't touch second wheel yet) with lines going through them and in order so it will look like its spinning, like:
code:
| / - \ |


It kinda worked, but not really...

code:

setscreen ("graphics:800;200,nobuttonbar")

var picture, fr1, fr2, fr3, fr4 : int

Draw.FillOval (50, 75, 22, 22, 0)
Draw.FillOval (50, 75, 20, 20, 255)
Draw.FillOval (50, 75, 2, 2, 236)
Draw.Line (50, 55, 50, 95, 0)

fr1 := Pic.New (50, 55, 95, 95)
Draw.Cls

Draw.FillOval (50, 75, 22, 22, 0)
Draw.FillOval (50, 75, 20, 20, 255)
Draw.FillOval (50, 75, 2, 2, 236)
Draw.Line (30, 55, 70, 95, 0)

fr2 := Pic.New (50, 55, 95, 95)
Draw.Cls

Draw.FillOval (50, 75, 22, 22, 0)
Draw.FillOval (50, 75, 20, 20, 255)
Draw.FillOval (50, 75, 2, 2, 236)
Draw.Line (30, 75, 75, 75, 0)

fr3 := Pic.New (50, 55, 95, 95)
Draw.Cls

Draw.FillOval (50, 75, 22, 22, 0)
Draw.FillOval (50, 75, 20, 20, 255)
Draw.FillOval (50, 75, 2, 2, 236)
Draw.Line (30, 95, 70, 55, 0)

fr4 := Pic.New (50, 55, 95, 95)
Draw.Cls

% Body
Draw.FillOval (100, 100, 100, 25, 12)
Draw.FillOval (190, 100, 8, 5, 0)
Draw.FillOval (3, 108, 3, 10, 12)

% Cab
Draw.ThickLine (50, 120, 70, 150, 4, 12)
Draw.ThickLine (150, 120, 130, 150, 4, 12)
Draw.ThickLine (130, 150, 70, 150, 4, 12)
Draw.ThickLine (100, 120, 100, 150, 4, 12)
Draw.Line (99, 75, 99, 152, 0)
Draw.FillOval (60, 115, 4, 1, 0)
Draw.FillOval (110, 115, 4, 1, 0)

picture := Pic.New (0, 0, 220, 199)
Draw.Cls

loop
    for i : 0 .. 600 by 10
        Pic.Draw (picture, 0 + i, 0, picCopy)
        Pic.Draw (fr1, 0 + i, 0, picCopy)
        Draw.Cls
        Pic.Draw (fr2, 0 + i, 0, picCopy)
        Draw.Cls
        Pic.Draw (fr3, 0 + i, 0, picCopy)
        Draw.Cls
        Pic.Draw (fr4, 0 + i, 0, picCopy)
        Draw.Cls
        Time.Delay (20)
        Draw.Cls
    end for

    picture := Pic.Mirror (picture)

    for decreasing i : 600 .. 0 by 10
        Pic.Draw (picture, 0 + i, 0, picCopy)
        Pic.Draw (fr1, 0 + i, 0, picCopy)
        Draw.Cls
        Pic.Draw (fr2, 0 + i, 0, picCopy)
        Draw.Cls
        Pic.Draw (fr3, 0 + i, 0, picCopy)
        Draw.Cls
        Pic.Draw (fr4, 0 + i, 0, picCopy)
        Draw.Cls
        Time.Delay (20)
        Draw.Cls
    end for

    picture := Pic.Mirror (picture)

end loop
Viper




PostPosted: Fri Nov 26, 2004 3:34 pm   Post subject: (No subject)

check out ma truck in the submissions page i got spinners on it <Ma pimpin truck>
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  [ 6 Posts ]
Jump to:   


Style:  
Search: