Android collision detection -



Android collision detection -

description:

i've got project finished now, i've noticed collision not working. it's snake-like game can controlled via touch-screen, sharp (?, sorry german) angles possible. @ moment leave bit of tolerance (ignore first 2 sprites) enable bit of turning. main problem sprites beingness rotated results in overdimensional collision boxes. i'm not using game engines or opengl.

collision code: offsetx & offsety bitmaps width or height / 2, called on head of snake. each link in snake (bird) placeable

public boolean doeshit(placeable p) { int xlen = math.abs(this.x - p.x); int ylen = math.abs(this.y - p.y); if (bmp != null) { if (xlen < offsetx + p.offsetx && ylen < offsety + p.offsety) homecoming true; } else { if (xlen < bird.big_w[bird.musebird] / 2 && ylen < bird.big_h[bird.musebird] / 2) homecoming true; } homecoming false; }

tl;dr / question:

is there way rotate rects , compare them (preferred, game finished apart this)? or simplest way port opengl / game engine?

the best alternative go opengl , utilize rotated polygons intersects.

however quick hack alter doeshit() routine consider sprites circles instead of rectangles. way not grow outside bounds when rotated. cost collision detecting lousy in corners.

android collision-detection rect

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -