collision-detection

What's the best way to do collision detection?

妖精的绣舞 提交于 2019-12-13 00:52:22
问题 I have a need to define a polygon that would be the "legal" area, and allow a user to move a rectangle around within that polygon, preventing them from moving the rectangle anywhere where its points venture outside the polygon. The polygon is a fixed shape, so, I was thinking it may be easiest to import a PNG of that shape and pull the points in that way, somehow? But I'm still at a loss as to the math involved in checking the coordinates of the rectangle as the user drags it, and testing at

Pygame circle collision?

泪湿孤枕 提交于 2019-12-13 00:34:45
问题 I am using pygame to make a simple game. I am having issues with circle collisions. I am getting the following error: "AtributeError: 'pygame.Rect' object has no attrinute 'rect'" Here is the particular code I am having issues with below: if pygame.sprite.collide_circle(hero_circle, enemy_circle): gameover() Thanks in advance! 回答1: Use pygame.mask to create a collision mesh for your objects and use the mesh to do collision detections. In more detail: Create an image file for both of your

pygame collision detection with walls

眉间皱痕 提交于 2019-12-13 00:19:43
问题 Currently I've been spending around half an hour trying to figure out how to implement this script better. I've tried a few methods, but they didn't quite work. When running the script, the player glitches a bit, and sometimes the player can only move in the blocks once it comes in contact. x = 64*3 y = 0 xvel = 0 yvel = 0 grounded = True playerRect = pygame.Rect ((x, y, 64, 64)) collidelist = [] level = ["#=======##=========================", "#=======#==========================", "#==######

Simple collision detection

做~自己de王妃 提交于 2019-12-12 20:17:15
问题 I want to write a platform game, all I done before was puzzle games with no need of physics. All I need is simple collision detection, what I will supply the physics engine is position of all objects and it should output: All objects of a specific object type (bullets) that collide with any object (and what object), just a list of pairs. For every object of a specific object type (players and npcs) if its on ground or in mid air. All the simulation of move/speed/gravity/hits/reflections will

Collision detected multiple times.

北慕城南 提交于 2019-12-12 19:24:11
问题 I am making a flappy bird game. I seem to be having a problem when my bird passes each wall/collects a coin. There are 2 problems. 1 the game lags for a millisecond after collecting. 2 My bird seems to have 2 or even 3 collisions each time creating a score of 2 or 3, I cannot get my head around this! My bird is a 5 texture animation, with physics body that wraps around its complex shape with the texture: bird.texture! type of code. I have been trying to figure this out for 4 days now its put

AndEngine: Handling collisions with TMX Objects

≡放荡痞女 提交于 2019-12-12 18:29:00
问题 I managed to load a tmx map now I would like to create the obstacle that the sprite can not move, I recovered the obstacle like this : try { final TMXLoader tmxLoader = new TMXLoader(this, this.mEngine.getTextureManager(), TextureOptions.BILINEAR_PREMULTIPLYALPHA, new ITMXTilePropertiesListener() { @Override public void onTMXTileWithPropertiesCreated(final TMXTiledMap pTMXTiledMap, final TMXLayer pTMXLayer, final TMXTile pTMXTile, final TMXProperties<TMXTileProperty> pTMXTileProperties) { /*

ball collision detection

限于喜欢 提交于 2019-12-12 18:07:38
问题 im trying to detect what colour ball a white ball initially makes contact with. the coordinates and colors of all balls are known and the video feed of the balls will be top-view so there is only coordinates in x-y my code for the detected balls is as follows *//draw all detected circles for (int i = 0; i < circles->total; i++) { // round the floats to an int float* p = (float*)cvGetSeqElem(circles, i); cv::Point center(cvRound(p[0]), cvRound(p[1])); int radius = cvRound(p[2]); //uchar* ptr;

XAML Collision detection

爷,独闯天下 提交于 2019-12-12 15:44:41
问题 I am working on a Windows Phone game and it is going swimmingly minus collision detection. Is there a simple way that anyone could suggest detecting if two XAML objects are on top of each other? The only method I know of is creating a list that contains the coords of every single collidable object in the game, then scanning the list to determine if there is a collision or not. With all the cool XAML features like triggers, behaviors and such I thought there might be an easier way. However,

HTML JS Canvas Game: Tile Collision Bug Makes Player Teleport Up

那年仲夏 提交于 2019-12-12 14:33:40
问题 I'm a beginner at game development and have been struggling with getting collision done right between an array of tiles and a player rectangle. This game features jumping and gravity. First of all the collision works, but is very clunky. Sometimes when the player ends up on top of a tile and a little to the edge, it will instantly teleport to either the right or left side (depending on what edge/corner) and fall of it. This also happens when colliding with the bottom of the tile; the player

Java Circle to Circle collision detection

痴心易碎 提交于 2019-12-12 09:54:11
问题 I am making a circle to circle collision detection program. I can get the balls to move around but when the collision is detected, the balls are quite far overlapped. Any suggestions? Thanks in advance! import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.lang.Math; public class ShapePanel extends JPanel{ private JButton button, startButton, stopButton; private JTextField textField; private JLabel label; private Timer timer; private final