collision-detection

Java game - how to stop player from walking over obstacles

元气小坏坏 提交于 2020-01-04 05:18:12
问题 I have made a very simple 2D Java game class made up of the general 2D game methods such as render and update, I have set up all my if statements so that the player moves around the map with the keyboard arrow input. I am now trying to set up what I have read is a collision detection, I know the basics of what I need to do because I did a lot of reading before I actually came here to ask the question, from what I have read it goes something like this: Make 2 rectangles Rectangle rectOne = new

Detecting the point of collision with Pygame

╄→гoц情女王★ 提交于 2020-01-04 05:14:17
问题 I am making a game with Pygame. For this game I need to be able to detect not only that two rectangles have collided, but also the point of collision between them. I looked at the documentation but couldn't seem to find any answers. Is something like this possible? 回答1: You can use Rect.clip: crops a rectangle inside another clip(Rect) -> Rect Returns a new rectangle that is cropped to be completely inside the argument Rect. If the two rectangles do not overlap to begin with, a Rect with 0

Should games rely on frame rate only?

亡梦爱人 提交于 2020-01-04 03:15:08
问题 I would like your suggestion about this problem... To make it simple, I'll consider only the x axis. Image an object in position 10, and its width also 10 units, which is moving forward 100 units per second, and due to low frame, on each update it should move 80 units. After the first update is called, its position is now 90 and there is another object of the same size in position 120. The next update, will move the object to position 170. Considering that I need to implement collision

Java More Resourceful Collision Detection

纵饮孤独 提交于 2020-01-04 02:52:07
问题 I am making a game in java which involves characters moving around a map and having some solid collision objects (i.e. buildings) placed around the map by reading certain data from a text file. There will be multiple maps where these objects' locations will change. My question is would painting a rectangle in a certain color that indicates collision behind such structures or would reading mouse coordinates and searching an array of these structures to see if that point lies on a building,

Collision detection between a BoundingBox and a Sphere in libgdx

南楼画角 提交于 2020-01-02 09:58:40
问题 In my libgdx game I have 3D BoundingBoxes and Spheres for map and player objects. I want to calculate whether they collide with each other in order to properly simulate the motion of these objects. What method can I use to calculate whether these objects collide/intersect? 回答1: You can use the following method: public static boolean intersectsWith(BoundingBox boundingBox, Sphere sphere) { float dmin = 0; Vector3 center = sphere.center; Vector3 bmin = boundingBox.getMin(); Vector3 bmax =

Sprite Kit Physics Collision Issue

自古美人都是妖i 提交于 2020-01-02 03:47:06
问题 I'm having an issue with some collisions. I have two objects equal size and mass. When one collides into another that is at rest I get the correct behavior (grey area in image). When I have two objects that are next to each other the behavior isn't quite right. Spritekit result on the left. Expected/needed result on right. I think I know what is going on, but not sure what to do about it. If the object was one object with twice the mass then the spritekit behavior would be correct, but they

Distinguish between collision surface orientations in box2d

孤街浪徒 提交于 2020-01-01 19:16:25
问题 I've been working on an iOS project, using Cocos2D 1.0 and Box2D, and I've run into a bit of a problem. What I need to be able to do is determine the orientation of a surface my player has hit. For example, if we have a rectangular platform, and the player collides with it, I need to know whether the player has hit the left, right, top, or bottom face of it. ALL the objects in the game are square, and the ONLY one moving is the player. I'm currently using a b2ContactListener in Box2D (well,

Add collision detection to a plattformer in pygame

拟墨画扇 提交于 2020-01-01 18:20:51
问题 I'm working on a small platformer game in which you place blocks to make a level, then play it. I got gravity, jumping, and left and right movement.. but I am not sure how to make the player collide with walls when moving left or right. The way I want it to work is like this- if key[K_LEFT]: if not block to the left: move to the left How would I go about doing this (relative to this source): import pygame,random from pygame.locals import * import itertools pygame.init() screen=pygame.display

Java/libGDX - how to check Polygon collision with Rectangle or Circle

隐身守侯 提交于 2020-01-01 11:42:11
问题 I'm new to libGDX and from what I can tell the Intersector class has overlap methods for Rectangle/Rectangle, Circle/Circle, Circle/Rectangle, and Polygon/Polygon, but for some reason it doesn't seem to have any methods for checking Polygon/Rectangle or Polygon/Circle. Is there a recommended way to check for collision between polygon and rect/circle? Also, is there some reason why this has been left out of the Intersector class? (ie, should I avoid it? If so, what's the recommended

Suggestions for .Net 3D physics engine [closed]

梦想与她 提交于 2020-01-01 09:01:54
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I need physics engine to simulate game world on server. I googled for .Net physics engines and they all were released in 2006-2009. So