switch to circle based collision
This commit is contained in:
parent
92569c2345
commit
d91f4bf9c1
1 changed files with 31 additions and 31 deletions
62
src/Test.hs
62
src/Test.hs
|
@ -250,34 +250,34 @@ checkBoundsCollision
|
||||||
checkBoundsCollision
|
checkBoundsCollision
|
||||||
pos@(V2 or oc) npos@(V2 fr fc) acc@(V2 mr mc)
|
pos@(V2 or oc) npos@(V2 fr fc) acc@(V2 mr mc)
|
||||||
(Boundaries (minr, minc) (maxr, maxc))
|
(Boundaries (minr, minc) (maxr, maxc))
|
||||||
| (fr - fromIntegral (floor fr) >= minr &&
|
| ntestr && ntestc && not testr = V2 (0 * mr) (1 * mc)
|
||||||
fr - fromIntegral (floor fr) <= maxr) &&
|
| ntestc && ntestr && not testc = V2 (1 * mr) (0 * mc)
|
||||||
(fc - fromIntegral (floor fc) >= minc &&
|
| not ntestr && not ntestc = V2 (1 * mr) (1 * mc)
|
||||||
fc - fromIntegral (floor fc) <= maxc) &&
|
| not ntestr && ntestc = V2 (1 * mr) (1 * mc)
|
||||||
(or - fromIntegral (floor or) < minr ||
|
| not ntestc && ntestr = V2 (1 * mr) (1 * mc)
|
||||||
or - fromIntegral (floor or) > maxr) =
|
| otherwise = V2 (0 * mr) (0 * mc)
|
||||||
(V2 (0 * mr) (1 * mc))
|
where
|
||||||
| (fr - fromIntegral (floor fr) >= minr &&
|
ntestr
|
||||||
fr - fromIntegral (floor fr) <= maxr) &&
|
| ndistr <= hheight + 0.07 = True
|
||||||
(fc - fromIntegral (floor fc) >= minc &&
|
| ncdistsq <= 0.005 = True
|
||||||
fc - fromIntegral (floor fc) <= maxc) &&
|
| otherwise = False
|
||||||
(oc - fromIntegral (floor oc) < minc ||
|
ntestc
|
||||||
oc - fromIntegral (floor oc) > maxc) =
|
| ndistc <= hwidth + 0.07 = True
|
||||||
(V2 (1 * mr) (0 * mc))
|
| ncdistsq <= 0.005 = True
|
||||||
| (fr - fromIntegral (floor fr) < minr ||
|
| otherwise = False
|
||||||
fr - fromIntegral (floor fr) > maxr) &&
|
testr
|
||||||
(fc - fromIntegral (floor fc) < minc ||
|
| distr <= hheight + 0.07 = True
|
||||||
fc - fromIntegral (floor fc) > maxc) =
|
| cdistsq <= 0.005 = True
|
||||||
(V2 (1 * mr) (1 * mc))
|
| otherwise = False
|
||||||
| (fr - fromIntegral (floor fr) < minr ||
|
testc
|
||||||
fr - fromIntegral (floor fr) > maxr) &&
|
| distc <= hwidth + 0.07 = True
|
||||||
(fc - fromIntegral (floor fc) >= minc &&
|
| cdistsq <= 0.005 = True
|
||||||
fc - fromIntegral (floor fc) <= maxc) =
|
| otherwise = False
|
||||||
(V2 (1 * mr) (1 * mc))
|
ndistr = abs ((fr - fromIntegral (floor fr)) - (minr + hheight))
|
||||||
| (fr - fromIntegral (floor fr) >= minr &&
|
ndistc = abs ((fc - fromIntegral (floor fc)) - (minc + hwidth))
|
||||||
fr - fromIntegral (floor fr) <= maxr) &&
|
distr = abs ((or - fromIntegral (floor or)) - (minr + hheight))
|
||||||
(fc - fromIntegral (floor fc) < minc ||
|
distc = abs ((oc - fromIntegral (floor oc)) - (minc + hwidth))
|
||||||
fc - fromIntegral (floor fc) > maxc) =
|
hheight = (maxr - minr) / 2
|
||||||
(V2 (1 * mr) (1 * mc))
|
hwidth = (maxc - minc) / 2
|
||||||
| otherwise =
|
ncdistsq = (ndistr - hheight) ^ 2 + (ndistc - hwidth) ^ 2
|
||||||
(V2 (0 * mr) (0 * mc))
|
cdistsq = (distr - hheight) ^ 2 + (distc - hwidth) ^ 2
|
||||||
|
|
Loading…
Reference in a new issue