From 00af64d4e503dd82abf4657ec6fd44b0a418adb2 Mon Sep 17 00:00:00 2001 From: equa Date: Mon, 19 Apr 2021 20:39:21 -0500 Subject: cool bullets --- lib/game.fnl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/game.fnl') diff --git a/lib/game.fnl b/lib/game.fnl index b75a254..3f99550 100644 --- a/lib/game.fnl +++ b/lib/game.fnl @@ -51,7 +51,9 @@ :player {:up (love.keyboard.isDown :up) :right (love.keyboard.isDown :right) - :left (love.keyboard.isDown :left)})) + :left (love.keyboard.isDown :left) + :shoot (love.keyboard.isDown :z) + })) ;; entities (each [id e (pairs self.entities)] (tset e entity.position (vec.wrap @@ -62,7 +64,10 @@ t (. self.grid x y)] (when t (entity.collide e self id x y))) - ) + (when (entity.duration e) + (tset e entity.duration (- (entity.duration e) 1)) + (if (= (entity.duration e) 0) + (tset self.entities id nil)))) ) (fn id [x] x) @@ -128,7 +133,10 @@ (each [id v (pairs self.entities)] (love.graphics.push) (let [pos (entity.position v) - render-pos (vec.lerp camera-a camera-b display-a display-b pos)] + render-pos (vec.lerp camera-a camera-b display-a display-b + (vec.add camera-a + (vec.wrap (vec.sub pos camera-a) + (vec.sub camera-b camera-a))))] (love.graphics.translate render-pos.x render-pos.y) (love.graphics.scale cell-box.x cell-box.y)) @@ -172,9 +180,9 @@ :rate 6 :entities {:player (entity.init player {:x 32 :y 32})} :grid (new-grid width height #(if (= (math.random 6) 1) - (if (> $1 34) + (if (> $1 44) (cell.init cells.life) - (< $1 00) + (< $1 10) (cell.init cells.brain) nil) nil)) -- cgit 1.3.0-6-gf8a5