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

Username:   Password: 
 RegisterRegister   
 Problem with my animation.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Polar Bear Hustle




PostPosted: Wed Apr 21, 2010 11:49 am   Post subject: Problem with my animation.

I am trying to get user input to create an animation for a oval to fall into that specific place on the x co-ordinate line. The plane made by ovals and the bomb (also an oval) must stay together until the user inputted x coordinate. When that coordinate is reached the oval (bomb) will drop to that x coordinate witha small animation.



My problem is that everything except the dropping of the bomb is working. I can get the user input but the most
I have been able to do is create an oval at the user inputted coordinate. The basic problem is the oval will be lowered however it is still being smeared onto the bottom because it follows the x for making the plane move. The procedure planebomb has the problem. I want the bomb to simply drop and not move at the x that is inputted.

I have tried adding a variable to be similar to the one making the ufo go across the screen however the variable will not allow itself to be manipulated.

Turing:


<setscreen ("graphics:800;600;millions")
setscreen ("graphics")
var i, a, j, h, num: int

proc menu
    put "Where do you want to drop the bomb?"
    get num
end menu

proc drawbackground
    %I is a random x for the base
    randint (i, 100, 600)

    drawfillbox (0, 0, 800, 600, 7)
    drawfillbox (0, 0, 800, 50, 2)
    drawfilloval (30, 370, 50, 50, 31)


    %Base
    drawfillbox (i, 40, i + 40, 80, 72)
    %Top of Base
    drawfillbox (i - 10, 80, i - 10 + 60, 95, 72)


end drawbackground

proc planebomb
    % J is for adjusting the bomb's y axis, a is for the random y for the plane.
    % H is for the new position of the bomb after num is read. B is for the plane going across the screen
    randint (a, 150, 275)
    j := a

    for b : 1 .. 800
        %Plane Body
        drawfilloval (b, a, 30, 7, 14)
        %Top of plane
        drawfilloval (b, a + 2, 7, 10, 14)


        %bomb bomb
        drawfilloval (b, j - 18, 7, 7, 12)
        delay (5)
        %Plane Back part eraser
        drawfillbox (b - 30, a - 30, b + 30, a + 30, 7)
        if b = num then
            drawfilloval (num, 20, 7, 7, 14)

        end if
    end for
end planebomb

loop
    drawbackground
    menu
    planebomb
    cls
end loop


>



I am using Turing version 4.11
Sponsor
Sponsor
Sponsor
sponsor
BigBear




PostPosted: Wed Apr 21, 2010 2:34 pm   Post subject: RE:Problem with my animation.

You have the plane and the bomb being drawn separate.

You want to draw the bomb under the plane if it has not passed over the yellow oval you have drawn.

so if b passes over the bomb draw the yellow otherwise draw it with the plane

Turing:
%bomb bomb
        drawfilloval (b, j - 18, 7, 7, 12)
        delay (5)
        %Plane Back part eraser
        drawfillbox (b - 30, a - 30, b + 30, a + 30, 7)
        if b = num then
            drawfilloval (num, 20, 7, 7, 14)

        end if


look at this section here
Polar Bear Hustle




PostPosted: Wed Apr 21, 2010 3:23 pm   Post subject: Re: Problem with my animation.

New turing working turing code. Now that the bomb is removed from the plane and dropped to it's spot I need assistance with making an "eraser" for the streak the dropping animation causes.

Turing:

proc planebomb
    % J is for adjusting the bomb's y axis, a is for the random y for the plane.
    % H is for the new position of the bomb after num is read. B is for the plane going across the screen
    randint (a, 150, 275)
    j := a
   
    for b : 1 .. 800
        %Plane Body
        drawfilloval (b, a, 30, 7, 14)
        %Top of plane
        drawfilloval (b, a + 2, 7, 10, 14)

   
       delay (5)
%Plane Back part eraser
drawfillbox (b - 30, a - 30, b + 30, a + 30, 7)
 for decreasing h: j .. 20

 %If you haven't gone past the num
 if b >= num then
%Bomb eraser
drawfillbox ( num-15,h-9, num+15, h+9, 7)
 drawfilloval (num, h, 7, 7, 12)
%After the num

else

%bomb bomb
drawfilloval (b, j - 18, 7, 7, 12)

end if
 
end for
    end for
end planebomb


That h variable is for the dropping animation.
BigBear




PostPosted: Wed Apr 21, 2010 5:35 pm   Post subject: RE:Problem with my animation.

Why do you even have h if I get rif of that for loop and the -h +h it seems to work fine
Polar Bear Hustle




PostPosted: Wed Apr 21, 2010 6:00 pm   Post subject: Re: Problem with my animation.

So how do you make the loop lower the bomb gradually to (num, 20)?
BigBear




PostPosted: Wed Apr 21, 2010 6:36 pm   Post subject: RE:Problem with my animation.

you can do that in the same for loop

since you want to do both at the same time and not get stuck in one for loop

you can make another loop controlled variable h if you want and increment it every iteration
Polar Bear Hustle




PostPosted: Wed Apr 21, 2010 6:40 pm   Post subject: Re: Problem with my animation.

Is the loop located within the same procedure as all the drawing? If so, right before or after the if statement?
BigBear




PostPosted: Wed Apr 21, 2010 7:07 pm   Post subject: Re: Problem with my animation.

Turing:
for b : 1 .. 800 %loop starts here
        %Plane Body
        drawfilloval (b, a, 30, 7, 14)
        %Top of plane
        drawfilloval (b, a + 2, 7, 10, 14)


        delay (5)
        %Plane Back part eraser
        drawfillbox (b - 30, a - 30, b + 30, a + 30, 7)


        %If you haven't gone past the num
        if b >= num then
            %Bomb eraser
            drawfillbox (num - 15, 9, num + 15, 9, 7)
            drawfilloval (num, 9, 7, 7, 12)
            %After the num

        else

            %bomb bomb
            drawfilloval (b, j - 18, 7, 7, 12)

        end if


    end for%loop ends here
Sponsor
Sponsor
Sponsor
sponsor
Polar Bear Hustle




PostPosted: Wed Apr 21, 2010 7:43 pm   Post subject: Re: Problem with my animation.

The loop makes the overall animation neater however, Im trying to achieve a dropping animation similar to the animation of the plane I have. The h is there so that the bomb will drop from it's point to another point when the user number is reached. My problem is that the bomb doesn't stop "bouncing" in its spot. I have created a drawfillbox around the bomb that is the same colour as the background so that the additional copies of the bomb are erased. I don't understand why it is bouncing.
BigBear




PostPosted: Wed Apr 21, 2010 8:10 pm   Post subject: RE:Problem with my animation.

You could proceed as usual until the bomb and plane are within a certain amount of pixels ten start to move the bomb down towards the target location.
ProgrammingFun




PostPosted: Wed Apr 21, 2010 8:11 pm   Post subject: Re: Problem with my animation.

Polar Bear Hustle @ Wed Apr 21, 2010 7:43 pm wrote:
I don't understand why it is bouncing.


You need more explosive and less rubber Mr. Green ...

Sorry for the completely off-topic post tho.
Polar Bear Hustle




PostPosted: Wed Apr 21, 2010 8:28 pm   Post subject: Re: Problem with my animation.

ProgrammingFun @ Wed Apr 21, 2010 8:11 pm wrote:
Polar Bear Hustle @ Wed Apr 21, 2010 7:43 pm wrote:
I don't understand why it is bouncing.


You need more explosive and less rubber Mr. Green ...

Sorry for the completely off-topic post tho.


Im frequently finding cool effects to add to this program even when I don't want them. Like earlier I found how I could make a giant laserbeam come from my ufo and take out everything as it flies. Not really the point of my game. After removing my "eraser" I don't think it is bouncing as much as the screen is just clipping from all the drawing now I have read a little bit on View.Set things however Im not totally sure where to set the offscreenonly. This is rather irritating considering it seemed so much easier in my head. This bomb just has to have a small animation as the plane flies away. I have the animation however it is just a thick line without the eraser and with the eraser is a flickering bouncing ball.

For now I guess it will have to stay bouncing as I will bug my teacher tommorow about it. Thanks for all the help BigBear.
BigBear




PostPosted: Wed Apr 21, 2010 9:16 pm   Post subject: RE:Problem with my animation.

If your using offscreenonly you have to put View.Update after you update your animation before you cls and make sure to put it after you put text

also with cls you won't need to draw a black spaceship to erase.
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  [ 13 Posts ]
Jump to:   


Style:  
Search: