Skip to main content

Questions tagged [collision]

In collision detection problems, the challenge is to determine when shapes intersect each other.

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 ...
Linny's user avatar
  • 10.3k
4 votes
1 answer
190 views

Creating a maze game where the game resets if you hit traps/walls and finishes when you hit a different color

Here’s my code, the traps are the slightly visible squares. The user controls a red square (with arrow keys) and cannot touch the walls or traps or else the game resets. Additionally, if the user ...
Nicocav6's user avatar
3 votes
1 answer
202 views

Making a grid for collision detection in a game that wraps

I'm making a 2D game which wraps (when you move off the right edge, you appear on the left, etc). The game area is square, all objects are circles (with AABB smaller than the game area, and in most ...
Shuri2060's user avatar
  • 227
4 votes
1 answer
1k views

Bounding volume hierarchy C++

Here is a C++ implementation of a bounding volume hierarchy, aimed for fast collision detection (view frustum, rays, other bounding volumes). It is based on the ideas from the book "Real-Time ...
user avatar
1 vote
2 answers
237 views

Simplify JavaScript collision detection with offset [closed]

I am working on a background project that is a little interactive. Now I am using some collision detection to draw some lines and stuff. The code I have works great but it is very bulky and hard to ...
JanWillem Huising's user avatar
0 votes
1 answer
76 views

Self Updtating QuadTree

I'm making a simple 2D game engine, and to make collision detection more effective I tried making a QuadTree class. I don't know if this will work, but that's not that important. You don't have to ...
Kristóf Bácskai's user avatar
2 votes
1 answer
602 views

C++ Breakout game using SDL

I did a big mistake to create procedural C++ breakout game on start and now im having trouble converting it into OOP. As far as I can see I need classes: Loptica (eng. Ball), Splav (eng. Paddle), ...
Marko Petričević's user avatar
3 votes
1 answer
272 views

Flood Fill using unordered_map which has user-defined type as key

I have an implementation of the flood fill algorithm. Assume that an image is provided as a vector of ...
skr's user avatar
  • 539
5 votes
2 answers
10k views

Python Turtle based Pong game

I'm new to Python but I've coded in other languages mainly for hardware. I made Pong in Python using turtle but it's a little glitchy. I was wondering if any of you guys could check it out and give ...
Remington Nachshin's user avatar
5 votes
1 answer
779 views

Collision detection for moving 2D objects

After implementing SAT (separating axis theorem) and not being happy with it only working on stationary shapes, this in theory allowing for fast objects to glitch through others, I came up with this ...
DarkWiiPlayer's user avatar
3 votes
2 answers
307 views

Platformer Game: Arrow Key Player Movement and Collision Detection

I am in the middle of working on this game and I still need to add some things (e.g. score, coin counters, etc.) but I really feel like there is way too much unneeded code. Could you help me simplify ...
Josh Berger's user avatar
5 votes
1 answer
307 views

Line and bitmap collision detection

I am trying to implement an efficient collision detection between a line joining two points and a bitmap mask. Example: Currently I am using Bresenham's line drawing algorithm to draw each pixel of ...
Alessi 42's user avatar
  • 153
6 votes
2 answers
962 views

Collision Detection in a 2D shooter game

I have the following code that works just fine for collision detection. The only problem is its size and its performance. I'm trying to do it and many other things 60 times per second, which doesn't ...
Plqsmic's user avatar
  • 197
5 votes
1 answer
50 views

Mutable 2d Rect class

So I wrote a 2d rectangle class for use in a 2d pygame based game engine. It uses the vector class from this question, so if you want to test, you need that code too. I want to ask: Does this ...
MegaIng's user avatar
  • 413
6 votes
3 answers
249 views

Calculate next position and velocity after "bounce"

Intro and code I have the following function that calculates an object's "next" position and velocity (in 1 dimension) given a boundary [0, max]. ...
geofflittle's user avatar

15 30 50 per page
1
2
3 4 5
8