root growth tweaks

This commit is contained in:
Dave Griffiths 2009-08-25 15:48:05 +01:00
parent d1dbef3f32
commit a86bd6aa47
5 changed files with 34 additions and 24 deletions

View file

@ -49,7 +49,7 @@
(define/public (setup)
(lock-camera cam)
(camera-lag 0.2)
(clip 1 100)
(clip 1 300)
(set-camera-transform (mtranslate (vector 0 0 -4))))
; moveme

View file

@ -18,7 +18,7 @@
(define curl-amount 40)
(define start-size 50)
(define max-ornaments 10) ; per twig
(define nutrient-twig-size-increase 4)
(define nutrient-twig-size-increase 2)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the base class logic object - all logic side objects can
@ -91,6 +91,9 @@
(define/public (get-dist)
dist)
(define/public (get-w)
w)
(define/public (get-dir)
dir)
@ -131,7 +134,8 @@
(set! w (if (zero? (- num-points 2)) width
(+ 0.1 (* width (- 1 (/ (length points) (- num-points 2)))))))
(* width (- 1 (/ (length points) (- num-points 2))))))
(set! dist (* w 1.5))
(set! last-point new-point)
(set! points (append points (list new-point)))
(set! widths (append widths (list w)))
@ -324,7 +328,7 @@
(field
(twigs '()) ; a assoc list map of ids to twigs
(leader-twig #f) ; the temporary twig controlled by the player
(properties '(leaf flower fork horn inflatoe)) ; a list of symbols - properties come from pickups
(properties '()) ; a list of symbols - properties come from pickups
(ornaments '()) ; map of ids to ornaments on the plant
(size start-size) ; the age of this plant
(max-twigs default-max-twigs) ; the maximum twigs allowed at any time - oldest removed first

View file

@ -589,17 +589,23 @@
(let* ((twig-id (inexact->exact twig-id))
(twig (get-twig twig-id))
(point (inexact->exact point)))
(if twig
(cond
((< point 1) (pdata-set! "twig" i -1) (vector 0 0 0))
((or (< point 1) (not twig))
(let* ((new-twig (choose twigs))
(num-points (send (cadr new-twig) get-num-points))
(new-point (if (zero? num-points) 0 (random num-points))))
(pdata-set! "twig" i (car new-twig))
(pdata-set! "point" i new-point)
(pdata-set! "offset" i (vmix offset (vmul (srndvec) (send (cadr new-twig) get-width new-point)) 0.2))
(send (cadr new-twig) get-point new-point)))
((< (vdist (vadd (send twig get-point point) offset) p) 0.1)
(pdata-set! "point" i (- point 1))
(vadd p (vmul (vnormalise (vsub (vadd (send twig get-point (- point 1)) offset) p)) (* speed d))))
(else
(vadd p (vmul (vnormalise (vsub (vadd (send twig get-point point) offset) p)) (* speed d)))))
(vector 0 0 0))))
(vadd p (vmul (vnormalise (vsub (vadd (send twig get-point point) offset) p)) (* speed d)))))))
"p" "twig" "point" "offset" "speed"))))
(define/public (update t d)
(update-nutrients t d)
(with-primitive seed

View file

@ -49,7 +49,7 @@
(lambda (_)
(make-ob 'seed 'seed "meshes/seed.obj"
(vmul (srndvec) (* size area 0.5))
(* 0.5 50)
(* 0.3 50)
(vmul (rndvec) 0) 0)))
(build-list num-pickups

File diff suppressed because one or more lines are too long