Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [collision]

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

-1
votes
0answers
23 views

making 1 player pong in java, can't figure out collisions [on hold]

I'm trying to piece things together with things that I have a vague understanding of. If you think there's an easier idea I'm open to suggestions. ...
4
votes
1answer
136 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 ...
-1
votes
1answer
76 views

Simplify JavaScript collision detection with offset

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 ...
0
votes
1answer
37 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 ...
2
votes
1answer
183 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), ...
3
votes
1answer
132 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 ...
4
votes
2answers
3k 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 ...
5
votes
1answer
339 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 ...
3
votes
2answers
178 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 ...
4
votes
1answer
45 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 ...
6
votes
2answers
812 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 ...
5
votes
1answer
38 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 ...
5
votes
2answers
147 views

OBBs intersection improvement for AABBs-OBBs

I'm trying to code some intersection codes for Oriented Bounding Boxes (OBBs) and axis-aligned bounding boxes (AABBs). I have the OBB-OBB intersection using the Separating Axis Theorem (SAT) and I'm ...
3
votes
1answer
544 views

Circle - Line segment collision

I wrote an implementation of circle - line segment collision detection algorithm. Here is quick demonstration how it works: And here is my implementation in Javascript using HTML canvas: index.html ...
4
votes
1answer
348 views

Simple class game hierarchy with collision detection

I'm trying to make the transition from the 'understand how standalone features work' phase to writing.. more 'complex' code that could actually see use in real life, so I've been trying find some neat,...
3
votes
2answers
2k views

Find the intersect area of two overlapping rectangles

This is my solution to find the coordinates of 2 overlapped rectangles implemented in JavaScript. Each rectangle is represented by 2 points, each with 2 (x,y) coordinates. Can this code be improved?...
3
votes
1answer
291 views

Octree Implementation

The fn_AABB struct represents an axis aligned bounding box, by a center(position) and half lengths(hwidth). They also contain a set of planes for use in collision but that is not important to the ...
6
votes
1answer
223 views

Handling collision on a turn-based 2D game

I have implemented a collision check algorithm that I have created for my game, and the algorithm uses recursion. Now it all works fine, and I thought to myself, what if there was a way to solve this ...
4
votes
1answer
120 views
5
votes
0answers
188 views

Spacial hashing Library

Old code ...
1
vote
1answer
78 views

Collision manager

I have a chunk of code that's working properly but it's way too complicated to read: ...
2
votes
0answers
236 views

Collision detection method

I think everyone has some code they are embarrassed and not proud of and today I have decided to show mine. I'm not sure how to go about making this more efficient, at the time I was just happy it did ...
-2
votes
1answer
2k views

C++ Erasing an object from vector of pointers

I am making this simple game in SFML and I have this vector of pointers std::vector<Brick*> bricks; which stores objects of class ...
3
votes
2answers
276 views

Maximize the number of PyGame sprites, with collision detection

I was trying to see what is the highest number of moving and colliding boxes (sprites) I could get in pygame? So that I could start working on game I want, I searched google and I found different ...
2
votes
2answers
314 views

Checking whether a bullet has hit a Space Invader

I just (almost) finished a Space-Invaders game in Javascript. I have a few bugs to clear out of the way but meanwhile I wanted to ask how I can improve the method I use to test if one of my 'Bullets' ...
1
vote
2answers
248 views

Javascript collision check

I have code to find images in my selections. But when nothing in selection (loop FOR) and selection is kinda big, it's kinda laggy. How can I improve my code? ...
5
votes
0answers
211 views

2D Game - Ray-cast collision handling

This code is an excerpt from an infinite platformer I'm working on for fun. It belongs to the class GameObject from which every object i.e platforms, player, ...
11
votes
2answers
4k 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 ...
2
votes
2answers
888 views

High performance, branchless Intersection testing: sphere-aabb & aabb-aabb

From my tests: AABB-Sphere: 2954.8 tests per ms. AABB-AABB: 1087.0 tests per ms. The sphere test is almost 3 times faster, but the two intersection tests seem to perform about the same number ...
1
vote
0answers
28 views

More JS AI causes slower AI movement in HTML Canvas

I have a simple little game with one character as the player and four enemy characters. I created a very basic AI, that moves towards the player when the player is nearby. That all worked fine, but ...
3
votes
1answer
673 views

Simple geometry problems involving rectangles and circles in Python 3

I'm working with some simple geometry problems featuring rectangles and circles. My code is as follows: ...
7
votes
1answer
112 views

Kattis “Hitting the Targets” utilizing a polymorphic relashionship

In order to learn C++ I have written a solution to this Kattis "Hitting the Targets" problem Basically the program is to accept some shapes (circles and rectangles) on std in and a set of points and ...
1
vote
1answer
212 views

Log collisions in generating unique random strings

I've created a small class to generate unique random strings. It works fine. I also want to log the collisions of the generated strings. I check if the generated string is in the array for uniquness: ...
6
votes
2answers
458 views

Computing intersections of a Polyline and a line

I wrote a script to compute / interpolate the nodes of a Polyline at a given latitude, input_lat. It works for my purpose but I am wondering if there is a better, ...
6
votes
2answers
512 views

Rectangle-segment collision detection

I am working with C++ and SDL, hoping to create a game later. I am implementing the collision detection between rectangles and segments. I found this (NateS user's solution) about line-rectangle ...
8
votes
1answer
1k views

2D colliding disks in JavaScript (ideal billiard balls)

I am implementing a simulation of colliding disks (ideal 2D billiard balls) in JavaScript. I follow an event-driven algorithm that avoids discretizing time; the algorithm goes as follows at each step:...
1
vote
1answer
56 views

Find cells crossed by a line

This method find cells that are crossed by line A-B and adds them to one vector. I have got some duplicates here and some lines of code are very similiar but they differ in one variable. Should this ...
15
votes
3answers
800 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 ...
4
votes
0answers
103 views

Hash Based Data Structure in Java for Collision Calculation

I have started a project on my free time were I'm writing a 2D game engine in Java. One of the more challenging and interesting aspects of such a project is collision detection between sprites on the ...
11
votes
1answer
272 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 ...
5
votes
1answer
81 views

Clone of “Pop the Lock” iPhone Game

As an exercise, I decided to program my own version of the game Pop the Lock for the iPhone. The look and functionality are essentially the same, though the controls are modified for playing on a ...
3
votes
1answer
207 views

Checking a circle against some bounds in a collision detector

First, some code. I have a class, Circle: ...
1
vote
3answers
3k views

Collision detection algorithm

This is my second algorithm and I will try to make it as simple for you to understand how it works. It is pretty expensive and I'd like to make it more efficient. . It works by splitting a square ...
4
votes
2answers
1k views

QuadTree for collision detection

I was recently working on a game using the SFML library, Later on, I experienced performance issues due to collision detection. I have been told to use a QuadTree ...
11
votes
1answer
356 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 ...
4
votes
2answers
344 views

Obstacle-avoiding AI

I have made a game in Java that involves two players to fight each other with spaceships. For one player mode, I have programmed a simple AI to avoid allies and asteroids and go straight towards the ...
3
votes
6answers
692 views

Conditionally eliminating one of two colliding bodies

I like to explicit return function even for void functions to reduce the use of if-elses, like this code snippet: ...
1
vote
0answers
168 views

Recreating pong

Github is a link to all my code and the working JAR file. I have been learning LibGDX and attempted to make a working Pong game, I am new to this and would like some pointers on where I could improve ...
4
votes
1answer
1k views

Check if specific key exists in 2-dimensional array

I am writing a "collision detection" in PHP and want to check if a specific "area" is still free in the two-dimensional target array. I use the following code to do that, but I think there might be a ...
5
votes
1answer
251 views

Platformer with collisions

Today I started to build my first platformer, first time working with collisions and stuff. Now, surprisingly, everything seems to work, but since this is my first time creating a platformer and I'm ...