Jump to content

  • Log In with Google      Sign In   
  • Create Account


2d Physics


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 white_waluigi   Members   -  Reputation: 111

Like
0Likes
Like

Posted 12 May 2013 - 07:37 AM

i started to make a 2d game a while ago and i encountered a lot of Problem with movment and gravitation.

I managed to make sure, that stuff can't get through walls (Line-Collision System, with the Separating axis T.) But after that the Problems started and i desparating right now. first i had the Problem with tzhe Gravitation, that when you stand on a inclined line and Gravity is on, the Player slowly slides of the surfaces. also  if you move on an inclined line you are slower than you were on even surface. next Problem is, that if you move in the opposite direction of an inclined line, you just fly in the air for a brief second. There are a lot of other Problems but i don't wanna list them all here.

 

Does someone have a few links for me?



Sponsor:

#2 DT....   Members   -  Reputation: 487

Like
0Likes
Like

Posted 12 May 2013 - 01:59 PM

http://box2d.googlecode.com/files/Tonge_Richard_PhysicsForGame.pdf

 

http://code.google.com/p/box2d/downloads/list



#3 white_waluigi   Members   -  Reputation: 111

Like
0Likes
Like

Posted 13 May 2013 - 08:27 AM

thx



#4 white_waluigi   Members   -  Reputation: 111

Like
0Likes
Like

Posted 18 May 2013 - 01:24 AM

OK, now I've looked through that stuff and it didn't really solve my Problem.

Maybe i should have mentioned that i wasn't searching for real physics like stuff rotating and rag-dolls and such, just Physics like in Super Mario for example (I know it says a lot, if i can't even get that right) just instead of simple Block-Worlds Worlds that are Physical build out of Simple Lines.

But the Problems are still with Gravitation.

Does maybe someone have some Tips or an OpenS Game to check how they solved it?



#5 Bacterius   Crossbones+   -  Reputation: 8671

Like
0Likes
Like

Posted 18 May 2013 - 03:41 AM

You might be better off implementing this yourself if you are looking for simple physics with no advanced features and existing tools are too hard to integrate in your game. Though for that you'll need at least some working knowledge about Newtonian mechanics (just translation, since you said you don't need rotation). Can you describe why someone standing on a frictionless slope will slowly slide down due to gravity?


For your first problem, if you want to prevent the player from sliding off a slope, you need to add friction. As I said, you would slide down a slope in real life if it were frictionless (think an icy slope). The most basic implementation is simply as follows (this is called static friction, there are other types of friction):

 

1. calculate the force the player exerts to move, call if F

2. calculate the force exerted by the player on the surface on which he is standing (gravity), call it N

3. if F > N * c, move the player, else, don't move the player, where c is some constant between 0 and 1 (called the friction coefficient)

 

This way, if a player simply stands on a slope, he won't move. And if he wants to move, he will be able to.

 

For your second problem, this isn't really a problem per se. If you walked straight off a slope in real life, you would fall and tumble as well. But what we do in real life is we follow the slope, that is, we incline ourselves so that we don't walk off the slope horizontally, but instead move diagonally along the slope. To do this, you can look at what the player is currently standing on, calculate the gradient at that position, and make the player move according to that gradient. This will make him "slide" down the slope nicely instead of moving in a staircase pattern.


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#6 white_waluigi   Members   -  Reputation: 111

Like
0Likes
Like

Posted 18 May 2013 - 08:01 AM

k, didn't think i'd have to go so far for a 2d game, but ok, thanks. So ill have to implement a system, that gets the surface(s) the player is standing on.



#7 Bacterius   Crossbones+   -  Reputation: 8671

Like
0Likes
Like

Posted 18 May 2013 - 08:05 AM

k, didn't think i'd have to go so far for a 2d game, but ok, thanks. So ill have to implement a system, that gets the surface(s) the player is standing on.

 

Well there are always ways to fake it. But if you want to make sure everything works as planned, it's best to have some code that can handle anything you throw at it (within the limits of your game). Otherwise you'll be piling hack on hack, adding one special case after another, and it gets ugly really quickly.


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#8 white_waluigi   Members   -  Reputation: 111

Like
0Likes
Like

Posted 18 May 2013 - 01:07 PM

Otherwise you'll be piling hack on hack, adding one special case after another, and it gets ugly really quickly.

yeah been there already. Lost a lot of time. Now i wanna do it right.

 

So what do you think of that:

 

-a friction System like the one from Bacterius

-When a collision gets solved, that collision gets stored in the Units collision List. If the collsion was not too steep, the Player is allowed to jump.

 

I just wanna ask before i loose more time.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS