optimisations

This commit is contained in:
Dave Griffiths 2009-10-26 07:39:01 +00:00
parent 1fea628cdf
commit c1c1bbb0e1
2 changed files with 27 additions and 8 deletions

View file

@ -92,7 +92,8 @@
(set-camera-transform (mtranslate (vector 0 0 -4))))))
(set! debounce-i #t))
(when (key-pressed "c")
(send game-logic clear))
(when (and (key-pressed " ") debounce-space (not current-twig-growing)
; don't want the branch to be too small

View file

@ -30,11 +30,13 @@
(define num-spiders 10)
(define num-butterflies 10)
(define auto-twig-var 5)
(define auto-time 10)
(define pickup-check-prob 20)
(define max-pickups 300)
(define auto-time 1)
(define pickup-check-prob 200)
(define max-pickups 150)
(define insect-send-prob 3)
(define update-count 0)
; moveme
(define (collide? line objs)
(foldl
@ -73,6 +75,7 @@
(else (cons (car l) (flatten (cdr l))))))
(define/pubment (update t d) ; need to augement this if we have child logic objects,
(set! update-count (+ update-count 1))
(let ((l (inner '() update t d)) ; and call update on them too.
(m messages))
(set! messages '())
@ -482,7 +485,6 @@
(twigs '()) ; a assoc list map of ids to twigs
(leader-twig #f) ; the temporary twig controlled by the player
(properties (list 'inflatoe implicit-property)) ; 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
(next-twig-id 0)
@ -528,7 +530,7 @@
(define/public (add-property name)
(set! twig-size (+ twig-size nutrient-twig-size-increase))
(when (not (eq? name 'nutrient))
(when (and (not (eq? name 'nutrient)) (not (list-contains name properties)))
(set! properties (cons name properties))))
; we need to maintain our list of twig ids here, for this plant
@ -548,7 +550,8 @@
(when leader-twig
(for-each
(lambda (pickup)
(send leader-twig check-pickup pickup))
(when (not (list-contains (send pickup get-type) properties))
(send leader-twig check-pickup pickup)))
pickups))))
(define/public (destroy-twig twig)
@ -571,6 +574,13 @@
(cons thing out))
(else (cons-twig thing (cdr in) (- count 1) (append out (list (car in)))))))
(define/public (destroy-all-twigs)
(for-each
(lambda (twig)
(destroy-twig twig))
twigs)
(set! twigs '()))
(define/public (get-random-ornament)
(if (null? twigs) #f (send (cadr (choose twigs)) get-random-ornament)))
@ -705,6 +715,12 @@
(add-insect (make-object insect-logic% (new-insect-id) (vmul (srndvec) 100) 'butterfly)))
))
(define/public (clear)
(for-each
(lambda (plant)
(send plant destroy-all-twigs))
plants))
(define/public (add-player plant)
(send-message 'player-plant (list
(list 'plant-id (send plant get-id))
@ -777,7 +793,9 @@
; to distribute the cpu load
(define/augment (update t d)
;(printf "num pickups ~a~n" (length pickups))
(printf "num updates ~a~n" update-count)
(printf "num pickups ~a~n" (length pickups))
(set! update-count 0)
(run-auto-pilot t d)