From c44bcbe373f70a5a82da1117cc5239e323f104f3 Mon Sep 17 00:00:00 2001 From: Gene Pasquet Date: Fri, 16 May 2025 19:57:20 +0100 Subject: WIP again --- src/macroknight/entities.hy | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/macroknight/entities.hy') diff --git a/src/macroknight/entities.hy b/src/macroknight/entities.hy index 1ac59ce..50d774c 100644 --- a/src/macroknight/entities.hy +++ b/src/macroknight/entities.hy @@ -7,14 +7,14 @@ ;;; Game entity (setv _fixed False) - (defn __init__ [self id tile tile-size initial-pos] + (defn __init__ [self id tile tile-size x y] (.__init__ (super)) (setv self.id id) (setv self._surf (Surface #(tile-size tile-size))) (.blit self._surf tile #(0 0)) (setv self._rect (.get_rect self._surf - :left (* (get initial-pos 0) tile-size) - :top (* (get initial-pos 1) tile-size)))) + :left (* x tile-size) + :top (* y tile-size)))) (defn [property] fixed [self] self._fixed) @@ -28,21 +28,24 @@ (defclass LevelTile [Entity] (setv _fixed True) - (defn __init__ [self id tile-size scaling x y tile] + (defn __init__ [self id tile tile-size x y scaling] (let [tile-width (* (.get_width tile) scaling) tile-height (* (.get_height tile) scaling) tile_ (if (!= scaling 1) (pygame.transform.scale tile #(tile-width tile-height)) tile)] - (.__init__ (super) id tile_ tile-size #(x y))))) + (.__init__ (super) id tile_ tile-size x y)))) + +(defclass Goal [Entity] + (setv _fixed True)) (defclass Player [Entity] (setv SPEED 3) (setv JUMP_IMPULSE 10) (setv MAX_JUMPING 100) - (defn __init__ [self id tile tile-size initial-x initial-y] - (.__init__ (super) id tile tile-size #(initial-x initial-y)) + (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)) -- cgit v1.2.3