1 USING: accessors math kernel sequences math.vectors gamelib.board ;
3 IN: gamelib.cell-object
5 TUPLE: cell-object draw-cell-delegate ;
7 GENERIC: draw-cell-object* ( loc dim delegate -- )
9 : <cell-object*> ( draw-delegate -- cell )
12 : <cell-object> ( delegate -- cell )
13 <cell-object*> ; inline
16 TUPLE: flowcell-object < cell-object flow ;
18 ! the flowcell-object will move every target frames
19 ! counter keeps track of how many frames have passed since the flowcell-object has last moved
20 TUPLE: flow is-on direction target counter ;
22 ! -------------------- Helper methods ----------------------------------------
23 ! Checks if the flow constant is at the specified location on the board
24 :: flow-on? ( flowcell-object -- ? )
25 flowcell-object flow>> is-on>> ;
27 ! Add flow information to the cell
28 :: set-flow ( flowcell-object direction target -- flowcell-object )
29 t direction target 0 flow boa :> flow-obj
30 flowcell-object flow-obj >>flow
33 :: turn-off-flow ( cell -- cell )
34 f f f f flow boa :> flow-obj
35 flowcell-object flow-obj >>flow
39 TUPLE: child-cell < cell-object parent ;
42 GENERIC: call-parent* ( resources instruction delegate -- )
44 TUPLE: parent children function ;
46 : <parent*> ( children function -- parent )
49 : <parent> ( children function -- parent )
52 :: new-child ( child-pos parent -- )
53 parent parent children>> { child-pos } append >>children drop ;
55 :: fill-board-parent ( board parent -- board )
56 board parent children>> { parent } set-cells ;
58 :: move-children ( board move parent -- board )
59 parent children>> :> children
60 parent children [ move v+ ] map >>children drop
61 board children children [ move v+ ] map board children first get-cell move-many-objects ;