81 lines
2.7 KiB
Scheme
81 lines
2.7 KiB
Scheme
#lang scheme/base
|
|
(require fluxus-016/drflux)
|
|
(require scheme/class "logic.ss" "view.ss" "controller.ss")
|
|
(require "jabberer.ss")
|
|
|
|
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
; p l a n t e y e s
|
|
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
; notes:
|
|
;
|
|
; * keeping with a view/logic separation, although this is quite different to
|
|
; the hexagon game. the main advantages:
|
|
; - just a divide and conquer strategy for staying sane
|
|
; - able to debug the logic without the view, or vice versa
|
|
; - the logic can be ticked at a lower frequency - or even different
|
|
; parts at different rates, whereas the view needs ticking every frame
|
|
;
|
|
; * need to try to keep all the intensive 'every thing vs every thing' checking
|
|
; in the logic side, where it can be done over many frames (i'm thinking the
|
|
; lags involved with things like nutrients getting absorbed may not matter
|
|
; too much in this game)
|
|
;
|
|
; * using a message passing system to formalise the passing of information on
|
|
; the logic side. this makes it possible to have objects sending messages
|
|
; at any point, and have them automatically collected up and dispatched to
|
|
; the view
|
|
;
|
|
; * line segments are computed in the logic side, and can be represented any
|
|
; way by the view - maybe the players plant will be geometry and everyone
|
|
; elses will be ribbons (stoopid LOD)
|
|
;
|
|
; * in the same way, the line segments can be created in any way by the logic
|
|
; side - eg. lsystem, or different methods per plant (or per twig even)
|
|
|
|
(define logic-tick 0.5) ; time between logic updates
|
|
|
|
(clear)
|
|
|
|
(define gl (make-object game-logic%))
|
|
(define gv (make-object game-view%))
|
|
(define c (make-object controller% gv))
|
|
|
|
(send c setup)
|
|
(send gv setup)
|
|
(send gl setup)
|
|
|
|
(define plant1 (make-object plant-logic% "dave@fo.am" (vector 0 0 0)))
|
|
(define plant2 (make-object plant-logic% "plant00001@fo.am" (vector 0 0 90)))
|
|
|
|
(send c set-player-plant plant1)
|
|
|
|
(send gl add-plant plant1)
|
|
(send gl add-plant plant2)
|
|
|
|
(send plant2 add-twig (make-object twig-logic% (vector 0 0 0) 0 plant2 'root (vector 0 -1 0) start-twig-width 10 'ribbon))
|
|
|
|
(define tick-time 0)
|
|
|
|
(define pt 0)
|
|
(define pd 0.02)
|
|
(define (pe-time) pt)
|
|
(define (pe-delta) pd)
|
|
(define (pt-update) (set! pt (+ pt pd)))
|
|
|
|
(define (animate)
|
|
|
|
(when (< tick-time (pe-time))
|
|
(set! tick-time (+ (pe-time) logic-tick))
|
|
(send plant1 grow (vmul (send c get-fwd) -1))
|
|
(send plant2 grow (vector 0 -1 0))
|
|
(send gv update (pe-time) (pe-delta) (send gl update)))
|
|
|
|
(send gv update (pe-time) (pe-delta) '())
|
|
(send c update)
|
|
(pt-update))
|
|
|
|
#;(for ((i (in-range 0 10000)))
|
|
(animate))
|
|
|
|
(every-frame (animate))
|