Skip to content

Commit

Permalink
faster skels
Browse files Browse the repository at this point in the history
  • Loading branch information
David O'Toole committed Dec 14, 2009
1 parent 8ccbe05 commit e71605b
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 99 deletions.
45 changes: 23 additions & 22 deletions blast/blast.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@

(defpackage :blast
(:documentation "Blast Tactics: A sci-fi roguelike for Common Lisp.")
(:use :rlx :common-lisp)
(:use :xe2 :common-lisp)
(:export blast))

(in-package :blast)

;;; Custom bordered viewport

(define-prototype view (:parent rlx:=viewport=))
(define-prototype view (:parent xe2:=viewport=))

(define-method render view ()
[parent>>render self]
(rlx:draw-rectangle 0 0
(xe2:draw-rectangle 0 0
<width>
<height>
:color ".blue" :destination <image>))
Expand All @@ -48,7 +48,7 @@

;;; Controlling the game.

(define-prototype blast-prompt (:parent rlx:=prompt=))
(define-prototype blast-prompt (:parent xe2:=prompt=))

(defparameter *basic-keybindings*
'(("KP7" nil "move :northwest .")
Expand Down Expand Up @@ -167,7 +167,8 @@

(defparameter *alternate-qwerty-keybindings*
(append *basic-keybindings*
'(("Q" nil "move :northwest .")
'(
("Q" nil "move :northwest .")
("W" nil "move :north .")
("E" nil "move :northeast .")
("A" nil "move :west .")
Expand Down Expand Up @@ -270,7 +271,7 @@
("Q" (:control) "quit ."))))

(define-method install-keybindings blast-prompt ()
(let ((keys (ecase rlx:*user-keyboard-layout*
(let ((keys (ecase xe2:*user-keyboard-layout*
(:qwerty *qwerty-keybindings*)
(:alternate-qwerty *alternate-qwerty-keybindings*)
(:dvorak *dvorak-keybindings*))))
Expand All @@ -285,7 +286,7 @@
(defvar *ship-status* nil)
(defvar *dude-status* nil)

(define-prototype status (:parent rlx:=formatter=)
(define-prototype status (:parent xe2:=formatter=)
(character :documentation "The character cell."))

(define-method set-character status (character)
Expand Down Expand Up @@ -441,7 +442,7 @@
(define-prototype splash (:parent =widget=))

(define-method render splash ()
(rlx:draw-resource-image "splash" 0 0
(xe2:draw-resource-image "splash" 0 0
:destination <image>))

(defvar *space-bar-function*)
Expand All @@ -452,7 +453,7 @@
(when (functionp *space-bar-function*)
(funcall *space-bar-function*))
;; TODO ugh this is a hack!
(rlx:show-widgets))
(xe2:show-widgets))

(define-prototype splash-prompt (:parent =prompt=)
(default-keybindings :initform '(("SPACE" nil "dismiss ."))))
Expand All @@ -469,14 +470,14 @@
(defparameter *tile-size* 16)

(defun blast ()
(rlx:message "Initializing Blast Tactics...")
(xe2:message "Initializing Blast Tactics...")
(setf clon:*send-parent-depth* 2)
(rlx:set-screen-height *blast-window-height*)
(rlx:set-screen-width *blast-window-width*)
;; (rlx:set-frame-rate 30)
;; (rlx:disable-timer)
;; (rlx:enable-held-keys 1 15)
(setf rlx:*zoom-factor* 1)
(xe2:set-screen-height *blast-window-height*)
(xe2:set-screen-width *blast-window-width*)
;; (xe2:set-frame-rate 30)
;; (xe2:disable-timer)
;; (xe2:enable-held-keys 1 15)
(setf xe2:*zoom-factor* 1)
(let* ((prompt (clone =blast-prompt=))
(universe (clone =universe=))
(narrator (clone =narrator=))
Expand All @@ -492,10 +493,10 @@
(stack (clone =stack=))
(stack2 (clone =stack=)))
;; hehe, turn this on for realtime
;; (rlx:enable-timer)
;; (rlx:set-frame-rate 30)
;; (rlx:set-timer-interval 1)
;; (rlx:enable-held-keys 1 3)
;; (xe2:enable-timer)
;; (xe2:set-frame-rate 30)
;; (xe2:set-timer-interval 1)
;; (xe2:enable-held-keys 1 3)
;;
(setf *view* (clone =view=))
;;
Expand Down Expand Up @@ -586,11 +587,11 @@
;; (draw-line x y sx sy :destination image
;; :color color)))))
;; [add-overlay *view* #'hack-overlay])))
;; (setf rlx::*lighting-hack-function* #'light-hack))
;; (setf xe2::*lighting-hack-function* #'light-hack))
;;
(setf *pager* (clone =pager=))
[auto-position *pager*]; :width *left-column-width*]
(rlx:install-widgets splash-prompt splash)
(xe2:install-widgets splash-prompt splash)
[add-page *pager* :play stack prompt dude-status ship-status *view* minimap terminal]
[add-page *pager* :help textbox]))

12 changes: 6 additions & 6 deletions blast/enemy.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ of poisonous radioactive gas."))
(when (and (< (random 100) probability)
[in-bounds-p *active-world* r c])
[drop-cell *active-world* (clone =explosion=) r c :no-collisions nil]))))
(dolist (dir rlx:*compass-directions*)
(dolist (dir xe2:*compass-directions*)
(multiple-value-bind (r c)
(step-in-direction <row> <column> dir)
(boom r c 100)))
Expand Down Expand Up @@ -228,7 +228,7 @@ Not the typical choice of the best pilots."))
(stepping :initform t)
(attacking-with :initform :robotic-arm)
(max-weight :initform (make-stat :base 25))
(direction :initform (rlx:random-direction))
(direction :initform (xe2:random-direction))
(strength :initform (make-stat :base 4 :min 0 :max 30))
(dexterity :initform (make-stat :base 5 :min 0 :max 30))
(intelligence :initform (make-stat :base 11 :min 0 :max 30))
Expand All @@ -250,7 +250,7 @@ Berserkers attack with a shock probe."))
[>>attack self player-dir]
[>>move self player-dir]))
(progn (when [obstacle-in-direction-p world row column <direction>]
(setf <direction> (rlx:random-direction)))
(setf <direction> (xe2:random-direction)))
[>>move self <direction>])))))

(define-method die berserker ()
Expand All @@ -269,7 +269,7 @@ Berserkers attack with a shock probe."))

;;; The radar-equipped Biclops is more dangerous.

(define-prototype biclops (:parent rlx:=cell=)
(define-prototype biclops (:parent xe2:=cell=)
(name :initform "Biclops")
(strength :initform (make-stat :base 15 :min 0 :max 50))
(dexterity :initform (make-stat :base 15 :min 0 :max 30))
Expand Down Expand Up @@ -464,7 +464,7 @@ Hard to kill because of their evasive manuevers."))
(square (nth (position farthest scores)
neighbors)))
(destructuring-bind (r c) square
[move self (rlx:direction-to row column r c)])))))))
[move self (xe2:direction-to row column r c)])))))))

(define-method move rook (direction)
(setf <last-direction> direction)
Expand Down Expand Up @@ -627,5 +627,5 @@ and attacks anyone who comes near."))
[>>speedsuck self [resolve self player-dir]]
[>>move self player-dir]))
(progn (when [obstacle-in-direction-p world row column <direction>]
(setf <direction> (rlx:random-direction)))
(setf <direction> (xe2:random-direction)))
[>>move self <direction>])))))
3 changes: 3 additions & 0 deletions forest/base.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Monastery. It is cold and rainy."
:fireflies 200
:graveyards 4
:ruins 3
:firewood 10
:raining t
:tree-grain 0.5
:tree-density 30
Expand All @@ -47,6 +48,8 @@ It has begun to snow."
:graveyards 6
:ruins 10
:snowing t
:firewood 25
:archer-skeletons 6
:tree-grain 0.2
:tree-density 30
:water-grain 0.5
Expand Down
Binary file added forest/death-alien.wav
Binary file not shown.
76 changes: 76 additions & 0 deletions forest/enemy.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
(intelligence :initform (make-stat :base 13 :min 0 :max 30))
(categories :initform '(:actor :target :obstacle :opaque :enemy :equipper))
(equipment-slots :initform '(:left-hand))
(bow-reload-clock :initform 0)
(max-items :initform (make-stat :base 3))
(stepping :initform t)
(speed :initform (make-stat :base 1))
Expand Down Expand Up @@ -87,6 +88,81 @@
[play-sample self "dead"]
[parent>>die self])

;;; The deadly archer skeleton

(defcell archer-skeleton
(tile :initform "archer-skeleton")
(name :initform "Archer-Skeleton")
(categories :initform '(:obstacle :actor :equipper :opaque
:exclusive :enemy :target :archer-skeleton))
(direction :initform nil)
(speed :initform (make-stat :base 3))
(movement-cost :initform (make-stat :base 6))
(hit-points :initform (make-stat :base 16 :min 0))
(equipment-slots :initform '(:left-hand :right-hand))
(arrows :initform (make-stat :base 15 :min 0))
(max-items :initform (make-stat :base 3))
(stepping :initform t)
(dead :initform nil)
(firing-with :initform :left-hand)
(energy :initform (make-stat :base 800 :min 0 :max 1000))
(strength :initform (make-stat :base 24))
(dexterity :initform (make-stat :base 12))
(description :initform
"An undead soul inhabits these blackened bones."))

(define-method choose-new-direction archer-skeleton ()
[expend-action-points self 2]
(setf <direction>
(if (= 0 (random 20))
;; occasionally choose a random dir
(nth (random 3)
'(:north :south :east :west))
;; otherwise turn left
(getf '(:north :west :west :south :south :east :east :north)
(or <direction> :north)))))

(define-method loadout archer-skeleton ()
[choose-new-direction self]
[make-inventory self]
[make-equipment self]
[equip self [add-item self (clone =wooden-bow=)]])

(define-method cancel archer-skeleton ()
(decf *enemies*))

;; (define-method initialize archer-skeleton ()
;; [make-inventory self]
;; [make-equipment self])

(define-method kick archer-skeleton (direction)
(setf <direction> direction))

(define-method run archer-skeleton ()
(clon:with-field-values (row column) self
(let ((world *world*))
(if (and (< [distance-to-player world row column] 10)
[line-of-sight world row column
[player-row world]
[player-column world]])
(let ((player-dir [direction-to-player world row column]))
[move self player-dir]
[fire self player-dir]
[expend-action-points self 10])
(multiple-value-bind (r c)
(step-in-direction <row> <column> <direction>)
[expend-action-points self 8]
(when [obstacle-at-p world r c]
[choose-new-direction self])
[move self <direction>])))))

(define-method die archer-skeleton ()
(unless <dead>
(setf <dead> t)
[drop self (clone =arrows= :count [stat-value self :arrows])]
[play-sample self "death-alien"]
[delete-from-world self]))

;;; Wolves are the most difficult enemies.

(defcell wolf
Expand Down
Binary file modified forest/forest.fasl
Binary file not shown.
6 changes: 5 additions & 1 deletion forest/forest.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,11 @@
(graveyards 15)
(ruins 15)
(herbs 2)
(firewood 8)
(firewood 14)
level snowing raining
(tree-grain 0.3)
(tree-density 30)
(archer-skeletons 0)
(water-grain 0.9)
(water-density 90)
(water-cutoff 0.2))
Expand Down Expand Up @@ -433,6 +434,9 @@
(dotimes (n firewood)
(multiple-value-bind (r c) [random-place self]
[drop-cell self (clone =firewood=) r c :exclusive t :probe t]))
(dotimes (n archer-skeletons)
(multiple-value-bind (r c) [random-place self]
[drop-cell self (clone =archer-skeleton=) r c :exclusive t :probe t :loadout t]))
(let* ((gateway (clone (ecase level
(1 =river-gateway=)
(2 =passage-gateway=))))
Expand Down
19 changes: 3 additions & 16 deletions forest/forest.org
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
** TODO [#A] fix being able to travel easily thru water
*** TODO smother fire with dirt
*** TODO freezing death
*** TODO hungry/soaked/freezing display in status
** TODO making fire to dry yourself
** TODO [#A] fix too much water
** TODO faster skel archers with better vision
** TODO hungry/soaked/freezing display in status
** TODO rose found in the forest
** TODO [#A] make wolves less annoying
** TODO more herbs on dead bodies'
** TODO more skeletons
Expand All @@ -15,21 +12,11 @@
** TODO magic barrier shield (flickering sprites)
** TODO magic missile (sparkly trails.)
** TODO enemies search for dark spots
** TODO [#A] fix moving when dead
** TODO [#B] fix scrolling
** TODO [#A] fix help screen
** TODO [#C] Command-Q should quit on mac ?
** TODO [#A] don't place bodies in walls OR ITEMS
** TODO [#A] fix arrows not dying
** TODO [#C] indicate edge of map with chevrons. piece together maps.
** TODO [#C] overworld map? (FUTURE)
** TODO [#B] fix in-game map scrolling off bottom of viewport
** TODO [#B] find in-game notes with same color scheme text as scroll
** TODO [#B] longer level approach to monastery, talk to a few npcs, follow a road and cross fences
cold rainy forest
brush to slow progress
bow and arrow combat , food factor, rest. travel a long road.
bird sound. short story. exploring an abandoned house. path through
woods to clearing. follow the bird. watercolor look.
lighting effects. game occurs, you explore ruins at (night , re-use vm0 art
lightning bugs
3 changes: 3 additions & 0 deletions forest/forest.pak
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
(:name "wolf" :type :image :file "wolf.png")
(:name "raindrop" :type :image :file "raindrop.png")
(:name "skeleton" :type :image :file "skel.png")
(:name "archer-skeleton" :type :image :file "skel-archer.png")
(:name "gravestone" :type :image :file "gravestone.png")
(:name "wooden-bow" :type :image :file "wooden-bow.png")

Expand All @@ -97,6 +98,8 @@
(:name "wall" :type :image :file "wall.png")
(:name "dandelion" :type :image :file "dandelion.png")
(:name "death" :type :sample :file "death.wav" :properties (:volume 40))
(:name "death-alien" :type :sample :file "death-alien.wav" :properties (:volume 30))
(:name "knock" :type :sample :file "knock.wav" :properties (:volume 50))
(:name "monks" :type :sample :file "monks.wav" :properties (:volume 25))
(:name "talk" :type :sample :file "talk.wav" :properties (:volume 10))
(:name "lutey" :type :sample :file "lutey.wav" :properties (:volume 31))
Expand Down
Binary file added forest/knock.wav
Binary file not shown.
Loading

0 comments on commit e71605b

Please sign in to comment.