aboutsummaryrefslogtreecommitdiff
path: root/src/macroknight/systems.hy
diff options
context:
space:
mode:
authorGene Pasquet <dev@etenil.net>2025-05-16 19:57:20 +0100
committerGene Pasquet <dev@etenil.net>2025-05-16 19:57:20 +0100
commitc44bcbe373f70a5a82da1117cc5239e323f104f3 (patch)
tree9606a3dc1827b21768c4c42de8eb851b3f4e644d /src/macroknight/systems.hy
parentcbb2602ed9dedf973ddbf6d769b11c666de2ea22 (diff)
WIP again
Diffstat (limited to 'src/macroknight/systems.hy')
-rw-r--r--src/macroknight/systems.hy23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/macroknight/systems.hy b/src/macroknight/systems.hy
index 2762247..b02bc50 100644
--- a/src/macroknight/systems.hy
+++ b/src/macroknight/systems.hy
@@ -6,15 +6,14 @@
(.move entity #(0 GRAVITY))))
(defn apply-collisions [entity entities]
- (for [ent entities]
- (when (and (!= ent.id entity.id)
- (.colliderect entity.rect ent.rect)
- (not entity.fixed))
- (let [collision-rect (.clip entity.rect ent.rect)
- move-x (get entity.total-move 0)
- move-y (get entity.total-move 1)]
- (when (!= move-x 0)
- (.move entity #((* (if (> move-x 0) -1 1) collision-rect.width) 0)))
- (when (!= move-y 0)
- (.move entity #(0 (* (if (> move-y 0) -1 1) collision-rect.height)))))
- (.ground entity))))
+ (when (not entity.fixed)
+ (for [ent (gfor enti entities :if (!= enti.id entity.id) enti)]
+ (when (.colliderect entity.rect ent.rect)
+ (let [collision-rect (.clip entity.rect ent.rect)
+ move-x (get entity.total-move 0)
+ move-y (get entity.total-move 1)]
+ (when (!= move-x 0)
+ (.move entity #((* (if (> move-x 0) -1 1) collision-rect.width) 0)))
+ (when (!= move-y 0)
+ (.move entity #(0 (* (if (> move-y 0) -1 1) collision-rect.height)))))
+ (.ground entity)))))