collision-detection

How to check which object my character is colliding with?

点点圈 提交于 2019-12-11 12:56:40
问题 I am working on collision detection for a game, so that if the character runs into an object they stop moving. As part of my solution for this, I have made two functions that iterate through a list of on screen objects to check for collision. The first function (on_key_up) checks for collision when the direction key is held down and then stops character movement when True. The second part of this is another function (on_key_up) that moves the character slightly out of the collision zone so he

HTML5 Canvas 2D Frameworks focusing on collision detection and physics

半腔热情 提交于 2019-12-11 12:24:28
问题 I am looking for the best way to manage objects within the canvas context. For my first project I am looking to do the following: Draw the ground. Drop a circle onto the ground with collision detection and elasticity. Have the circle "explode" subtracting the ground below it(Explosion that alters the ground giving a crater like look). So basically what is the best way to track objects that then get altered by other objects. I'm guessing you could track all of the changes to an object in an

Easy SpriteKit Contact Detection (Space Shooter Game) Not Wotking Properly

自闭症网瘾萝莉.ら 提交于 2019-12-11 12:24:26
问题 I'm trying to make a simple Space Shooter game. The contact should happen either between the torpedo and the alien or the shuttle and the alien. The problem is that this second contact (shuttle vs. alien) only happens after the first kind of contact has happend (torpedo vs. alien) and further more they're not always precise. This is a struct created outside the class struct PhysicsCategory { static let alien : UInt32 = 1 static let torpedo : UInt32 = 2 static let shuttle : UInt32 = 3 }

Java Smooth 2D Rectangle collision?

寵の児 提交于 2019-12-11 12:03:23
问题 Hey guys i'm making a maze game and I'm trying to figure out how to make a 2D collision smooth. Currently I have some really bad collision code that I thought up since I haven't done this part yet and it is glitchy and sometimes goes inside the wall then you can't get out. My code: public void checkCollision() { Rectangle player_rectangle = new Rectangle(player.getX(),player.getY(),32,32); for(Wall wall : walls) { Rectangle wall_rectangle = new Rectangle(wall.getX(), wall.getY(), 32,32); if

Optional unwrapping SKPhysics error

让人想犯罪 __ 提交于 2019-12-11 09:49:54
问题 Before I'm crucified with downvotes let me say I have done research into this and I still cannot understand why I am getting this error. I have a core that the player is trying to defend and you can shoot little lasers out from it to defend against incoming meteors. Well, I have everything set up and working (most of the time anyways), but every once and while when a laser hits a meteor and my collision handling function tries to remove the shot node and meteor node, it throws this error:

How to get coordinates/area of collision in Pygame

好久不见. 提交于 2019-12-11 09:13:12
问题 I have a game where the bullet is moving so fast that in a single frame it is already across the screen. That being said, it has already collided with multiple walls. Currently, I have a rectangular image that spans from where the bullet currently is, to where the bullet will be in the next frame, in order to not miss any zombies that may be in between. I also kill the bullet if it collided with any wall, before checking if it collided with any of the zombies because what happened was that if

GameQuery Collision Detection

梦想与她 提交于 2019-12-11 08:18:38
问题 I am having a problem with GameQuery (jQuery) collision detection Tthey just never seem to fire?!? I have checked all the .arrow's exist and the same for the .bot's but it just never seems to call the function I have the below code in my main callback: $(".bot").each(function(){ $(this).collision(".arrow").each(function(){ alert("Test"); }); }); Do you have any idea why this would just simply be doing nothing? The bot walks (has it's x value) moved right over the arrow. Many thanks, 回答1: Your

Using tiles in SFML and collision detection

匆匆过客 提交于 2019-12-11 08:17:30
问题 I decided to look a good tileset to use and found some, but the question is how I actually load the tile from the image file as there seem to be more than one tile in one file? Also how do I implement a collision detection for non square tiles? Example: Tileset 回答1: Images(sfml1.6) or Textures (sfml2.0) are usually drawn using sf::Sprite . The usual way to do it is to let all sprites share the same tileset texture/image, and then use sf::Sprite::SetSubRect(const IntRect &SubRect) to set the

Collision Detection with Javascript, Canvas, and Alpha Detection

风流意气都作罢 提交于 2019-12-11 08:14:54
问题 I'm currently working on a basic javascript game that has two sprites that are not to be collided together. However, basic bounding box collision won't suffice as there are portions of the sprites that are transparent and wouldn't 'count' as colliding. I found a solution to the problem that I am having, but I can't get it to work. What I would like to do is calculate the transparent portions of the sprites and make sure that if the transparent portions overlap, that there is no collision

Implementing per pixel collision on rotated sprites

有些话、适合烂在心里 提交于 2019-12-11 07:27:00
问题 I am building a 2D game in XNA using C#, and I am using sprites that will track the player's position and rotate accordingly in the spritebatch.Draw() method. I am now trying to implement per-pixel collision detection, and I believe that the rotation of the sprites is throwing it off. The collision checks are as follows. private bool collision(Rectangle object1, Color[,] dataA, Rectangle object2, Color[,] dataB) { if (object1.Bottom < object2.Top) return perPixel(object1, dataA, object2,