Posted: Mon Apr 09, 2012 5:28 pm Post subject: Getting the ball to curve, present speed, and
What is it you are trying to achieve?
I am trying to have the ball curve once it falls from the cliff being the highest point.
any help would be wonderful, I understand how to move the ball but not in a curve and not with speed.
What is the problem you are having?
<Answer Here>
Describe what you have tried to solve this problem
I have tried to play around with the X value
and use:
[code="turing"]
y := starting_y_value - 0.5*a*t**2
%where a = the pull of gravity. specifcally around 9.81 m/s2
Turing:
var x, y :int var
x :=maxx - 10%the start y value
y :=maxy - 10%the start x value
procedure p_mountain%procedure to draw the mountain. Draw.Line(619, 380, 640, 380, black)%Rocksurface Draw.Line(619, 380, 619, 10, black)%Rockwall Draw.Line(10, 100, 640, 10, black)%ground end p_mountain
procedure p_main
put x, " ", y
Draw.Oval(x, y, 10, 10, black) end p_main
p_mountain
p_main
%%of course all I have is this unfinished background but it will curve and speed towards the ground then bounce 3 times and roll out to a hault.
[size=14]4.1.1
Sponsor Sponsor
Raknarg
Posted: Tue Apr 10, 2012 8:42 am Post subject: RE:Getting the ball to curve, present speed, and
So what, are you trying to make a physics engine with turing? or are you only working with the ball falling for now?
Gadd
Posted: Tue Apr 10, 2012 2:01 pm Post subject: RE:Getting the ball to curve, present speed, and
Im just working on geting that ball to fall and curve to make the realism show. A physics engine, ahah good idea.
Gadd
Posted: Tue Apr 10, 2012 2:02 pm Post subject: RE:Getting the ball to curve, present speed, and
here a bit more detail, basically what Im wanting here is to get that ball to run a procedure called say curve... and it will run that balls curve while at the same time adding to the gravity... once gravity hits a max value (which I will set) it will enter the fall procedure that will start dropping the ball right down to the ground and then enter a bounce procedure that will bounce the ball and roll it out. We are able to just make the ball fall but thats way to simple for me.
Raknarg
Posted: Tue Apr 10, 2012 3:02 pm Post subject: RE:Getting the ball to curve, present speed, and
hmm... well, you could have an acceleration, a vx and a vy. vx and vy start at 0. When you want the ball to start moving, you change the vx. Then when the ball falls, you can use the acceleration to change vy. vx will stay the same the entire time, but because of gravity the ball's vy will change, if that makes sense.
The bouncing, however, will require knowledge of trig and vectors.
Dreadnought
Posted: Tue Apr 10, 2012 3:10 pm Post subject: Re: Getting the ball to curve, present speed, and
I think you are slightly confused about gravity velocity.
Gadd wrote:
and it will run that balls curve while at the same time adding to the gravity... once gravity hits a max value ...
Gravity (near the Earth) is constant, it does not change, nor does it need to. It is an acceleration, the rate at which the velocity will change. In gravity's case, the velocity in the downward direction (toward the Earth) increases over time (for free-fall, neglecting air resistance). Note that if we consider air resistance then we do have a terminal velocity, which the ball will not exceed (although factoring in effects of air resistance complicates things a fair bit).
I assume that in your post when you said gravity, you meant downward velocity.
Gravity on it's own does not cause a curve, but if we roll a ball off a table the trajectory is curved. This is because, in addition to the downward velocity acquired by the ball due to gravity, there is also a component of the ball's velocity that is perpendicular to the vertical. (a horizontal velocity)
The ball's position along the vertical will vary like t**2, but its position along the horizontal will vary like t**1 (or just t), because there is no acceleration in this direction.
Gadd
Posted: Tue Apr 10, 2012 8:18 pm Post subject: RE:Getting the ball to curve, present speed, and
hey totally off subject Raknarg how did you like Ottawa for schooling? I'm only currently in highschool about to go into grade 12 at CarletonPlace and was going to attend Algonquin College. Let me know ;P
Raknarg
Posted: Tue Apr 10, 2012 8:41 pm Post subject: RE:Getting the ball to curve, present speed, and
Haha buddy, Im only in grade 11 though im further ahead than most people.
As far as I've heard, however, Ottawa seems to be pretty good for compsci, especially if you want to focus on the game aspect (which most new people seem to)
@Dreadnaught if you're making a physics engine, I don't think you want to make the x and y coordinates directly related to time passed.
Sponsor Sponsor
Dreadnought
Posted: Tue Apr 10, 2012 9:25 pm Post subject: Re: Getting the ball to curve, present speed, and
Raknarg wrote:
@Dreadnaught if you're making a physics engine, I don't think you want to make the x and y coordinates directly related to time passed.
I agree, but the idea that acceleration is the rate of change of the rate of change of position and that this means that position varies like t**2 (for constant acceleration) is important in understanding why the path of projectiles is parabolic (hence the curved path that Gadd wants to reproduce).
And while it is true that position should not be directly coded as a function of time, the position during free fall will end up depending on t**2 whether we like it or not (ignoring air resistance). In this case, though, units of time may be iterations of a loop.
Raknarg
Posted: Wed Apr 11, 2012 1:35 pm Post subject: RE:Getting the ball to curve, present speed, and
No, I agree that it's correct, but that's assuming that there arent other objects within the engine, correct?
Dreadnought
Posted: Wed Apr 11, 2012 2:22 pm Post subject: Re: Getting the ball to curve, present speed, and
Well, what I meant was that if you are creating a physics engine to cause objects to behave as they would in the real world, then the way the object moves in free fall will go like t**2. At this point I wasn't really concerned about the implementation, but a basic physics engine will produce this behavior (how it will work internally may not resemble it).
At this point I was only worried about the free fall (not the other behavior like bouncing).
Raknarg
Posted: Wed Apr 11, 2012 3:24 pm Post subject: RE:Getting the ball to curve, present speed, and
Oh, fair enough then.
smool
Posted: Wed Apr 11, 2012 4:53 pm Post subject: RE:Getting the ball to curve, present speed, and
So, to keep things simple: Just like your ball has two seperate postion values (x, y), so should your velocity have two seperate components (Vx, Vy). Gravity acts straight down, and so only affects the vertical component of your acceleration.
Gadd
Posted: Wed Apr 11, 2012 7:37 pm Post subject: RE:Getting the ball to curve, present speed, and
It's alright guys I discovered I could use the equation I said to make the cure and add the X + 1 to make a rise and lower the (a) value in order to make the curve larger, gravity will be tolled by delay time instead and it's getting me a 4 so, I'm fine thanks though ahah.
Raknarg
Posted: Thu Apr 12, 2012 8:45 am Post subject: RE:Getting the ball to curve, present speed, and
Just remember that marks arent the important thing here. There's never harm in going beyond, it's good for learning. For instnace, had I just stopped my old sidescrolling spaceship shooter game at the point where I could make my ship generate bullet, which was the only think I intended, I wouldn't have learned a lot of different concepts that I understood after i took it farther.