Game Physics With RK4 Implementation For A 2D Platformer

oscar.rpr
  • Game Physics With RK4 Implementation For A 2D Platformer oscar.rpr

    I been reading about RK4 for physics implementation in a game, so I read in some pages and all people recommend me this page:

    http://gafferongames.com/game-physics/fix-your-timestep/

    This page shows clearly how this one works, but I can't figure out how to implement in my game, maybe I don't understand that good but I find some things that are not really clearly to me.

    In my game, the player decides when change direction in the X-Axis but I can't figure out how with this RK4 implementation change the direction of the object, in the example the point goes side to side but I don't understand how I can control when he goes right or left.

    So if anyone can give a little bit of clarity in this implementation and my problem which I do not understand I will be really grateful.

    Thanks beforehand

  • To be frank: RK4 almost certainly isn't your biggest need right now. What's more, unless you're after very accurate game physics, I recommend against using Runge-Kutta entirely - it's simply more complication, and for most platformers standard Euler integration should be more than enough. In fact, most platformers don't really need that sort of physics at all - if you're looking to try and control character position, I would suggest 'faking it' by giving the character a constant velocity while the keys are down, with simple acceleration to speed (increase the velocity by a constant amount each tick until maximum speed is reached) and the inverse (deceleration to 0) when the key is released. What's the core problem that you're trying to solve?

Tags
c++ physics rk4
Related questions and answers
  • -physics/fix-your-timestep/ So when this is implemented, I might be making the following calls: update(dt) draw(0.24) draw(0.64) update(dt) draw(0.24) draw(0.76) The floating point numbers shown... a problem with smoothness. If I reduce my physics updates to 25 per second which I have only done as an experiment then it is a bit jerky. But the game easily runs at higher rates than that so there may... my game working at the moment without interpolation. It does physics updates using fixed step time deltas. The frame display rate is decoupled from this. So, it might be doing 40 Physics updates per

  • that make really hard to work with when coding some functions that use them. I was thinking of making ie. SimpleMesh and HierarchyMesh objects, which will also require that the renderer can deal... for my needs. Ah and I forgot to mention that nodes can have hierarchy, but this is not a problem if the frame data is reduced. The structure instances don't get duplicated unless any value changes. When... the Diffuse color variation or making it store any value that can change but making it so random that I woulnd't know how to relate the data to the other frames, or need a complex system for it. That's why

  • leverage it. My client is going to be written in C++ and I can use whatever language makes it easiest (I'm leaning towards Java) to make it happen on the server side. I plan on adding support for users... and if I can leverage Shiro's session features then that's a bonus. My real question is about the handshake between the client and server. If I use WS-Security isn't all that taken care of for me? Does...I'm trying to find a solid architecture for authenticating users against a database. I have a game client, which I plan to serve up a request with. The transport doesn't really matter

  • something. So I can change the height but nothing more. I can't move it left, right - anything. Also when I set 0 everywhere ( I mean in btVector3) the object is jumping up rather than falling down or better stay still. Can someone help me with that? Also are there any materials except those on bullets page where are some tutorials or something? EDIT The main thing which I want to achive...I have got stupid and annoying problem in my app. I am using bullet physics and I've started with hello world example on wiki: http://bulletphysics.org/mediawiki-1.5.8/index.php/Hello_World

  • out what I have done wrong, but it is hard, so perhaps someone has any idea of what may it be. I can reproduce it easily on my engine and my scene consists only of: 1 terrain page 1 mesh... to fire that I have found is the hash being changed after the node was inserted on the map. Any ideas how can I find a solution to it? Which data and information I can provide to help debug this? Also I have seen in the forum some posts about this assertion, but no one that I have seen explain ways to debug or to fix it. Ogre version 1.7.1 Windows 7 render Direct3d 9

  • Choosing an Audio API Aidan Knight

    library and stick with it. I switched physics engines 3 times which caused quite a bit of wasted time, so I would like to be set when I pick an Audio lib. I will be falling into the "indie" section as far as licensing goes. Here is what I have so far.. FMOD - Quality Middleware, success has gone to their heads and it seems they did away with the indie license recently. Price range seems to go from... to FMOD, but I will need to pull out the Euro to Dollar calculator, and figure out if the Shareware license would be applicable to Digitally Distributed Content. IrrKlang - Pricing looks fair

  • Ive been reteaching myself opengl so I can make a game on android. However Ive been struggling with how to build objects and scenes in opengl using c/c++ and passing them through the jni to the virtual machine where android can use them. Can some one point me towards some tutorials that actually show the use of natively built objects being created and passed through to the jni. Im fine using c... but I cant figure out how to create a scene in opengl in c++ and then pass it to java. Ive been looking at writing everything using java but Im not sure if the java bindings make for some performance

  • This is the first time I'm trying to make a 2D game, so I'm having quite a few difficulties in getting things right. Right now I'm trying to figure out exactly how the entity state machine should.... state_->handleEvent(event, this); } That means that I don't really ever need more than one instance of a particular entity state; doing something like entity.setState(new StandState) is therefore highly wasteful. Then again, making each entity state a singleton hardly seems appropriate. What do you suggest I do? (The same can be said about game states, so whatever the solution

  • I am trying to create a 2D platformer (Mario-type) game and I am some having some issues with handling collisions properly. I am writing this game in C++, using SDL for input, image loading, font... to work correctly. Player movement ends up being very glitchy and repositions the player when I don't want it to. Part of the reason is probably because I feel like this is something so simple but I'm... be crucial, let me know and I'll provide the necessary information. Finally, for anyone who can help, providing code would be very helpful and much appreciated. Thank you again for your help! Edit: I

Data information