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

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




PostPosted: Wed Jan 07, 2009 1:25 pm   Post subject: animation question

how do you make objects go down or up?
Sponsor
Sponsor
Sponsor
sponsor
Laplace's Demon




PostPosted: Wed Jan 07, 2009 1:37 pm   Post subject: Re: animation question

Is your object a sprite? Or is it drawn with something like drawfillbox?
asianrandy




PostPosted: Wed Jan 07, 2009 1:42 pm   Post subject: RE:animation question

drawfillbox
Laplace's Demon




PostPosted: Wed Jan 07, 2009 2:03 pm   Post subject: Re: animation question

ok, if your using drawfillbox you should do it like this:

You need to keep an X and a Y variable for your box, when you draw the box use the X and Y variables.

ie: drawfillbox (x, y, x+50, y+50, black)

So in your loop, you want to use something to alter the X and Y values, you can do this with a set script, or you can use input such as Input.KeyDown.

After you change the X and Y variables you then want to use cls to clear the screen and therefore destroy the old box. After you cls you then want to draw the box again based on the new x and y values.

in pseudocode:

loop

draw the box
change x and y values
delay
cls

end loop

You can change up the order in which you do things...but that is the bare bones basic way to move an "object".
asianrandy




PostPosted: Wed Jan 07, 2009 7:12 pm   Post subject: RE:animation question

There one more question?

when the transformer stops moving, i want to move this arm down, then i have to use
code:
cls
is their another way. i dont wanna write the transformer.

code:
% Randy Phalla TIK 20 - Computer and Information Science Culminating Activity
setscreen ("graphics:1010;670")
View.Set ("offscreenonly")
var background : int;

background := Pic.New (0, 0, maxx, maxy)
for i : 0 .. 50
    cls
    Pic.Draw (background, 0, 0, picCopy)
    %Transfomer
    drawfillbox (800 -i * 2, 300, 670 - i * 2, 500, red)     %body
    drawfillbox (540 -i * 2, 470, 670 - i * 2, 500, blue)     % right arm
    drawfillbox (800 -i * 2, 470, 920 - i * 2, 500, blue)     % left arm
    drawfillbox (770 -i * 2, 570, 700 - i * 2, 500, black)     % Head
    drawfillbox (770 -i * 2, 600, 790 - i * 2, 500, blue)     % ears
    drawfillbox (700 -i * 2, 600, 677 - i * 2, 500, blue)     %ears
    drawfillbox (730 -i * 2, 170, 670 - i * 2, 300, blue)     %right leg
    drawfillbox (740 -i * 2, 170, 800 - i * 2, 299, blue)     % left leg
    drawfillbox (770 -i * 2, 575, 700 - i * 2, 571, gray)     %top of the head
    drawfillbox (700 -i * 2, 530, 770 - i * 2, 500, gray)     % Month
    drawfillbox (770 -i * 2, 505, 700 - i * 2, 500, black)
    drawfillbox (770 -i * 2, 510, 700 - i * 2, 515, black)
    drawfillbox (770 -i * 2, 525, 700 - i * 2, 520, black)
    drawfillbox (670 -i * 2, 180, 730 - i * 2, 170, gray)     % left foot
    drawfillbox (740 -i * 2, 180, 800 - i * 2, 170, gray)     % left foot
    View.Update
    delay (1)
 

end for
Laplace's Demon




PostPosted: Wed Jan 07, 2009 7:47 pm   Post subject: Re: animation question

mm...

So at the end of his movement you want him to move his arm?

What I would do it move the cls to the bottom of the for loop (after the delay) and I would put it in an if statement so that when i = 50 it doesn't cls anymore, instead it goes into a special procedure which draws a white box over the old arm then draw the new arm. Try that.
asianrandy




PostPosted: Thu Jan 08, 2009 1:46 pm   Post subject: RE:animation question

yo i cant make his arm go down
asianrandy




PostPosted: Thu Jan 08, 2009 7:33 pm   Post subject: RE:animation question

the code didn't work for moving this arm down, can you put the code for me thanks.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jan 08, 2009 7:58 pm   Post subject: Re: RE:animation question

asianrandy @ Thu Jan 08, 2009 7:33 pm wrote:
can you put the code for me thanks.

No. Things don't work this way.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Laplace's Demon




PostPosted: Thu Jan 08, 2009 8:26 pm   Post subject: Re: animation question

Be more specific. What isn't working with the arm moving? Post your code.
asianrandy




PostPosted: Thu Jan 08, 2009 9:13 pm   Post subject: RE:animation question

when the xtransformer done moving, i want his right arm go down.


code:
% Randy Phalla TIK 20 - Computer and Information Science Culminating Activity
setscreen ("graphics:1010;670")
View.Set ("offscreenonly")
var background : int;

% Background
drawfillbox (0, 0, maxx, maxy, black)

% Field
drawfillbox (1, 150, 1010, 1, red)

% City
drawfillbox (1000, 300, 950, 10, gray)
drawfillbox (880, 300, 830, 10, gray)
drawfillbox (950, 100, 880, 10, gray)

% Windows
drawfillbox (900, 70, 840, 100, yellow)

background := Pic.New (0, 0, maxx, maxy)
for i : 0 .. 50
    cls
    Pic.Draw (background, 0, 0, picCopy)
    %xTransfomer
    drawfillbox (800 - i * 2, 300, 670 - i * 2, 500, red)    %body
    drawfillbox (540 - i * 2, 470, 670 - i * 2, 500, blue)    % right arm
    drawfillbox (800 - i * 2, 470, 920 - i * 2, 500, blue)    % left arm
    drawfillbox (770 - i * 2, 570, 700 - i * 2, 500, black)    % Head
    drawfillbox (770 - i * 2, 600, 790 - i * 2, 500, blue)    % ears
    drawfillbox (700 - i * 2, 600, 677 - i * 2, 500, blue)    %ears
    drawfillbox (730 - i * 2, 170, 670 - i * 2, 300, blue)    %right leg
    drawfillbox (740 - i * 2, 170, 800 - i * 2, 299, blue)    % left leg
    drawfillbox (770 - i * 2, 575, 700 - i * 2, 571, gray)    %top of the head
    drawfillbox (700 - i * 2, 530, 770 - i * 2, 500, gray)    % Month
    drawfillbox (770 - i * 2, 505, 700 - i * 2, 500, black)
    drawfillbox (770 - i * 2, 510, 700 - i * 2, 515, black)
    drawfillbox (770 - i * 2, 525, 700 - i * 2, 520, black)
    drawfillbox (670 - i * 2, 180, 730 - i * 2, 170, gray)    % left foot
    drawfillbox (740 - i * 2, 180, 800 - i * 2, 170, gray)    % left foot
    View.Update
    delay (1)



end for

background := Pic.New (0, 0, maxx, maxy)
for i : 0 .. 50
    Pic.Draw (background, 0, 0, picCopy)

    % Tank
    drawfillbox (60 + i * 1, 20, 140 + i * 1, 4, green)         % bottom Body
    drawfillbox (70 + i * 1, 50, 110 + i * 1, 20, green)         % top
    drawfillbox (70 + i * 1, 50, 150 + i * 1, 40, green)         % Cannon

    % 2 tank
    drawfillbox (400 + i * 1, 83, 300 + i * 1, 100, green)         % Bottom body
    drawfillbox (350 + i * 1, 100, 310 + i * 1, 130, green)         % middle
    drawfillbox (420 + i * 1, 130, 310 + i * 1, 140, green)         % Cannon
    View.Update

    delay (1)

end for



% Tank Lazers
for a : 1 .. 50
    Draw.DashedLine (600, 200, 470, 140, drawDot, yellow)
    delay (1)
    Draw.DashedLine (700, 200, 210, 50, drawDot, yellow)
    delay (1)
    Draw.DashedLine (600, 300, 470, 140, drawDot, red)
    delay (1)
    Draw.DashedLine (700, 300, 210, 50, drawDot, yellow)
    delay (1)
end for



% explosion set 1
for f : 1 .. 10
    delay (1)
    Draw.FillOval (600, 200, 0 + f, 0 + f, brightred)
    delay (1)
    Draw.FillOval (700, 300, 0 + f, 0 + f, brightred)
    delay (1)
    Draw.FillOval (600, 300, 0 + f, 0 + f, brightred)
    delay (1)
    Draw.FillOval (700, 200, 0 + f, 0 + f, brightred)
end for


background := Pic.New (0, 0, maxx, maxy)
for i : 0 .. 50
    Pic.Draw (background, 0, 0, picCopy)

    % Good Tranformer
    drawfillbox (50 + i * 1, 400, 110 + i * 1, 500, gray) % body
    drawfillbox (60 + i * 1, 550, 100 + i * 1, 500, blue) % head
    drawfillbox (60 + i * 1, 500, 50 + i * 1, 550, red)
    drawfillbox (110 + i * 1, 500, 100 + i * 1, 550, red)
    drawfillbox (50 + i * 1, 400, 75 + i * 1, 300, blue) % left leg
    drawfillbox (110 + i * 1, 400, 85 + i * 1, 300, blue) %right leg
    drawfillbox (75 + i * 1, 300, 50 + i * 1, 295, gray) %left foot
    drawfillbox (110 + i * 1, 300, 85 + i * 1, 295, gray) % right foot
    drawfillbox (170 + i * 1, 480, 110 + i * 1, 500, red) % right arm
    drawfillbox (50 + i * 1, 480, 5 + i * 1, 500, red) % left arm
    View.Update
    delay (1)
end for

% Good tranformer lazers
for a : 1 .. 50
    Draw.DashedLine (215, 485, 600, 400, drawDot, gray)
    delay (1)
    Draw.DashedLine (215, 485, 600, 450, drawDot, yellow)
    delay (1)
end for

% explosion set 2 from good tranformer
for f : 1 .. 10
    delay (1)
    Draw.FillOval (600, 400, 0 + f, 0 + f, brightred)
    delay (1)
    Draw.FillOval (600, 450, 0 + f, 0 + f, brightred)
    delay (1)
end for
Laplace's Demon




PostPosted: Thu Jan 08, 2009 10:11 pm   Post subject: Re: animation question

Alright, I just got it working but I'm not gonna post the code.

All you need to do it follow the steps I outlined earlier.

Move the cls to the bottom of your transformer for loop and put it in an if statement so that it will only cls when i is less than fifty. In that same if statement, once i = 50 draw over the old arm with the background color (black) and then simply draw the new arm. 6 lines of code in my variation for the if statement, cls, box over the old arm, and then drawing of the new arm.

Also, for future reference try to be more descriptive with your problems. "how do you make something move" or "I can't change the arm" makes it hard for us to help you.
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  [ 12 Posts ]
Jump to:   


Style:  
Search: