bouncing ball
Author |
Message |
bloodyeric12
|
Posted: Mon May 14, 2012 6:29 pm Post subject: bouncing ball |
|
|
ok so im doing a project at my school , ive done about half of it already. All i need to kno is how i would make a ball starting in the air and make it bounce up and down continously. thx |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Amarylis
|
Posted: Mon May 14, 2012 6:33 pm Post subject: RE:bouncing ball |
|
|
Would you care to tell us any attempts you've had with it so far, or anything regarding it that confuses you? |
|
|
|
|
|
bloodyeric12
|
Posted: Mon May 14, 2012 8:30 pm Post subject: RE:bouncing ball |
|
|
ive only tried the way i have been taught by changing the y so it would seem that the ball is falling but it would then stop and i dunt know how to make it bounce back up and down continously |
|
|
|
|
|
Dreadnought
|
Posted: Mon May 14, 2012 9:11 pm Post subject: Re: bouncing ball |
|
|
Consider giving the ball a speed (say in pixels per frame). Then every time you update the position of the ball (frame) you move it by that many pixels. By making the speed positive or negative you can make the ball move up or down. Try to make it bounce once by changing the speed. Then you can try to think of a way to make it bounce multiple times (if you've taken any physics in high school it could come in handy). |
|
|
|
|
|
bloodyeric12
|
Posted: Tue May 15, 2012 4:57 pm Post subject: Re: bouncing ball |
|
|
this is what i have so far
var x : int
var y : int
var bounce : int := 0
x := 200
y := 250
y := y + 25
loop
bounce := bounce + 1
y := y - 3
for i : 1 .. 200
cls ()
drawfilloval (x, y, 20, 20, 7)
delay (2)
y := y - 1
end for
for i : 1 .. 190
cls ()
drawfilloval (x, y, 20, 20, 7)
delay (2)
y := y + 1
end for
exit when bounce = 5
end loop
i made it bounce 5 times and im supose to make it bounce lower and lower each time like how if you drop a basket ball it will eventually stop bouncing
in my code the ball bounces lower but falls off the screen, and i cant figure out how to make it stay in one place while making the ball drop lower and lower each time |
|
|
|
|
|
QuantumPhysics
|
Posted: Wed May 16, 2012 11:12 am Post subject: RE:bouncing ball |
|
|
draw the oval make a for statement as you did and make it bounce up and down for a period of time and when it gets to the bottom or top make an if statement that loops it again |
|
|
|
|
|
Dreadnought
|
Posted: Wed May 16, 2012 2:44 pm Post subject: Re: bouncing ball |
|
|
You are telling the ball to fall a certain distance each time. The idea should be that the ball moves down until a certain point. Try using an if statement to check if the ball has hit the lowest point. This will stop the ball from "falling off the screen" |
|
|
|
|
|
alicesmith257
|
Posted: Mon Jul 23, 2012 7:37 am Post subject: Re: bouncing ball |
|
|
These things, we need to make Bouncing Ball like borax (found in the laundry section of the store), cornstarch (found in the baking section of the store), white glue (e.g., Elmer's glue - makes an opaque ball) or blue or clear school glue (makes a translucent ball), warm water, food coloring (optional), measuring spoons, spoon or craft stick to stir the mixture, 2 small plastic cups or other containers for mixing. By these things, you can make Bouncing Ball, perfectly.
SNIP |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Beastinonyou
|
Posted: Mon Jul 23, 2012 11:05 am Post subject: Re: bouncing ball |
|
|
alicesmith257 wrote:
These things, we need to make Bouncing Ball like borax (found in the laundry section of the store), cornstarch (found in the baking section of the store), white glue (e.g., Elmer's glue - makes an opaque ball) or blue or clear school glue (makes a translucent ball), warm water, food coloring (optional), measuring spoons, spoon or craft stick to stir the mixture, 2 small plastic cups or other containers for mixing. By these things, you can make Bouncing Ball, perfectly.
SNIP
Troll post?
Anyhow, from what I understand, you need your program to act as if you were to drop a ball, from an initial height, and it will eventually stop after bouncing some number of times.
Considering we don't know how many times the ball will bounce, because different initial height's will result in a different number of bounces, we need to use a Loop.
Then, since we don't want the ball to bounce forever, we need to have some way to slow the ball down, which could be done by having a variable, f, for friction, which we can apply to the ball, which occurs when the ball hits the ground.
I made the program just to test it out, but I'll give you some pseudo-code and that should help.
Turing: | %variables, including circle width, friction, circleX, circleY, circleVelocity, initialHeight, reducedHeight, and direction boolean.
circleX := xPositionYouWant
circleY := initialHeight
circleVelocity := 2 % value to increment by
reducedHeight := initialHeight
loop
% draw your circle with parameters (circleX, circleY, circleWidth, circleWidth, colour)
% If circleY goes under 0, set to 0 (reached bottom/ground).
% if circleY reached bottom/ground or direction is up and circleY is at reducedHeight then
% if direction is down, change direction to up, subtract friction from reducedHeight
% if direction is up, direction changes to down.
% if circleY is between 0 and reducedHeight
% if direction is down, subract circleVelocity from circleY
% if direction is up, add circleVelocity to circleY
% Update screen, delay, cls
end loop | This is a very simple solution, not that elaborate or fancy, but it gets the job done, given your details. |
|
|
|
|
|
mirhagk
|
Posted: Tue Jul 24, 2012 7:35 am Post subject: RE:bouncing ball |
|
|
That post is an intelligent spam bot. It finds similar questions on other forums and responds to the question with one of the answers. Which is why it's so serious, educated, yet completely off topic. |
|
|
|
|
|
Dragon20942
|
Posted: Mon Oct 08, 2012 2:02 am Post subject: RE:bouncing ball |
|
|
There are two immediately simple ways to do this that jump to my mind.
1. Create a series of loop controlled variable if statements. Basically, have the ball drop. When it rises, have it drop again from a height lower than when it started. Repeat until it bounces barely higher than when it touches the floor. It helps to have a safety net statement comparing the height cap variable to a height where it is safe to stop.
2. Acceleration/deceleration. This method works much better if you can understand it. Make a gravitational constant (2 works well with delay 10). Use this as your acceleration value. You will therefore have at least 3 variables concerning Y: Gravity, Velocity, and Position.
Hint: Gravity always pulls down, therefore when your perfectly elastic ball hits the floor, it is the velocity, not the gravity that is reversed in polarity. |
|
|
|
|
|
Insectoid
|
Posted: Mon Oct 08, 2012 4:38 am Post subject: RE:bouncing ball |
|
|
OP hasn't been here since May. He doesn't even remember this website exists anymore. |
|
|
|
|
|
QuantumPhysics
|
Posted: Mon Oct 08, 2012 11:17 am Post subject: RE:bouncing ball |
|
|
^ lol'ed. Every turing user is usually a one-time user. Posts then quits |
|
|
|
|
|
Aange10
|
Posted: Mon Oct 08, 2012 4:38 pm Post subject: RE:bouncing ball |
|
|
Usually. |
|
|
|
|
|
|
|