game-physics

how to use the libgdx contactlistener

橙三吉。 提交于 2019-12-05 19:17:32
问题 I've just began to work with the Libgdx's Box2d Engine but i simply do not understand when the methods of the Contactlistener should be called. There is on the one hand "begin contact" and on the other "end contact". Where should i call them, to get the Number of of a certain fixture touching others? And how do I implement the Contactlistener ? A redirec' to a Tutorial would answer my Question. I didn't find anything while searching google. This one helped me a lot but it is written for C++

how to move object in circle forward and backward in html5 canvas?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 18:57:08
I am developing a small app in html5 canvas. I need to move a object in circular motion using keyboard keys . I am able to move the object using keyboard keys but there are bugs .The object do not move back ward or forward from the same position .Can any body help me completing this. Please check the code from following. Any kind of help will be highly appreciable http://jsfiddle.net/tmrhq6s5/ if ( !window.requestAnimationFrame ) { window.requestAnimationFrame = ( function() { return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame ||

2d Ball Collision Problem: no conservation of energy

爷,独闯天下 提交于 2019-12-05 12:50:55
I am trying to write a simple physics simulation where balls with varying radii and masses bounce around in a perfectly elastic and frictionless environment. I wrote my own code following this resource: http://www.vobarian.com/collisions/2dcollisions2.pdf and I also tested the code from here: Ball to Ball Collision - Detection and Handling QUESTION EDITED With the help of Rick Goldstein and Ralph, I have gotten my code to work (there was a typo..). Thanks so much for you help. However I am still confused as to why the other algorithm isn't working for me. The balls bounce off in the correct

Ambigious OpenGL Default Camera position

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 12:07:08
in my Opengl programs (before i apply perspective projection matrix) whenever i draw some object I draw it at the origin of the world coordinate system, however almost all of the Opengl tutorials states that the camera (My projection view) is located at the origin looking toward positive z-axis (which depends on how you treat z value in the projection matrix later on), however if that is true how does my camera (located in the origin) is able to view an object located in the origin. Note: i need this information so that i shift the world and rotate it around the origin so i get a rotating

How to fix circle and rectangle overlap in collision response?

╄→гoц情女王★ 提交于 2019-12-05 10:44:12
问题 Since in the digital world a real collision almost never happens, we will always have a situation where the "colliding" circle overlaps the rectangle. How to put back the circle in the situation where it collides perfectly with the rectangle without overlap? Suppose that the rectangle is stopped (null velocity) and axis-aligned. I would solve this problem with a posteriori approach (in two dimensions). In short I have to solve this equation for t : Where: is a number that answers to the

Inheriting from Transformable and Drawable in SFML

两盒软妹~` 提交于 2019-12-05 06:05:16
I'm trying to inherit from Transformable and Drawable in SFML in order to make my objects... well, transformable and drawable. I'm making a simple breakout game, but perhaps I'm going about this the wrong way. Here's my code: #include <SFML/Graphics.hpp> #include <SFML/System.hpp> class Player : public sf::Transformable, public sf::Drawable { public: Player(int x, int y); ~Player() {}; sf::RectangleShape p_rect; void doMovement(const sf::RenderWindow& window); sf::FloatRect getGlobalBounds() const; private: virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const { states

Linear movement stutter

喜欢而已 提交于 2019-12-05 05:40:32
I have created simple, frame independent, variable time step, linear movement in Direct3D9 using ID3DXSprite . Most users cant notice it, but on some (including mine) computers it happens often and sometimes it stutters a lot. Stuttering occurs with VSync enabled and disabled. I figured out that same happens in OpenGL renderer. Its not floating point problem. Seems like problem only exist in AERO Transparent Glass windowed mode (fine or at least much less noticeable in fullscreen, borderless full screen window or with aero disabled), even worse when window lost focus. EDIT: Frame delta time

How to make a dynamic body static in Cocos2d v3.0 with Chipmunk

对着背影说爱祢 提交于 2019-12-04 22:02:54
I’m using Cocos2d v3 and want to change a body from dynamic to static after colliding with another body. At the moment I’ve got: -(void)ccPhysicsCollisionPostSolve:(CCPhysicsCollisionPair *)pair static:(CCNode *)nodeA wildcard:(CCNode *)nodeB { _player.physicsBody.type = CCPhysicsBodyTypeStatic; } or -(BOOL)ccPhysicsCollisionPreSolve:(CCPhysicsCollisionPair *)pair static:(CCNode *)nodeA wildcard:(CCNode *)nodeB { _player.physicsBody.type = CCPhysicsBodyTypeStatic; return YES; } but neither works. I get the error: Aborting due to Chipmunk error: This operation cannot be done safely during a

Multiplayer billiards game physics simulation [closed]

一世执手 提交于 2019-12-04 20:05:49
I’m building an online multiplayer billiards game and I’m struggling to think of the best approach to multiplayer physics simulation. I have thought of a three possible scenarios, each having its own advantages and disadvantages and I would like to hear some opinion of those that either have implemented something similar already or have experience in multiplayer online games. 1st Scenario: Physics simulation on the clients: The player in turn to take a shot sends the angle of the shot and power to the server, and the sever updates all clients with these values so they can simulate the shot

Circle/rectangle collision response

南笙酒味 提交于 2019-12-04 15:52:42
So I built some time ago a little Breakout clone , and I wanted to upgrade it a little bit, mostly for the collisions. When I first made it I had a basic " collision " detection between my ball and my brick, which in fact considered the ball as another rectangle. But this created an issue with the edge collisions, so I thought I would change it. The thing is, I found some answers to my problem: for example this image and the last comment of this thread : circle/rect collision reaction but i could not find how to compute the final velocity vector. So far I have : - Found the closest point on