Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #undef boolean
- #undef true
- #undef false
- #define boolean ubyte
- #define true 1
- #define false 0
- type Pnt
- as integer x
- as integer y
- end type
- type Rect
- as Pnt position
- as Pnt size
- end type
- function rectIntersects(r1 as Rect ptr, r2 as Rect ptr) as boolean
- #define r1p r1->position
- #define r1s r1->size
- #define r2p r2->position
- #define r2s r2->size
- if(r1p.x < r2p.x+r2s.x ORELSE r1p.x+r1s.x > r2p.x) then return false
- if(r1p.y < r2p.y+r2s.y ORELSE r1p.y+r1s.y > r2p.y) then return false
- 'if(r1->position.x > r2->position.x + r2->size.x OR r2->position.x > r1->position.x + r1->size.x) then return false
- 'if(r1->position.y < r2->position.y + r2->size.y OR r2->position.y < r1->position.y + r1->size.y) then return false
- return true
- end function
- function createRect(x as integer, y as integer, w as integer, h as integer) as Rect
- return type<Rect>(type<Pnt>(x,y),type<Pnt>(w,h))
- end function
- 'createRect(x, y, width, height)
- dim as Rect r1 = any, r2 = any
- r1 = createRect(50,50,50,50)
- r2 = createRect(75,75,50,50)
- print(str(rectIntersects(@r1, @r2)))
- sleep()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement