Questions tagged [collision]
In collision detection problems, the challenge is to determine when shapes intersect each other.
106
questions
32
votes
3
answers
44k
views
Overlapping rectangles
I received the following question in a technical interview today (for a devops/SRE position):
Write a function which returns true if the two rectangles passed to it
as arguments would overlap if ...
17
votes
1
answer
4k
views
Bouncing stacking boxes
I'm not sure if it would be better to make the envelope into an extension of the Rectangle constructor.
The physics seem a bit dodgy, it works well most of the time, but sometimes the boxes overlap ...
16
votes
3
answers
7k
views
2D Collision Detection in C++
I'm attempting to rewrite the classic snake game in c++. What I am inquiring about is my implementation for a 2D collision detection function. I am utilizing ...
15
votes
3
answers
836
views
Setting the scene for a role-playing game
I made some games in Pygame, but I am still new to making games.
I made this RPG game, and this code is just a part of the game. The game executes different Pygame files for different levels of the ...
13
votes
2
answers
10k
views
2D Collision Detection
I wrote this a while ago but wanted to see if I went about it the right way and if my brain is working correctly. I was thinking about these two projects the other day and I recently released the ...
11
votes
3
answers
2k
views
2D tilemap collision method
Is this the optimal method to check for collisions in a 2d-based game? I put together a working demo of 2D collisions here (WSAD to move, orange blocks collide).
I currently use the following code ...
11
votes
1
answer
359
views
Basketball Collisions with Box2d
I'm working on a new prototype that is a simple drag and shoot arcade basketball game. For this project I am working with LibGDX and the Box2d physics library.
You can play the game here: Play ...
11
votes
1
answer
586
views
Bounding volume hierarchy
I'm building a bounding volume hierarchy in Golang. I can tell my code works because I did some test on it and it gives the same results as the brute force implementation (brute force is to test all ...
11
votes
1
answer
539
views
Battle City (Tank) replica
I'm learning JS and Canvas. A friend of mine gave me the task to create a Battle City replica. I've already managed to make the map and the player to move. Nothing fancy just some squares with a color,...
10
votes
2
answers
1k
views
Design of physics with Collision Detection using SFML
I found out that in Visual Studio 2012, it is possible to create project of SFML easily with a template. I am not an experienced C# programmer. Hence I wanted to implement a physics component just for ...
10
votes
2
answers
365
views
Artifact collision in plane module
Here's something I tried putting together as I'm learning. Critiques on anything are welcome. There's also a logic bug in the Plane module I can't identify.
The long and the short are that it takes ...
10
votes
2
answers
584
views
Finding the nearest polygon
Finding the nearest polygon out of a list of polygons seems to be quite a challenge on performance, due to lack of optimization.
Consider the following image:
I'll give the concept behind this. The "...
9
votes
3
answers
2k
views
Performance of collision detection in a grid
I have fairly simple collision checking and handling Python code which is currently bottlenecking my performance quite a bit. I haven't done too much coding in python and I'm quite sure there's ...
9
votes
1
answer
13k
views
Line segment to circle collision algorithm
I've written a function (in Python 3) which computes if a line segment (constraint) and a circle (body) collide, and returns the point of intersection (closest point to the centre of the circle):
<...
9
votes
3
answers
968
views
Canvas Drawing/Animation
I am trying to learn how to write good, clean, and efficient JavaScript. I consider myself a novice, at best, in JavaScript. Any comments are appreciated.
In an effort to become a better JavaScript ...