aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGene Pasquet <dev@etenil.net>2025-05-16 21:50:13 +0100
committerGene Pasquet <dev@etenil.net>2025-05-16 21:50:13 +0100
commit4346ec2fa0623132afa7706cfb103e20c7e68494 (patch)
treede44331f43fd4091f3276e5dd1e9fb9b188458a6
parent5af7de084933444951dfb140c084ea07cf3346a8 (diff)
Basic animations
-rw-r--r--TODO.org12
-rw-r--r--src/macroknight/entities.hy17
-rw-r--r--src/macroknight/game.hy3
3 files changed, 24 insertions, 8 deletions
diff --git a/TODO.org b/TODO.org
index da32721..2773fe9 100644
--- a/TODO.org
+++ b/TODO.org
@@ -5,17 +5,17 @@
** TODO Finer macro movement steps to work out collision
* Improvements
-** TODO Display each stage of macro execution with a timer
+** DONE Display each stage of macro execution with a timer
* To do
** TODO Add enemies
** TODO Create enemy classes and behaviour
-** TODO Flip player sprite when moving the other way
+** DONE Flip player sprite when moving the other way
** TODO Animate player sprite
** DONE Add help text
-** TODO Add cool-down for macro ability
-** TODO Create more levels
-** TODO Define entity position on map layer
+** DONE Add cool-down for macro ability
+** DONE Create more levels
+** DONE Define entity position on map layer
** TODO Add a menu
-** TODO Detect win conditions
+** DONE Detect win conditions
** TODO Detect loss conditions
diff --git a/src/macroknight/entities.hy b/src/macroknight/entities.hy
index 666b06b..812193e 100644
--- a/src/macroknight/entities.hy
+++ b/src/macroknight/entities.hy
@@ -54,7 +54,9 @@
(defn __init__ [self id tile tile-size x y]
(.__init__ (super) id tile tile-size x y)
(setv self.jumping False)
- (setv self.jump-move 0))
+ (setv self.jump-move 0)
+ (setv self.moves [])
+ (setv self._disp_surf (.copy self._surf)))
(defn move [self move]
(.append self.moves move)
@@ -72,5 +74,16 @@
(defn ground [self]
(setv self.jump-move 0))
+ (defn animate [self]
+ (let [x-move (get self.total-move 0)]
+ (setv self._disp_surf
+ (cond
+ (< x-move 0) (pygame.transform.flip self._surf True False)
+ (> x-move 0) (.copy self._surf)
+ True self._disp_surf))))
+
(defn flush [self]
- (setv self.moves [])))
+ (setv self.moves []))
+
+ (defn [property] surf [self]
+ self._disp_surf))
diff --git a/src/macroknight/game.hy b/src/macroknight/game.hy
index 1676e5a..005f356 100644
--- a/src/macroknight/game.hy
+++ b/src/macroknight/game.hy
@@ -139,11 +139,14 @@
pygame.K_w (.jump player)
pygame.K_d (.move player #(player.SPEED 0))))
+
+
(try
(when (any ongoing_inputs)
(for [entity entities]
(apply-collisions entity entities)))
+ (.animate player)
(.flush player)
;; Apply systems