Implement simple swarm mechanics

This commit is contained in:
jgk
2021-05-14 20:28:53 +02:00
parent 2b09bf2072
commit c5657fe855
8 changed files with 75 additions and 37 deletions
+2 -2
View File
@@ -187,9 +187,9 @@ crCrSpring :: Creature -> Creature -> World -> World
crCrSpring c1 c2 w
| id1 == id2 = w
| vec == (0,0) = w
| diff < comRad = over (creatures . ix id1 . crPos) (+.+ overlap1)
| diff >= comRad = w
| otherwise = over (creatures . ix id1 . crPos) (+.+ overlap1)
$ over (creatures . ix id2 . crPos) (-.- overlap2) w
| otherwise = w
where
id1 = _crID c1
id2 = _crID c2