Explorar o código

Add ally tombs spawning

Lily Carpenter %!s(int64=9) %!d(string=hai) anos
pai
achega
d146e2c1d8
Modificáronse 2 ficheiros con 15 adicións e 0 borrados
  1. 1 0
      NOTES.org
  2. 14 0
      src/crypts-and-corpses.lisp

+ 1 - 0
NOTES.org

@@ -8,6 +8,7 @@ CLOSED: [2016-01-01 Fri 22:52]
8 8
 ** High Priority
9 9
 *** TODO Randomly place ally tombs
10 10
 - [ ] Player can wake up allies by entering room
11
+*** TODO Base random placement off center of room, not edges.
11 12
 *** TODO Create enemy AI
12 13
 - [ ] Detect whether player can be seen
13 14
 - [ ] Move to player

+ 14 - 0
src/crypts-and-corpses.lisp

@@ -77,6 +77,10 @@
77 77
    (health-regen :initarg :health-regen :initform 1 :type fixnum)
78 78
    (color :initarg :color :initform (color-from-name "#1919ff"))))
79 79
 
80
+(defclass tomb (tile-entity)
81
+  ((codepoint :initform #x2616)
82
+   (color :initform (color-from-name "yellow"))))
83
+
80 84
 (defclass minion (mobile)
81 85
   ((color :initarg :color :initform (color-from-name "yellow"))))
82 86
 
@@ -448,10 +452,20 @@
448 452
                 (when location
449 453
                   (setf (gethash location (game-map-mobiles map)) enemy)))))))
450 454
 
455
+(defun spawn-tombs (map)
456
+  (loop for room in (crawler::rooms (game-map-dungeon map)) do
457
+    (with-slots ((x1 crawler::x1) (x2 crawler::x2) (y1 crawler::y1) (y2 crawler::y2)) room
458
+      (when (= 2 (random 5))
459
+        (let* ((location (nearest-open-tile (gethash (calc-location x2 y2 map) (game-map-terrain map)) map))
460
+               (tomb (make-instance 'tomb :location location)))
461
+                (when location
462
+                  (setf (gethash location (game-map-terrain map)) tomb)))))))
463
+
451 464
 (defun initialize-map (map player)
452 465
   (fill-map-from-crawler map player)
453 466
   (setf (gethash (slot-value player 'location) (game-map-mobiles map)) player)
454 467
   (spawn-enemies map player)
468
+  (spawn-tombs map)
455 469
   map)
456 470
 
457 471
 (defun get-neighbors (tile map layer &key (filter-fun #'identity))