diff options
| -rw-r--r-- | TODO.org | 4 | ||||
| -rw-r--r-- | assets/level-0.tmx | 2 | ||||
| -rw-r--r-- | src/macroknight/game.hy | 44 | 
3 files changed, 35 insertions, 15 deletions
| @@ -2,6 +2,7 @@  ** DONE Collision detection when moving sideways and jumping  ** DONE Resolve collisions between each macro move  ** DONE Amount of movement from macros +** TODO Finer macro movement steps to work out collision  * Improvements  ** TODO Display each stage of macro execution with a timer @@ -15,3 +16,6 @@  ** TODO Add cool-down for macro ability  ** TODO Create more levels  ** TODO Define entity position on map layer +** TODO Add a menu +** TODO Detect win conditions +** TODO Detect loss conditions diff --git a/assets/level-0.tmx b/assets/level-0.tmx index f386d93..6ddf38f 100644 --- a/assets/level-0.tmx +++ b/assets/level-0.tmx @@ -21,7 +21,7 @@  1917,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1712,0,0,0,  1870,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1868,0,0,0,  1868,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1869,1570,1570,1570, -1870,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1025,1025,1025,1025,1025,0,0,0,0,0,0,0,0,0,1868,1868,1868,1868, +1870,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1868,1868,1868,1868,  1868,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1468,1868,1868,1868,  1572,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1239,1044,1044,1043,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,1044,  1044,1044,1044,1044,1045,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1766,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, diff --git a/src/macroknight/game.hy b/src/macroknight/game.hy index 99dc69f..1c10c95 100644 --- a/src/macroknight/game.hy +++ b/src/macroknight/game.hy @@ -13,6 +13,8 @@  (setv TILE_SCALING 1)  (setv TILE_SIZE (* TILE_SCALING 16)) +(setv MACRO_STEP_WAIT 300) +(setv MACRO_COOLDOWN 5000)  (setv screen (pygame.display.set_mode #((* TILE_SCALING 640) (* TILE_SCALING 480))))  (setv clock (pygame.time.Clock)) @@ -32,6 +34,7 @@  (setv player (Player 1 (get tileset.tiles 28) TILE_SIZE #* player-pos))  (.append sprites-group player)  (setv macro-input-mode False) +(setv macro-wait-time 0)  (setv macro-commands [None None None])  (for [tiledef (enumerate (.tiles (get level.layers 0)))] @@ -48,9 +51,9 @@                               (if macro-input-mode                                   (when (in event.key [pygame.K_a pygame.K_w pygame.K_a pygame.K_s pygame.K_d])                                     (setv (get macro-commands (.index macro-commands None)) event.key)) -                                 (case event.key -                                       pygame.K_SPACE (setv macro-input-mode True) -                                       else (.append ongoing_inputs event.key)))) +                                 (if (and (= event.key pygame.K_SPACE) (= macro-wait-time 0)) +                                     (setv macro-input-mode True) +                                     (.append ongoing_inputs event.key))))            pygame.KEYUP (when (in event.key ongoing_inputs)                           (.remove ongoing_inputs event.key)))) @@ -73,14 +76,16 @@            (do              (let [#(command-id command) (get (lfor command (enumerate macro-commands) :if (get command 1) command) 0)]                (case command -                    pygame.K_a (.move player #((neg TILE_SIZE) 0)) -                    pygame.K_s (.move player #(0 1)) +                    pygame.K_a (.move player #((neg (* 2 TILE_SIZE)) 0)) +                    pygame.K_s (.move player #(0 TILE_SIZE))                      pygame.K_w (.move player #(0 (neg (/ player.MAX_JUMPING 2)))) -                    pygame.K_d (.move player #(TILE_SIZE 0))) +                    pygame.K_d (.move player #((* 2 TILE_SIZE) 0)))                (if (= command-id (- (len macro-commands) 1))                    (do  (setv macro-commands [None None None]) -                       (setv macro-input-mode False)) -                  (setv (get macro-commands command-id) None)))) +                       (setv macro-input-mode False) +                       (setv macro-wait-time (+ (pygame.time.get_ticks) MACRO_COOLDOWN))) +                  (setv (get macro-commands command-id) None))) +            (pygame.time.wait MACRO_STEP_WAIT))            ;; If there's still space in the commands list            (for [#(num command) (enumerate macro-commands)] @@ -93,12 +98,18 @@                      None (draw-tile screen tileset 725 x-pos 5)))))        ;; Not in macro mode -      (do (for [inp ongoing_inputs] -            (case inp -                  pygame.K_a (.move player #((neg player.SPEED) 0)) -                  pygame.K_s (.move player #(0 1)) -                  pygame.K_w (.jump player) -                  pygame.K_d (.move player #(player.SPEED 0)))) +      (do +        (when (> macro-wait-time 0) +          (let [progress (round (* 3 (/ (- (pygame.time.get_ticks) macro-wait-time) MACRO_COOLDOWN)))] +            (for [indicator (range 3)] +              (draw-tile +                screen tileset 725 )))) +        (for [inp ongoing_inputs] +          (case inp +                pygame.K_a (.move player #((neg player.SPEED) 0)) +                pygame.K_s (.move player #(0 1)) +                pygame.K_w (.jump player) +                pygame.K_d (.move player #(player.SPEED 0))))            (when (any ongoing_inputs)              (for [sprite sprites-group] @@ -118,6 +129,11 @@      (.blit screen sprite.surf sprite.rect))    (pygame.display.flip) + +  (when (or (= 0 macro-wait-time) +            (< (- (pygame.time.get_ticks) macro-wait-time) 0)) +    (setv macro-wait-time 0)) +    (.tick clock 60))  (pygame.quit) | 
