50624f6d57d7

Add item pickup
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 07 Jan 2017 20:57:30 +0000
parents dd9a7ef86a21
children 2ee2dd0a706f
branches/tags (none)
files src/config.lisp src/entities/player.lisp src/main.lisp

Changes

--- a/src/config.lisp	Sat Jan 07 20:50:14 2017 +0000
+++ b/src/config.lisp	Sat Jan 07 20:57:30 2017 +0000
@@ -7,7 +7,7 @@
 (defparameter *noise-seed-x* (random 1000.0))
 (defparameter *noise-seed-y* (random 1000.0))
 
-(defparameter *ruin-density* 1/1000)
+(defparameter *ruin-density* 1/20000)
 (defparameter *ruin-size-mean* 10.0)
 (defparameter *ruin-size-dev* 2.0)
 (defparameter *graffiti-chance* 1/10)
--- a/src/entities/player.lisp	Sat Jan 07 20:50:14 2017 +0000
+++ b/src/entities/player.lisp	Sat Jan 07 20:57:30 2017 +0000
@@ -35,7 +35,10 @@
 
 (defun tick-player (player)
   (zapf (player/energy player) (clamp 0.0 100.0 (- % 0.1))
-        (player/health player) (clamp 0.0 100.0 (+ % 0.1))))
+        (player/health player) (clamp 0.0 100.0
+                                      (+ % (if (minusp (player/energy player))
+                                             -0.1
+                                             0.1)))))
 
 
 (defun player-inventory-full-p (player)
--- a/src/main.lisp	Sat Jan 07 20:50:14 2017 +0000
+++ b/src/main.lisp	Sat Jan 07 20:57:30 2017 +0000
@@ -375,10 +375,17 @@
     (when (passablep (aref *structures* dest-x dest-y))
       (coords-move-entity player dest-x dest-y))))
 
+(defun get-items ()
+  (iterate (for item :in (remove-if-not #'holdable? (coords-nearby *player* 0)))
+           (until (player-inventory-full-p *player*))
+           (player-get *player* item)))
+
+
 (defun world-map-input (window)
   (case (charms:get-char window)
     (#\q :quit)
     (#\h :help)
+    (#\g (get-items) :tick)
     (:left  (move-player -1 0) :tick)
     (:right (move-player 1 0) :tick)
     (:up    (move-player 0 -1) :tick)