;#lang scheme/base ;(require fluxus-016/drflux) (require scheme/class "logic.ss" "view.ss" "controller.ss" "client.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 ; ; * these messages are also converted to xmpp messages and sent out over the ; network ; ; * 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 jid "plant0000002@fo.am") (define pass "plant0000002") (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)) (define cl (make-object client% jid pass)) (send c setup) (send gv setup) (send gl setup) (send cl setup) (define plant1 (make-object plant-logic% jid (vector 0 0 0))) (send c set-player-plant plant1) (send gl add-plant plant1) (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)) (let ((messages (send gl update))) ; pass the messages to the network client (send gv update (pe-time) (pe-delta) (send cl update messages gl)))) ; and the game view (send gv update (pe-time) (pe-delta) '()) (send c update) (pt-update) (sleep 0.01)) #;(for ((i (in-range 0 10000))) (animate)) (every-frame (animate))