]> gitweb.factorcode.org Git - factor.git/blob - extra/gamelib/demos/sokoban/layouts/layouts.factor
198919b64a164984b65ecea0a84f27381d957496
[factor.git] / extra / gamelib / demos / sokoban / layouts / layouts.factor
1 USING: accessors colors gamelib.board gamelib.cell-object
2 gamelib.ui images.loader kernel literals opengl.textures
3 sequences namespaces ;
4
5 IN: gamelib.demos.sokoban.layouts
6
7 CONSTANT: player "vocab:gamelib/demos/sokoban/resources/CharR.png"
8 CONSTANT: wall "vocab:gamelib/demos/sokoban/resources/Wall_Brown.png"
9 CONSTANT: goal "vocab:gamelib/demos/sokoban/resources/Goal.png"
10 CONSTANT: light-crate "vocab:gamelib/demos/sokoban/resources/Crate_Yellow.png"
11 CONSTANT: dark-crate "vocab:gamelib/demos/sokoban/resources/CrateDark_Yellow.png"
12
13 TUPLE: crate-cell < cell-object image-path ;
14 M: crate-cell draw-cell-object* 
15     rot [ image-path>> load-image ] dip <texture> draw-scaled-texture ;
16
17 :: make-crate ( image-path -- crate )
18     crate-cell new
19     image-path crate-cell boa ;
20
21 : board-one ( gadget -- gadget )
22     8 9 make-board
23     
24     { 2 2 } player add-to-cell
25
26     {
27                         { 2 0 } { 3 0 } { 4 0 } { 5 0 } { 6 0 }
28         { 0 1 } { 1 1 } { 2 1 }                         { 6 1 }
29         { 0 2 }                                         { 6 2 }
30         { 0 3 } { 1 3 } { 2 3 }                         { 6 3 }
31         { 0 4 }         { 2 4 } { 3 4 }                 { 6 4 }
32         { 0 5 }         { 2 5 }                         { 6 5 } { 7 5 }
33         { 0 6 }                                                 { 7 6 }
34         { 0 7 }                                                 { 7 7 }
35         { 0 8 } { 1 8 } { 2 8 } { 3 8 } { 4 8 } { 5 8 } { 6 8 } { 7 8 }
36
37     } $ wall add-to-cells
38
39     { 
40
41         { 1 6 } { 3 2 } { 4 3 } { 4 4 } { 4 6 } { 3 6 } { 5 6 }
42     } $ light-crate make-crate add-copy-to-cells
43
44     {
45         { 1 2 } { 5 3 } { 1 4 } { 4 5 } { 3 6 } { 6 6 } { 4 7 } 
46     } $ goal add-to-cells 
47     
48     { } 1sequence add-board ;
49
50
51 : board-two ( gadget -- gadget )
52     22 11 make-board
53     
54     { 11 8 } player add-to-cell
55
56     {
57                                         { 4 0 } { 5 0 } { 6 0 } { 7 0 } { 8 0 }
58                                         { 4 1 }                         { 8 1 }
59                                         { 4 2 }                         { 8 2 }
60                         { 2 3 } { 3 3 } { 4 3 }                         { 8 3 } { 9 3 } { 10 3 }
61                         { 2 4 }                                                         { 10 4 }
62         { 0 5 } { 1 5 } { 2 5 }         { 4 5 }         { 6 5 } { 7 5 } { 8 5 }         { 10 5 }                                              { 16 5 } { 17 5 } { 18 5 } { 19 5 } { 20 5 } { 21 5 }
63         { 0 6 }                         { 4 6 }         { 6 6 } { 7 6 } { 8 6 }         { 10 6 } { 11 6 } { 12 6 } { 13 6 } { 14 6 } { 15 6 } { 16 6 }                                     { 21 6 }
64         { 0 7 }                                                                                                                                                                            { 21 7 }
65         { 0 8 } { 1 8 } { 2 8 } { 3 8 } { 4 8 }         { 6 8 } { 7 8 } { 8 8 }         { 10 8 }          { 12 8 } { 13 8 } { 14 8 } { 15 8 } { 16 8 }                                     { 21 8 }
66                                         { 4 9 }                                         { 10 9 } { 11 9 } { 12 9 }                            { 16 9 } { 17 9 } { 18 9 } { 19 9 } { 20 9 } { 21 9 }
67                                         { 4 10 } { 5 10 } { 6 10 } { 7 10 } { 8 10 } { 9 10 } { 10 10 }  
68     } $ wall add-to-cells
69     
70     {
71         { 19 6 } { 20 6 }
72         { 19 7 } { 20 7 }
73         { 19 8 } { 20 8 }
74     } $ goal add-to-cells
75
76     { 
77         { 5 2 } { 7 3 } { 5 4 } { 8 4 } { 5 7 } { 2 7 }
78     } $ light-crate make-crate add-copy-to-cells
79
80     { } 1sequence 
81
82     add-board ;
83
84
85 : board-three ( gadget -- gadget )
86     8 8 make-board
87     
88     { 1 1 } player add-to-cell
89
90     {
91         { 0 0 } { 1 0 } { 2 0 } { 3 0 } { 4 0 } { 5 0 } { 6 0 } { 7 0 }
92         { 0 1 }                                                 { 7 1 }
93         { 0 2 }                                                 { 7 2 }
94         { 0 3 }                                                 { 7 3 }
95         { 0 4 }                                                 { 7 4 }
96         { 0 5 }                                                 { 7 5 }
97         { 0 6 }                                                 { 7 6 }
98         { 0 7 } { 1 7 } { 2 7 } { 3 7 } { 4 7 } { 5 7 } { 6 7 } { 7 7 }
99     } $ wall add-to-cells
100
101     { 2 1 } $ light-crate make-crate add-to-cell
102
103     { 3 1 } $ goal add-to-cell                                         
104
105     { } 1sequence 
106
107     add-board ;