Computer Science Canada

Cheaply Animated Stick Man

Author:  Leftover [ Sun Nov 14, 2004 11:47 pm ]
Post subject:  Cheaply Animated Stick Man

I know this one had a lot of banging head's in my class, just working out everything properly. It's not beautiful, but it gets out the general message, and a lot of my friends were looking for the example, so here it is. Lot's of documentation because we get marked on that too Smile

code:

setscreen ("graphics:800;155,nobuttonbar") % Get rid of the button bar and set a reasonable workspace for the stickman to move

var fr1, fr2 : int

% Frame 1
Draw.Line (10, 1, 25, 50, 255) % Left Leg
Draw.Line (40, 1, 25, 50, 255) % Right Leg
Draw.Line (25, 50, 25, 100, 255) % Torso
Draw.Line (10, 75, 40, 100, 255) % Arms
Draw.FillOval (25, 125, 25, 25, 255) % Head

fr1 := Pic.New (0, 0, 125, 150) % Capture picture for use later
Draw.Cls % Clear and start drawing next

% Frame 2
Draw.Line (25, 1, 25, 50, 255) % Left Leg
Draw.Line (25, 1, 25, 50, 255) % Right Leg
Draw.Line (25, 50, 25, 100, 255) % Torso
Draw.Line (10, 100, 40, 75, 255) % Arms
Draw.FillOval (25, 125, 25, 25, 255) % Head

fr2 := Pic.New (0, 0, 125, 150) % Capture picture for use later
Draw.Cls % Clear and make way for animation

% Animate the frames to make the stick man move across the screen

loop
    for i : 0 .. 750 by 25
        Pic.Draw (fr1, i, 0, picCopy)
        Time.Delay (100)
        Pic.Draw (fr2, i, 0, picCopy)
        Time.Delay (100)
        Draw.Cls
    end for
   
% Animate the frames to make the stick man move back to where he started

    for decreasing i : 750 .. 0 by 25
        Pic.Draw (fr1, i, 0, picCopy)
        Time.Delay (100)
        Pic.Draw (fr2, i, 0, picCopy)
        Time.Delay (100)
        Draw.Cls
    end for

end loop


Edit: My bad, attached it now too.

Author:  cool dude [ Mon Nov 15, 2004 5:14 pm ]
Post subject: 

not bad. i made one like that before accept i made the stick man bounce all over the screen. lol.

Author:  zomg [ Tue Nov 16, 2004 11:47 am ]
Post subject: 

thats pretty i had to make something like in grade 10 lol i only got 52%

cuz i used pic.screenload o well

Author:  Viper [ Mon Nov 22, 2004 1:14 pm ]
Post subject: 

lol it look funny


: