collision-detection

How to detect collision in three.js?

别等时光非礼了梦想. 提交于 2019-12-17 10:19:36
问题 I am using three.js. I have two mesh geometries in my scene. If these geometries are intersected (or would intersect if translated) I want to detect this as a collision. How do I go about performing collision detection with three.js? If three.js does not have collision detection facilities, are there other libraries I might use in conjuction with three.js? 回答1: In Three.js, the utilities CollisionUtils.js and Collisions.js no longer seem to be supported, and mrdoob (creator of three.js)

Collision detection of huge number of circles

試著忘記壹切 提交于 2019-12-17 08:19:10
问题 What is the best way to check collision of huge number of circles? It's very easy to detect collision between two circles, but if we check every combination then it is O(n 2 ) which definitely not an optimal solution. We can assume that circle object has following properties: Coordinates Radius Velocity Direction Velocity is constant, but direction can change. I've come up with two solutions, but maybe there are some better solutions. Solution 1 Divide whole space into overlapping squares and

Collision Detection between two images in Java

人盡茶涼 提交于 2019-12-17 04:32:50
问题 I have two characters displayed in a game I am writing, the player and the enemy. defined as such: public void player(Graphics g) { g.drawImage(plimg, x, y, this); } public void enemy(Graphics g) { g.drawImage(enemy, 200, 200, this); } Then called with: player(g); enemy(g); I am able to move player() around with the keyboard, but I am at a loss when trying to detect a collision between the two. A lot of people have said to use Rectangles, but being a beginner I cannot see how I would link

Java ball object doesn't bounce off of drawn rectangles like it's supposed to.

孤街醉人 提交于 2019-12-17 04:07:22
问题 Sorry for the awful title. The purpose of the Java applet is as such: A ball is bouncing around the screen. The size and speed of this ball can be changed via scrollbars. The user can press and drag the mouse on the screen to draw rectangles. The ball will bounce off of these rectangles as well. The bounds of these rectangles are stored in a vector. When a rectangle is clicked, it (and all other rectangles at that point) are removed from the vector (and the screen). The problem I'm having is

circle-circle collision

孤街醉人 提交于 2019-12-17 02:31:33
问题 I am going to develop a 2-d ball game where two balls (circles) collide. Now I have the problem with determining the colliding point (in fact, determining whether they are colliding in x-axis/y-axis). I have an idea that when the difference between the y coordinate of 2 balls is greater than the x coordinate difference then they collide in their y axis, otherwise, they collide in their x axis. Is my idea correct? I implemented this thing in my games. Normally it works well, but sometimes, it

Improving performance of click detection on a staggered column isometric grid

孤者浪人 提交于 2019-12-17 02:26:15
问题 I am working on an isometric game engine and have already created an algorithm for pixel perfect click detection. Visit the project and notice that click detection is able to detect which edge of the tile was clicked. It is also checks the y-index to click the most upfront tile. An Explanation of my current algorithm: The isometric grid is made of tile images that are 100*65px. TileW=100, TileL=50, tileH=15 The map is represented by a three-dimensional array map[z][y][x] . Tile center points

How to handle Null Pointer Exception in libGDX's Box2D ContactListener?

你说的曾经没有我的故事 提交于 2019-12-14 03:23:08
问题 What's up everyone, I am heuristically producing a Pong clone in Box2D via libGDX. The Null Pointer Exception is originating in the ContactListener's beginContact() method in which I am trying to implement score logic. The Box2D world uses two separate EdgeShapes as sensors for incrementing a score variable upon collision with the Ball (view attached image). The collision logic between the Ball and the two EdgeShapes works, but collision between the Ball and anything else in the Box2D world

How to stop sprite on collision (Keep it from walking on walls)?

China☆狼群 提交于 2019-12-13 20:09:14
问题 Thanks to ellertsmari, I am able to get collision detection. Adding Collision to Rectangles so Sprite Wont Go Through? Just now I want to get my sprite to stop on collision so he won't be walking on walls. Here's my link to the game: https://yewtreedesign.github.io/441_HW/HW11/index.html Here's the source code that helped me to use sprites. https://dev.to/martyhimmel/moving-a-sprite-sheet-character-with-javascript-3adg so I figure that : positionX + deltaX > 0 (checks for left edge collision.

Android AndEngine: Simple sprite collision

こ雲淡風輕ζ 提交于 2019-12-13 18:27:11
问题 I am new to AndEngine game development (or game development in general) and I am working on a very simple game. The setting is that I have 4 main sprites in the game: a.) Fighter Plane b.) Tank c.) Foot soldiers d.) Bomb The game is in a current infinite loop. The fighter plane comes out from the left, zooms across the screen and comes out the right again continuously every second. The Tank comes out from the left side of the screen, makes its way to the middle of the screen, drops off some

Collision detection management in Libgdx

我只是一个虾纸丫 提交于 2019-12-13 18:15:27
问题 After reading this: Managing Collision Detection I thought about how to manage it in libgdx as it supports other collision detection (using Intersector) and other classes you can use in game. I have the logic of my Objects with their properties (Zombie for example with moving Speed and health) and the appearance with the Textures, Position on Screen etc.( Zombie2d for example which is a subclass of Actor). The Zombie2d has also a reference to Zombie to have all the attributes of a Zombie. The