collision-detection

Collision detection in a 2D maze with thick walls

99封情书 提交于 2019-12-05 11:47:51
I have to make a game with Windows Forms for school. My game consists of a user having to get through a maze. I'm trying to prevent my user from going straight through the walls using collision detection, but am getting stuck because of the varying shape of the rectangles being used to represent walls. Here's an image of the game. This question may be similar to this one , however with my movement I believe that it is quite different, as I don't have a grid system or graphical map laid out. As you can see, the walls are fairly thick. Each wall is represented by a C# Rectangle, as is my Player

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

Detect collision between a moving object and an immobile one

瘦欲@ 提交于 2019-12-05 08:14:42
First of all, my question isn't really specific to C# or XNA, but my code examples will use these. I am currently trying to make a Pong clone and I've run into a problem with collision-detection. Each object basicly has a specific Velocity(which is a Vector2), Position(Vector2, also) and Speed(just a float). On every Update() call of the object, the position is changed this way: Velocity.Normalize(); Position += Velocity * Speed; At first, I only checked if there currently was a collision between two objects with a simple Intersects() call from the rectangles of the objects. I quickly realized

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

Having some issues with making pacman?

人盡茶涼 提交于 2019-12-05 05:04:49
Edit: Totally forgot to mention I'm coding in Java I'm having a real hard time making some kind of detection system or some way to make my pacman sprite/character move smoothly through my board in the game. I did not make the board it's a image. I had tried colour detection first which worked the best yet was not smooth at all and pretty choppy. I then tried to manual input coordinates of location not allowed to be entered. This also did not work out so well. I'm currently trying now to have the program use colour detection and check a separate unseen board to see if I'm still on the path.

LibGDX - properly using Polygon class

妖精的绣舞 提交于 2019-12-05 03:05:34
问题 I have created Polygon object to wrap my airplane (size of airplane's TextureRegion is 256x74, but size of this one in a game is 70x20). So: TextureRegion[] texRegsAirplane = TextureRegion.split(textureAirplane, 256, 74); Rectangle bounds = new Rectangle(0, 0, 70, 20); Polygon polygon = new Polygon(new float[]{0,0,bounds.width,0,bounds.width,bounds.height,0,bounds.height,0,0}); After that in my update function I update position of it: public void update(float delta){ Vector2 v = getPosition()

Collision/overlap detection of circles in a d3 transition

霸气de小男生 提交于 2019-12-05 02:07:36
问题 I'm using d3 to animate a route (path) on a map. When the route reaches a point along the route I'd like to popup some information. Most of my code is based on the following example. http://bl.ocks.org/mbostock/1705868. I'm really just trying to determine if there is a way to detect when the transitioning circle collides or overlaps any of the stationary circles in this example. 回答1: You can detect collision in your tween function. Define a collide function to be called from inside the tween

Three.js, PointerLock And Collision Detection

删除回忆录丶 提交于 2019-12-05 01:53:15
问题 I'm working on a 3d virtual home project. everythings works fine except collision detection. I use PointerLockControls for my camera and movement. but i'm not sure how to detec collision in every possible directions. For simplicity i started with just forward and backward collision to a simple cube on (0,0,0): rays = [ new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 0, -1) ]; Then: function detectCollision() { var vector; var projector = new THREE.Projector(); for (var i = 0; i < rays.length

Detect collision between two objects in Swift

爷,独闯天下 提交于 2019-12-05 01:38:13
问题 Collision detection is pretty simple in Swift - yet on this particular project, body collision is not triggering the didBeginContact event as usual. Here is my checklist for two bodies colliding (using soldiers and bullets): Add SKPhysicsContactDelegate to the class. set the physicsWorld appropriately, usually: self.physicsWorld.contactDelegate = self Create categories for each group of nodes you will have. E.g. let bulletCategory = 0x1 << 0 Create SKNodes for each bullet and soldier. Give

iPhone Pong Collision Detection

人盡茶涼 提交于 2019-12-04 23:21:58
I have an issue where if the ball hits the paddle just right, it gets locked inside and can't be released. It happens sometimes on the player paddle, but since you have control of it, all you have to to do is move it and it escapes. The computer follows the ball perfectly, so once it gets inside it never can escape, leading to what happens in this video . Now this only happens when I increase the framerate, if it's really low, it kinda, errors out and "goes through" the paddle resulting in a point gained. At least in this case, it's not a noticeable bug and the game continues to play.