trying to shove things around
This commit is contained in:
parent
337fcf9cd0
commit
b53d93b608
2 changed files with 34 additions and 21 deletions
|
@ -182,27 +182,37 @@ class (Show c, Mass c) => Collidible c where
|
||||||
NoCollision ->
|
NoCollision ->
|
||||||
if overlap
|
if overlap
|
||||||
then
|
then
|
||||||
let xoverlap = floor (maximum (filter (0 >)
|
let xoverlap = floor $ -- (maximum (filter (0 >)
|
||||||
[ pm2b2x - pm2b1x
|
-- [
|
||||||
, pm2b1x - pm1b2x
|
pm2b2x - pm2b1x
|
||||||
]))
|
-- , pm2b1x - pm1b2x
|
||||||
yoverlap = floor (maximum (filter (0 >)
|
-- ]))
|
||||||
[ pm2b1y - pm1b2y
|
yoverlap = floor $ -- (maximum (filter (0 >)
|
||||||
, pm2b2y - pm1b1y
|
-- [
|
||||||
]))
|
pm2b1y - pm1b2y
|
||||||
|
-- , pm2b2y - pm1b1y
|
||||||
|
-- ]))
|
||||||
in
|
in
|
||||||
if xoverlap < yoverlap
|
case (xoverlap < 0, yoverlap < 0) of
|
||||||
then
|
(True, True) ->
|
||||||
if xoverlap < 0
|
if xoverlap < yoverlap
|
||||||
then OverlapCollision
|
then
|
||||||
(V2 xoverlap 0)
|
if xoverlap < 0
|
||||||
else
|
then OverlapCollision
|
||||||
|
(V2 xoverlap 0)
|
||||||
|
else
|
||||||
|
NoCollision
|
||||||
|
else
|
||||||
|
if yoverlap < 0
|
||||||
|
then OverlapCollision
|
||||||
|
(V2 0 yoverlap)
|
||||||
|
else NoCollision
|
||||||
|
(True, False) ->
|
||||||
|
OverlapCollision (V2 xoverlap 0)
|
||||||
|
(False, True) ->
|
||||||
|
OverlapCollision (V2 0 yoverlap)
|
||||||
|
(False, False) ->
|
||||||
NoCollision
|
NoCollision
|
||||||
else
|
|
||||||
if yoverlap < 0
|
|
||||||
then OverlapCollision
|
|
||||||
(V2 0 yoverlap)
|
|
||||||
else NoCollision
|
|
||||||
else NoCollision
|
else NoCollision
|
||||||
_ -> A.log
|
_ -> A.log
|
||||||
A.Error
|
A.Error
|
||||||
|
@ -255,8 +265,10 @@ elasticCollision damping mo1 (mo2, OverlapCollision depth) dt =
|
||||||
let m1 = mass mo1
|
let m1 = mass mo1
|
||||||
m2 = mass mo2
|
m2 = mass mo2
|
||||||
(V2 dx dy) = (/ dt) . fromIntegral <$> depth
|
(V2 dx dy) = (/ dt) . fromIntegral <$> depth
|
||||||
v1x' = 2 * (m1 * dx + m2 * (-dx)) / (m1 + m2) - dx
|
-- v1x' = 2 * (m1 * dx + m2 * (-dx)) / (m1 + m2) - dx
|
||||||
v1y' = 2 * (m1 * dy + m2 * (-dy)) / (m1 + m2) - dy
|
-- v1y' = 2 * (m1 * dy + m2 * (-dy)) / (m1 + m2) - dy
|
||||||
|
v1x' = 2 * (m1 * dx) / (m1 + m2)
|
||||||
|
v1y' = 2 * (m1 * dy) / (m1 + m2)
|
||||||
nvel = if m1 == recip 0
|
nvel = if m1 == recip 0
|
||||||
then V2 0 0
|
then V2 0 0
|
||||||
else (damping *) <$>
|
else (damping *) <$>
|
||||||
|
|
|
@ -174,6 +174,7 @@ instance Mass Pituicat where
|
||||||
move dt cat =
|
move dt cat =
|
||||||
let dpos = (dt *) <$> velocity cat
|
let dpos = (dt *) <$> velocity cat
|
||||||
mpos = (dt *) <$>
|
mpos = (dt *) <$>
|
||||||
|
-- pcMoveVel cat
|
||||||
(if pcXColl cat then V2 (-1) 1 else V2 1 1) * pcMoveVel cat
|
(if pcXColl cat then V2 (-1) 1 else V2 1 1) * pcMoveVel cat
|
||||||
in
|
in
|
||||||
positionUpdater cat (position cat + dpos + mpos)
|
positionUpdater cat (position cat + dpos + mpos)
|
||||||
|
|
Loading…
Reference in a new issue