Skip to content

Commit

Permalink
foo
Browse files Browse the repository at this point in the history
  • Loading branch information
David O'Toole committed Dec 11, 2009
1 parent 7423114 commit 006074d
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 26 deletions.
Binary file modified forest/forest.fasl
Binary file not shown.
102 changes: 79 additions & 23 deletions forest/forest.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,45 @@

;;; Forest addresses

(defun generate-forest-address (n)
(list '=forest=
:sequence-number (xe2:genseq)
:height *forest-height*
:width *forest-width*
:fireflies 100
:graveyards 8
:ruins 10
:tree-grain 0.5
:tree-density 30
:water-grain 0.2
:water-density 90
:water-cutoff 0.2))

(defun generate-level-address (n)
(ecase n
(1 (list '=forest=
:description
"You are outside of Nothbess town, heading south toward the
Monastery. It is cold and rainy."
:level n
:sequence-number (xe2:genseq)
:height *forest-height*
:width *forest-width*
:fireflies 200
:graveyards 2
:ruins 3
:raining t
:tree-grain 0.5
:tree-density 30
:water-grain 0.2
:water-density 0
:water-cutoff 0.2))
(2 (list '=forest=
:level n
:description
"The river has swelled beyond its banks with meltwaters, and flooded
an old hamlet whose name is forgotten.
It has begun to snow."
:sequence-number (xe2:genseq)
:height *forest-height*
:width *forest-width*
:fireflies 100
:graveyards 4
:ruins 10
:snowing t
:tree-grain 0.2
:tree-density 30
:water-grain 0.2
:water-density 90
:water-cutoff 0.2))
(3 (list '=passage=))))

;;; Text overlay balloons

(defcell balloon
Expand Down Expand Up @@ -245,6 +270,10 @@
(when [is-snowing *world*]
(multiple-value-bind (x y) [viewport-coordinates self]
[drop-sprite self (clone =snowflake=) x y])))
(percent-of-time 5
(when [is-raining *world*]
(multiple-value-bind (x y) [viewport-coordinates self]
[drop-sprite self (clone =raindrop=) x y])))
(setf <clock> *earth-rain-clock*))
(decf <clock>)))
"floor"))))
Expand Down Expand Up @@ -432,7 +461,7 @@
[set-player *universe* player]
[set-character *status* player]
[play *universe*
:address (generate-forest-address 1)]
:address (generate-level-address 1)]
[loadout player]))

(define-method damage player (points)
Expand Down Expand Up @@ -638,14 +667,18 @@
(define-prototype forest (:parent xe2:=world=)
(height :initform *forest-height*)
(width :initform *forest-width*)
(snowing :initform t)
(snowing :initform nil)
(raining :initform nil)
(ambient-light :initform *earth-light-radius*)
(description :initform "It is cold and snowing.")
(edge-condition :initform :block))

(define-method is-snowing forest ()
<snowing>)

(define-method is-raining forest ()
<raining>)

(define-method drop-earth forest ()
(dotimes (i <height>)
(dotimes (j <width>)
Expand Down Expand Up @@ -683,6 +716,14 @@
(+ (* 2 i) row)
(+ (* 2 j) column)]))))

(define-prototype river-gateway (:parent =gateway=)
(tile :initform "river-gateway")
(sequence-number :initform (genseq))
(address :initform (generate-level-address 2)))

(define-method step river-gateway (stepper)
[say self "The river meets the forest here. Press ENTER to continue on."])

(define-prototype passage-gateway (:parent =gateway=)
(tile :initform "passage-gateway")
(sequence-number :initform (genseq))
Expand Down Expand Up @@ -759,23 +800,29 @@
(trace-rectangle #'drop-floor (1+ row) (1+ column) (- height 2) (- width 2) :fill))
(dotimes (n (random 3))
(percent-of-time 70
[drop-cell self (clone =body=) (+ 1 row (random (- height 1))) (+ 1 column (random (- width 1)))
[drop-cell self (clone =body=) (+ 1 row (random (- height 1))) (+ column (random (- width 1)))
:exclusive t :probe t])))))

(define-method generate forest (&key (height *forest-height*)
(width *forest-width*)
sequence-number
sequence-number
description
(fireflies 100)
(graveyards 15)
(ruins 15)
(herbs 2)
level snowing raining
(tree-grain 0.3)
(tree-density 30)
(water-grain 0.9)
(water-density 90)
(water-cutoff 0.2))
(setf <height> height)
(setf <width> width)
(when description (setf <description> description))
(setf <sequence-number> sequence-number)
(setf <snowing> snowing <raining> raining)
(setf <level> level)
[create-default-grid self]
[drop-earth self]
[drop-cell self (clone =storm=) 0 0]
Expand All @@ -796,12 +843,16 @@
(column (1+ (random 20))))
[drop-cell self (clone =drop-point=) row column
:exclusive t :probe t]
[drop-cell self (clone =herb=) (+ row (random 20)) (+ column (random 20))])
(let* ((passage (clone =passage-gateway=))
(dotimes (n herbs)
(multiple-value-bind (r c) [random-place self]
[drop-cell self (clone =herb=) r c])))
(let* ((gateway (clone (ecase level
(1 =river-gateway=)
(2 =passage-gateway=))))
(row (+ (- height 10) (random 10))) ;; 20 FIXME
(column (random 10)))
[replace-cells-at *world* row column passage]
[set-location passage row column]))
[replace-cells-at *world* row column gateway]
[set-location gateway row column]))

(define-method begin-ambient-loop forest ()
(play-sample "lutey")
Expand Down Expand Up @@ -875,6 +926,11 @@
[drop-cell self (clone =drop-point=) row column
:exclusive t :probe t]))

;;; Monastery approach world




;;; Controlling the game

(define-prototype room-prompt (:parent xe2:=prompt=))
Expand Down Expand Up @@ -1054,7 +1110,7 @@
[newline quickhelp]))
;;
[play universe
:address (generate-forest-address 1)
:address (generate-level-address 1)
:player player
:narrator narrator
:prompt prompt
Expand Down
6 changes: 3 additions & 3 deletions forest/forest.org
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
** TODO map
** TODO don't generate bodies in walls
** TODO fix arrow behavior
** TODO overworld map? (FUTURE)
** TODO don't place bodies in walls
** TODO fix arrows not dying
** TODO record music/chant vox samples for monastery approach
** TODO fix being able to travel easily thru water, fix too much water
** TODO FIX joystick button handling
Expand Down
2 changes: 2 additions & 0 deletions forest/forest.pak
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@

(:name "player" :type :image :file "player.png")
(:name "passage-gateway" :type :image :file "mountain.png")
(:name "river-gateway" :type :image :file "river.png")
(:name "herb" :type :image :file "herb.png")
(:name "character" :type :image :file "character.png")
(:name "character-pink" :type :image :file "character-pink.png")
(:name "ball" :type :image :file "ball.png")
(:name "wall" :type :image :file "wall.png")
(:name "monks" :type :sample :file "monks.wav" :properties (:volume 20))
(:name "talk" :type :sample :file "talk.wav" :properties (:volume 10))
(:name "lutey" :type :sample :file "lutey.wav" :properties (:volume 31))
(:name "groar" :type :sample :file "groar.wav" :properties (:volume 25))
Expand Down

0 comments on commit 006074d

Please sign in to comment.