java - Collision Detection for fast-moving objects -


I am writing my first game for Android, and there is an issue with conflict investigation. The game has a scrolling scene in which the block leaps, and should be dependent on tall buildings. The problem is that the block is often terminated through the floor, because the frames are not updated fast, I have tried to detect a collision in a different thread, and when it seems to be a bit different, it is still not great is. When I manually compensate by setting the height for the next frame, I'm afraid that for a slower device than my Nexus 5, the object will easily fall through the building because it is sometimes on this device My code is as follows:

  Public zero physics () {// player generated rectangle player.set (x1, y1, x2, y2); // Check Building Rectangle (player.intersects (x1, y1, x2, y2)) {character.collide (); }}  

Can anyone tell me in the right direction to detect it with accuracy? I can not find any answer that is in line with my needs. Thanks!

Assume that objects are synchronized in each stage of the X or Y velocity object, "Received "Object (ground or wall, for example) should be larger width or height than the moving object.

If your object increases every phase of X coordinate 1000, and its width is only 32, it is highly unlikely that the range of throwing will surround each other with the wall, for example: < / P>

  Public projectile can be  may  be. Void onStep () (for wall wall: wall_items) // Be sure wall_items are iserable {// wall (wall.x> this.x == incorrect) Do not modify the walls after or after it; If (wall.y> this.y == incorrect) will continue; // Skip and turn on the loop wall. Wide = this.width + this.velocity_x; Wall.height = this.height + this.velocity_y; } This.x + = this.velocity_x; This.y + = this.velocity_y; }  

Now, when the throw is going on, then you should fly in the boundary of the throwing wall that is on the way to throw the flight. I hope this will give you a better sense of collision detection.

Edit: To check whether the walls are behind or above projectile, continue not back , As you still want to be in the onStep () method. my apology.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -