3 Replies - 757 Views - Last Post: 23 February 2017 - 03:32 AM Rate Topic: -----

#1 ryosaeba  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 20-February 17

Help me to understand about motion with variable acceleration in 2D

Posted 20 February 2017 - 04:06 AM

Hello everyone, be patient with me because I am not much into physics and just now start to understand about vector algebra. In this days I got a lot of confusion in my head about motion in 2D space with a variable acceleration.
I was working on the idea to make a simple game about airplane in a sidescroll view 2d like Super Mario (the framework is gamemaker) but I still got confusion about the getting the X and Y position of my object.
From what I understand untill now let's say my object start with velocity 0 and I apply some thrust to it with direction 0 (mean east) at the moment not considering gravity acceleration.
I will get something like this in my main loop:

...
speed += acc*deltatime;

x += (oldspeed + speed) * cos(degtorad(dir));
y -= (oldspeed + speed) * sin(degtorad(dir));

oldspeed = speed;
....



So with this code my airplane even if I not accelerate and decide to control my tail airelon change direction and make loop keeping the actual speed I am going to, that's nice. But I don't think it's currect way to doing it.
Basically dir is the direction my plane is pointing but it's wrong change it, the truth will be I am changing the angle of the tail airelon for make my plane pitch or dive and if I add the gravity force on my project offcurse it will not act as I want to (because as per example I consider my plane fly on dir = 0, gravity will be pointing at 270 but with the y * sin(degtorad(0)) will be 0 and not falling offcurse.
I am sorry I know it's stupid question but I'm really stuck so will be glad for one help on understanding.
Another addition, gamemaker not use strurcture like vectors sadly. Thank you and best regards.

Is This A Good Question/Topic? 0
  • +

Replies To: Help me to understand about motion with variable acceleration in 2D

#2 UG Cyber  Icon User is offline

  • D.I.C Addict

Reputation: 36
  • View blog
  • Posts: 610
  • Joined: 24-July 08

Re: Help me to understand about motion with variable acceleration in 2D

Posted 21 February 2017 - 06:48 PM

Im not really understanding the question.
Is your airplane moving in the correct direction before you add gravity?
If you remove the variable velocity and simply make it static, does it do what it is suppose to?

Can you show more code or provide the entire code so we can step through it and see what might be wrong?
Was This Post Helpful? 0
  • +
  • -

#3 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 792
  • View blog
  • Posts: 1,886
  • Joined: 24-April 12

Re: Help me to understand about motion with variable acceleration in 2D

Posted 22 February 2017 - 04:50 AM

You may want to check out my Acceleration Tutorial. The actual tutorial is here. You are probably not working with XNA, and so the linked source code and project may be of limited use. You could download it and at least look at the source code.

But the tutorial should be helpful even without the source code. That's one of the few where I spent a great deal of time discussing things rather than just simply writing a code example.

In the code, I addressed much of what you are talking about except I went with the even more simple example of a ship in space. All this is in 2D despite the fact that I've mostly done 3D. I wanted to get the concepts down before attempting it in 3D.

All the basic concepts of motion should be in the tutorial. You don't have gravity or drag. But gravity is just another acceleration vector in the direction of the planet. You will fall until something stops you, such as the ground. Remove that and you will continue to fall.

Drag is more of a resistance to velocity. The way I would deal with drag is a deceleration vector that's length is determined by the volume of air displaced. Basically you take a silhouette of the object and sweep it through the space it occupies during the time period and calculate the volume of air in that swept area. This gets into displacement. But I think the weight of that volume of air determines how much force is needed to move it out of the way.

You may also want to watch my Vectors video.
Was This Post Helpful? 2
  • +
  • -

#4 ryosaeba  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 20-February 17

Re: Help me to understand about motion with variable acceleration in 2D

Posted 23 February 2017 - 03:32 AM

View PostBBeck, on 22 February 2017 - 04:50 AM, said:

You may want to check out my Acceleration Tutorial. The actual tutorial is here. You are probably not working with XNA, and so the linked source code and project may be of limited use. You could download it and at least look at the source code.

But the tutorial should be helpful even without the source code. That's one of the few where I spent a great deal of time discussing things rather than just simply writing a code example.

In the code, I addressed much of what you are talking about except I went with the even more simple example of a ship in space. All this is in 2D despite the fact that I've mostly done 3D. I wanted to get the concepts down before attempting it in 3D.

All the basic concepts of motion should be in the tutorial. You don't have gravity or drag. But gravity is just another acceleration vector in the direction of the planet. You will fall until something stops you, such as the ground. Remove that and you will continue to fall.

Drag is more of a resistance to velocity. The way I would deal with drag is a deceleration vector that's length is determined by the volume of air displaced. Basically you take a silhouette of the object and sweep it through the space it occupies during the time period and calculate the volume of air in that swept area. This gets into displacement. But I think the weight of that volume of air determines how much force is needed to move it out of the way.

You may also want to watch my Vectors video.


Thank yuo for the effort, I am reading the code, I had used XNA and know C# but I got difficulty mostly because on GM is not available any function like Transform Matrix, nor vectors so my problem is working only with X and Y.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1