소스 검색

Merge pull request #622 from Joefish/rectcollision-optim

Shapes: Simplifies CheckCollisionRecs
pull/628/head
Ray 7 년 전
committed by GitHub
부모
커밋
20ff9dc663
No known key found for this signature in database GPG 키 ID: 4AEE18F83AFDEB23
1개의 변경된 파일5개의 추가작업 그리고 8개의 파일을 삭제
  1. +5
    -8
      src/shapes.c

+ 5
- 8
src/shapes.c 파일 보기

@ -646,14 +646,11 @@ bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2
// Check collision between two rectangles
bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2)
{
bool collision = false;
float dx = (float)fabs((rec1.x + rec1.width/2) - (rec2.x + rec2.width/2));
float dy = (float)fabs((rec1.y + rec1.height/2) - (rec2.y + rec2.height/2));
if ((dx <= (rec1.width/2 + rec2.width/2)) && ((dy <= (rec1.height/2 + rec2.height/2)))) collision = true;
return collision;
if ((rec1.x <= (rec2.x + rec2.width) && (rec1.x + rec1.width) >= rec2.x) &&
(rec1.y <= (rec2.y + rec2.height) && (rec1.y + rec1.height) >= rec2.y))
return true;
else
return false;
}
// Check collision between two circles

불러오는 중...
취소
저장