root growth tweaks
This commit is contained in:
parent
d1dbef3f32
commit
a86bd6aa47
5 changed files with 34 additions and 24 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -580,25 +580,31 @@
|
|||
(pdata-set! "p" p (send (get-twig twig-id) get-point twig-point))
|
||||
(pdata-set! "offset" p (vmul (srndvec) (
|
||||
send (get-twig twig-id) get-width twig-point))))))
|
||||
|
||||
|
||||
(define/public (update-nutrients t d)
|
||||
(when (not (null? twigs))
|
||||
(with-primitive nutrients
|
||||
(pdata-index-map!
|
||||
(lambda (i p twig-id point offset speed)
|
||||
(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))
|
||||
((< (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))))
|
||||
"p" "twig" "point" "offset" "speed"))))
|
||||
(when (not (null? twigs))
|
||||
(with-primitive nutrients
|
||||
(pdata-index-map!
|
||||
(lambda (i p twig-id point offset speed)
|
||||
(let* ((twig-id (inexact->exact twig-id))
|
||||
(twig (get-twig twig-id))
|
||||
(point (inexact->exact point)))
|
||||
(cond
|
||||
((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)))))))
|
||||
"p" "twig" "point" "offset" "speed"))))
|
||||
|
||||
|
||||
(define/public (update t d)
|
||||
(update-nutrients t d)
|
||||
|
|
|
@ -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
Loading…
Reference in a new issue