collision-detection

Slick2D Rectangle Collision Detection

橙三吉。 提交于 2019-12-02 07:15:39
I'm having an issue showing that one rectangle has collided with another. So my question is, how can I get the intersect method to check for collision? Or are there any other ways to handle collision in this situation? I'm creating a turn-based combat game (similar to Final Fantasy or Legend of Dragoon) where the player's character is on the right side of the screen and the enemy is on the left side. The player and enemy each take turns attacking. So when the player attacks, the sprite animation moves across the screen from right to left until it stops in front of the enemy, attacks, and

cocos2d v3 collision detection

橙三吉。 提交于 2019-12-02 07:11:59
I'm trying to inspect collision collision of two bodies, but collision detection callbacks are not being fired. Here is my code: 1) My CCScene implements CCPhysicsCollisionDelegate protocol 2) I set collision delegate for physics _physics = [CCPhysicsNode node]; _physics.gravity = PHYSICS_GRAVITY; _physics.debugDraw = YES; _physics.collisionDelegate = self; [self addChild:_physics]; 3) For each of two body I set a collision type body1.collisionType = @"body1"; body2.collisionType = @"body2"; 4) That's it, when these two bodies collide none of CCPhysicsCollisionDelegate callback methods is

How do I delete an image after a collision in pygame?

给你一囗甜甜゛ 提交于 2019-12-02 06:46:17
I'm making a game involving powerups using python. There is a random chance of one spawning and it blits its image on the screen. it picks a random powerup from a list once the player's body (The captain in this scenario) collides with it. I'm checking the collision with a rectangle at the position of the image (Same size) and attempting to delete the rectangle, and the image once a collision happens. How can I do this? This is my attempt so far, however, I keep receiving the error: "List assignment index out of range" and it highlights the line: del PowerYList[Spot]. Can someone tell me what

How to detect collision between objects in Pygame?

别说谁变了你拦得住时间么 提交于 2019-12-02 06:40:57
I'm making a sidescrolling game in Pygame, and if the fox sprite collides with the tree, it is supposed to print "COLLIDE". But it doesn't work. How can I fix this to detect collision between the fox and the tree? Here's the code: if foxsprite1 > xtree and foxsprite1 < xtree + treewidth or foxsprite1 + treewidth > xtree and foxsprite1 + treewidth < xtree + treewidth: print ("COLLIDE") xtree is the x coordinate of the tree, treewidth is the width of the tree, and foxsprite1 is the fox. Keep object position and size as pygame.Rect() fox_rect = pygame.Rect(fox_x, fox_y, fox_width, fox_height)

IOS SpriteKit Colision Detection: Resetting Position of an Object

て烟熏妆下的殇ゞ 提交于 2019-12-02 05:17:17
I'm working on Collision Detection where the hope is when Object1 moves down the screen and eventually hits Object2 it triggers the didBeginContact method and in turn, the resetPosition on Object1 which will bring Object1 back to the top of the screen. I've used NSLogs to test to make sure if the program reaches the didBeginContact method, and it does. On top of that, the program also works through the called upon method (resetPosition) as well. The only problem is, it does not change the position of Object1. I the tried to see if I could call the method resetPosition in the touchesBegan

physics engine - phase order and other general information

扶醉桌前 提交于 2019-12-02 04:46:00
I want to build my own 2D mini-physics engine, that will include(for now) rigid bodys, and constraints (joints, contacts, springs...). And I've tried to figure out what is the right order of the phases, when I start a timestep, when the the general phases are: Broadphase, Narrow phase(Collision Detection, and Contact generation), Resolution (Constraints Solver), and the Integration - hope you can tell me the right order. I allso have general questions about each phase: Narrow Phase - When I've found a collision do I need to seperate the bodies after I've found the collision or just apply an

Collision detection 2D between rectangles

放肆的年华 提交于 2019-12-02 03:14:46
I am writting a collision detection engine for my game and I have some problems. Indeed, since I have several fixed rectangle and one moving (the player), I need to know which side of the fixed one was collided at first by the player, to replace him correctly. The fixed rectangle are NOT in a grid so they can be placed anywhere on the map and they can have diffents size. They are not rotated. The player class stores it's direction vector. Any idea? KiTe In a nutshell: You'll compare the Y and X components of the bounding rectangles to eachother to check for a collision. If the top(Y) of the

How to get collision detection of circle and triangle

血红的双手。 提交于 2019-12-01 22:36:30
问题 I have one triangle ad one circle moving objects on plane.How will i know both of them are collide to each other. ? 回答1: Circle - triangle interesction test is what you want http://www.phatcode.net/articles.php?id=459 来源: https://stackoverflow.com/questions/5518940/how-to-get-collision-detection-of-circle-and-triangle

Mass Ball-to-Ball Collision Handling (as in, lots of balls)

醉酒当歌 提交于 2019-12-01 21:53:10
问题 Update: Found out that I was using the radius as the diameter, which was why the mtd was overcompensating. Another Update: The reason my balls are overlapping seem to be because there's only one check for every collision. After some research, some are saying that one of the ways you could prevent overlapping with objects piling up is to recursively perform the collision check. This works to an extent, and I suspect that it'd work even better if the physics were a lot more accurate. I'll