minigl 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +19 -19
- data/README.md +35 -36
- data/Rakefile +11 -11
- data/lib/minigl.rb +4 -4
- data/lib/minigl/forms.rb +1485 -1485
- data/lib/minigl/game_object.rb +379 -379
- data/lib/minigl/global.rb +729 -729
- data/lib/minigl/map.rb +256 -256
- data/lib/minigl/movement.rb +585 -585
- data/lib/minigl/text.rb +190 -188
- data/test/data/img/barbg.svg +73 -73
- data/test/data/img/barfg.svg +106 -106
- data/test/data/img/square.svg +66 -66
- data/test/data/img/square2.svg +66 -66
- data/test/data/img/square3.svg +76 -76
- data/test/data/img/tile1.svg +66 -66
- data/test/data/img/tile2.svg +66 -66
- data/test/game.rb +150 -150
- data/test/game_object_tests.rb +108 -108
- data/test/iso_game.rb +39 -39
- data/test/map_tests.rb +57 -57
- data/test/mov_game.rb +76 -76
- data/test/movement_tests.rb +86 -86
- data/test/res_tests.rb +45 -45
- data/test/vector_tests.rb +55 -55
- metadata +24 -24
data/test/data/img/square3.svg
CHANGED
@@ -1,76 +1,76 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
-
|
4
|
-
<svg
|
5
|
-
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
-
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
-
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
-
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
-
xmlns="http://www.w3.org/2000/svg"
|
10
|
-
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
-
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
-
width="100"
|
13
|
-
height="100"
|
14
|
-
viewBox="0 0 100 100"
|
15
|
-
id="svg2"
|
16
|
-
version="1.1"
|
17
|
-
inkscape:version="0.91 r13725"
|
18
|
-
sodipodi:docname="square3.svg"
|
19
|
-
inkscape:export-filename="/home/victor/aleva/minigl/test/data/img/square3.png"
|
20
|
-
inkscape:export-xdpi="90"
|
21
|
-
inkscape:export-ydpi="90">
|
22
|
-
<defs
|
23
|
-
id="defs4" />
|
24
|
-
<sodipodi:namedview
|
25
|
-
id="base"
|
26
|
-
pagecolor="#ffffff"
|
27
|
-
bordercolor="#666666"
|
28
|
-
borderopacity="1.0"
|
29
|
-
inkscape:pageopacity="0.0"
|
30
|
-
inkscape:pageshadow="2"
|
31
|
-
inkscape:zoom="8.62"
|
32
|
-
inkscape:cx="50"
|
33
|
-
inkscape:cy="50"
|
34
|
-
inkscape:document-units="px"
|
35
|
-
inkscape:current-layer="layer1"
|
36
|
-
showgrid="false"
|
37
|
-
inkscape:snap-global="false"
|
38
|
-
units="px"
|
39
|
-
inkscape:window-width="1920"
|
40
|
-
inkscape:window-height="1025"
|
41
|
-
inkscape:window-x="0"
|
42
|
-
inkscape:window-y="0"
|
43
|
-
inkscape:window-maximized="1" />
|
44
|
-
<metadata
|
45
|
-
id="metadata7">
|
46
|
-
<rdf:RDF>
|
47
|
-
<cc:Work
|
48
|
-
rdf:about="">
|
49
|
-
<dc:format>image/svg+xml</dc:format>
|
50
|
-
<dc:type
|
51
|
-
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
52
|
-
<dc:title></dc:title>
|
53
|
-
</cc:Work>
|
54
|
-
</rdf:RDF>
|
55
|
-
</metadata>
|
56
|
-
<g
|
57
|
-
inkscape:label="Layer 1"
|
58
|
-
inkscape:groupmode="layer"
|
59
|
-
id="layer1"
|
60
|
-
transform="translate(0,-952.36216)">
|
61
|
-
<rect
|
62
|
-
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.2"
|
63
|
-
id="rect4133"
|
64
|
-
width="100"
|
65
|
-
height="100"
|
66
|
-
x="0"
|
67
|
-
y="952.36218" />
|
68
|
-
<rect
|
69
|
-
y="1002.3622"
|
70
|
-
x="50"
|
71
|
-
height="40"
|
72
|
-
width="40"
|
73
|
-
id="rect4135"
|
74
|
-
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.2" />
|
75
|
-
</g>
|
76
|
-
</svg>
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
10
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
+
width="100"
|
13
|
+
height="100"
|
14
|
+
viewBox="0 0 100 100"
|
15
|
+
id="svg2"
|
16
|
+
version="1.1"
|
17
|
+
inkscape:version="0.91 r13725"
|
18
|
+
sodipodi:docname="square3.svg"
|
19
|
+
inkscape:export-filename="/home/victor/aleva/minigl/test/data/img/square3.png"
|
20
|
+
inkscape:export-xdpi="90"
|
21
|
+
inkscape:export-ydpi="90">
|
22
|
+
<defs
|
23
|
+
id="defs4" />
|
24
|
+
<sodipodi:namedview
|
25
|
+
id="base"
|
26
|
+
pagecolor="#ffffff"
|
27
|
+
bordercolor="#666666"
|
28
|
+
borderopacity="1.0"
|
29
|
+
inkscape:pageopacity="0.0"
|
30
|
+
inkscape:pageshadow="2"
|
31
|
+
inkscape:zoom="8.62"
|
32
|
+
inkscape:cx="50"
|
33
|
+
inkscape:cy="50"
|
34
|
+
inkscape:document-units="px"
|
35
|
+
inkscape:current-layer="layer1"
|
36
|
+
showgrid="false"
|
37
|
+
inkscape:snap-global="false"
|
38
|
+
units="px"
|
39
|
+
inkscape:window-width="1920"
|
40
|
+
inkscape:window-height="1025"
|
41
|
+
inkscape:window-x="0"
|
42
|
+
inkscape:window-y="0"
|
43
|
+
inkscape:window-maximized="1" />
|
44
|
+
<metadata
|
45
|
+
id="metadata7">
|
46
|
+
<rdf:RDF>
|
47
|
+
<cc:Work
|
48
|
+
rdf:about="">
|
49
|
+
<dc:format>image/svg+xml</dc:format>
|
50
|
+
<dc:type
|
51
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
52
|
+
<dc:title></dc:title>
|
53
|
+
</cc:Work>
|
54
|
+
</rdf:RDF>
|
55
|
+
</metadata>
|
56
|
+
<g
|
57
|
+
inkscape:label="Layer 1"
|
58
|
+
inkscape:groupmode="layer"
|
59
|
+
id="layer1"
|
60
|
+
transform="translate(0,-952.36216)">
|
61
|
+
<rect
|
62
|
+
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.2"
|
63
|
+
id="rect4133"
|
64
|
+
width="100"
|
65
|
+
height="100"
|
66
|
+
x="0"
|
67
|
+
y="952.36218" />
|
68
|
+
<rect
|
69
|
+
y="1002.3622"
|
70
|
+
x="50"
|
71
|
+
height="40"
|
72
|
+
width="40"
|
73
|
+
id="rect4135"
|
74
|
+
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.2" />
|
75
|
+
</g>
|
76
|
+
</svg>
|
data/test/data/img/tile1.svg
CHANGED
@@ -1,66 +1,66 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
-
|
4
|
-
<svg
|
5
|
-
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
-
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
-
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
-
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
-
xmlns="http://www.w3.org/2000/svg"
|
10
|
-
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
-
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
-
width="24"
|
13
|
-
height="16"
|
14
|
-
id="svg2"
|
15
|
-
version="1.1"
|
16
|
-
inkscape:version="0.48.4 r9939"
|
17
|
-
sodipodi:docname="tile1.svg"
|
18
|
-
inkscape:export-filename="/home/victor/Projects/TCC/minigl/data/img/tile1.png"
|
19
|
-
inkscape:export-xdpi="90"
|
20
|
-
inkscape:export-ydpi="90">
|
21
|
-
<defs
|
22
|
-
id="defs4" />
|
23
|
-
<sodipodi:namedview
|
24
|
-
id="base"
|
25
|
-
pagecolor="#ffffff"
|
26
|
-
bordercolor="#666666"
|
27
|
-
borderopacity="1.0"
|
28
|
-
inkscape:pageopacity="0.0"
|
29
|
-
inkscape:pageshadow="2"
|
30
|
-
inkscape:zoom="1"
|
31
|
-
inkscape:cx="12"
|
32
|
-
inkscape:cy="8"
|
33
|
-
inkscape:document-units="px"
|
34
|
-
inkscape:current-layer="layer1"
|
35
|
-
showgrid="false"
|
36
|
-
inkscape:window-width="1364"
|
37
|
-
inkscape:window-height="718"
|
38
|
-
inkscape:window-x="0"
|
39
|
-
inkscape:window-y="0"
|
40
|
-
inkscape:window-maximized="1" />
|
41
|
-
<metadata
|
42
|
-
id="metadata7">
|
43
|
-
<rdf:RDF>
|
44
|
-
<cc:Work
|
45
|
-
rdf:about="">
|
46
|
-
<dc:format>image/svg+xml</dc:format>
|
47
|
-
<dc:type
|
48
|
-
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
49
|
-
<dc:title />
|
50
|
-
</cc:Work>
|
51
|
-
</rdf:RDF>
|
52
|
-
</metadata>
|
53
|
-
<g
|
54
|
-
inkscape:label="Layer 1"
|
55
|
-
inkscape:groupmode="layer"
|
56
|
-
id="layer1"
|
57
|
-
transform="translate(0,-1036.3622)">
|
58
|
-
<path
|
59
|
-
style="fill:#008201;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
60
|
-
d="M 12,1.6038382 0.9,9 12,16.396 23.1,9 z"
|
61
|
-
id="path3753"
|
62
|
-
inkscape:connector-curvature="0"
|
63
|
-
transform="translate(0,1035.3622)"
|
64
|
-
sodipodi:nodetypes="ccccc" />
|
65
|
-
</g>
|
66
|
-
</svg>
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
10
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
+
width="24"
|
13
|
+
height="16"
|
14
|
+
id="svg2"
|
15
|
+
version="1.1"
|
16
|
+
inkscape:version="0.48.4 r9939"
|
17
|
+
sodipodi:docname="tile1.svg"
|
18
|
+
inkscape:export-filename="/home/victor/Projects/TCC/minigl/data/img/tile1.png"
|
19
|
+
inkscape:export-xdpi="90"
|
20
|
+
inkscape:export-ydpi="90">
|
21
|
+
<defs
|
22
|
+
id="defs4" />
|
23
|
+
<sodipodi:namedview
|
24
|
+
id="base"
|
25
|
+
pagecolor="#ffffff"
|
26
|
+
bordercolor="#666666"
|
27
|
+
borderopacity="1.0"
|
28
|
+
inkscape:pageopacity="0.0"
|
29
|
+
inkscape:pageshadow="2"
|
30
|
+
inkscape:zoom="1"
|
31
|
+
inkscape:cx="12"
|
32
|
+
inkscape:cy="8"
|
33
|
+
inkscape:document-units="px"
|
34
|
+
inkscape:current-layer="layer1"
|
35
|
+
showgrid="false"
|
36
|
+
inkscape:window-width="1364"
|
37
|
+
inkscape:window-height="718"
|
38
|
+
inkscape:window-x="0"
|
39
|
+
inkscape:window-y="0"
|
40
|
+
inkscape:window-maximized="1" />
|
41
|
+
<metadata
|
42
|
+
id="metadata7">
|
43
|
+
<rdf:RDF>
|
44
|
+
<cc:Work
|
45
|
+
rdf:about="">
|
46
|
+
<dc:format>image/svg+xml</dc:format>
|
47
|
+
<dc:type
|
48
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
49
|
+
<dc:title />
|
50
|
+
</cc:Work>
|
51
|
+
</rdf:RDF>
|
52
|
+
</metadata>
|
53
|
+
<g
|
54
|
+
inkscape:label="Layer 1"
|
55
|
+
inkscape:groupmode="layer"
|
56
|
+
id="layer1"
|
57
|
+
transform="translate(0,-1036.3622)">
|
58
|
+
<path
|
59
|
+
style="fill:#008201;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
60
|
+
d="M 12,1.6038382 0.9,9 12,16.396 23.1,9 z"
|
61
|
+
id="path3753"
|
62
|
+
inkscape:connector-curvature="0"
|
63
|
+
transform="translate(0,1035.3622)"
|
64
|
+
sodipodi:nodetypes="ccccc" />
|
65
|
+
</g>
|
66
|
+
</svg>
|
data/test/data/img/tile2.svg
CHANGED
@@ -1,66 +1,66 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
-
|
4
|
-
<svg
|
5
|
-
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
-
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
-
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
-
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
-
xmlns="http://www.w3.org/2000/svg"
|
10
|
-
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
-
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
-
width="25"
|
13
|
-
height="17"
|
14
|
-
id="svg2"
|
15
|
-
version="1.1"
|
16
|
-
inkscape:version="0.48.4 r9939"
|
17
|
-
sodipodi:docname="tile1.svg"
|
18
|
-
inkscape:export-filename="/home/victor/Projects/TCC/minigl/data/img/tile1.png"
|
19
|
-
inkscape:export-xdpi="90"
|
20
|
-
inkscape:export-ydpi="90">
|
21
|
-
<defs
|
22
|
-
id="defs4" />
|
23
|
-
<sodipodi:namedview
|
24
|
-
id="base"
|
25
|
-
pagecolor="#ffffff"
|
26
|
-
bordercolor="#666666"
|
27
|
-
borderopacity="1.0"
|
28
|
-
inkscape:pageopacity="0.0"
|
29
|
-
inkscape:pageshadow="2"
|
30
|
-
inkscape:zoom="1"
|
31
|
-
inkscape:cx="9.1614129"
|
32
|
-
inkscape:cy="10.063397"
|
33
|
-
inkscape:document-units="px"
|
34
|
-
inkscape:current-layer="layer1"
|
35
|
-
showgrid="false"
|
36
|
-
inkscape:window-width="1364"
|
37
|
-
inkscape:window-height="718"
|
38
|
-
inkscape:window-x="0"
|
39
|
-
inkscape:window-y="0"
|
40
|
-
inkscape:window-maximized="1" />
|
41
|
-
<metadata
|
42
|
-
id="metadata7">
|
43
|
-
<rdf:RDF>
|
44
|
-
<cc:Work
|
45
|
-
rdf:about="">
|
46
|
-
<dc:format>image/svg+xml</dc:format>
|
47
|
-
<dc:type
|
48
|
-
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
49
|
-
<dc:title></dc:title>
|
50
|
-
</cc:Work>
|
51
|
-
</rdf:RDF>
|
52
|
-
</metadata>
|
53
|
-
<g
|
54
|
-
inkscape:label="Layer 1"
|
55
|
-
inkscape:groupmode="layer"
|
56
|
-
id="layer1"
|
57
|
-
transform="translate(0,-1035.3622)">
|
58
|
-
<path
|
59
|
-
style="fill:#008201;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
60
|
-
d="M 12.5,0.61978426 0.9,8.5 12.5,16.38 24.1,8.5 z"
|
61
|
-
id="path3753"
|
62
|
-
inkscape:connector-curvature="0"
|
63
|
-
transform="translate(0,1035.3622)"
|
64
|
-
sodipodi:nodetypes="ccccc" />
|
65
|
-
</g>
|
66
|
-
</svg>
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
10
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
+
width="25"
|
13
|
+
height="17"
|
14
|
+
id="svg2"
|
15
|
+
version="1.1"
|
16
|
+
inkscape:version="0.48.4 r9939"
|
17
|
+
sodipodi:docname="tile1.svg"
|
18
|
+
inkscape:export-filename="/home/victor/Projects/TCC/minigl/data/img/tile1.png"
|
19
|
+
inkscape:export-xdpi="90"
|
20
|
+
inkscape:export-ydpi="90">
|
21
|
+
<defs
|
22
|
+
id="defs4" />
|
23
|
+
<sodipodi:namedview
|
24
|
+
id="base"
|
25
|
+
pagecolor="#ffffff"
|
26
|
+
bordercolor="#666666"
|
27
|
+
borderopacity="1.0"
|
28
|
+
inkscape:pageopacity="0.0"
|
29
|
+
inkscape:pageshadow="2"
|
30
|
+
inkscape:zoom="1"
|
31
|
+
inkscape:cx="9.1614129"
|
32
|
+
inkscape:cy="10.063397"
|
33
|
+
inkscape:document-units="px"
|
34
|
+
inkscape:current-layer="layer1"
|
35
|
+
showgrid="false"
|
36
|
+
inkscape:window-width="1364"
|
37
|
+
inkscape:window-height="718"
|
38
|
+
inkscape:window-x="0"
|
39
|
+
inkscape:window-y="0"
|
40
|
+
inkscape:window-maximized="1" />
|
41
|
+
<metadata
|
42
|
+
id="metadata7">
|
43
|
+
<rdf:RDF>
|
44
|
+
<cc:Work
|
45
|
+
rdf:about="">
|
46
|
+
<dc:format>image/svg+xml</dc:format>
|
47
|
+
<dc:type
|
48
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
49
|
+
<dc:title></dc:title>
|
50
|
+
</cc:Work>
|
51
|
+
</rdf:RDF>
|
52
|
+
</metadata>
|
53
|
+
<g
|
54
|
+
inkscape:label="Layer 1"
|
55
|
+
inkscape:groupmode="layer"
|
56
|
+
id="layer1"
|
57
|
+
transform="translate(0,-1035.3622)">
|
58
|
+
<path
|
59
|
+
style="fill:#008201;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
60
|
+
d="M 12.5,0.61978426 0.9,8.5 12.5,16.38 24.1,8.5 z"
|
61
|
+
id="path3753"
|
62
|
+
inkscape:connector-curvature="0"
|
63
|
+
transform="translate(0,1035.3622)"
|
64
|
+
sodipodi:nodetypes="ccccc" />
|
65
|
+
</g>
|
66
|
+
</svg>
|
data/test/game.rb
CHANGED
@@ -1,150 +1,150 @@
|
|
1
|
-
require_relative '../lib/minigl'
|
2
|
-
include MiniGL
|
3
|
-
|
4
|
-
class MyGame < GameWindow
|
5
|
-
def initialize
|
6
|
-
super 800, 600, false
|
7
|
-
|
8
|
-
# @img = Res.img :img1
|
9
|
-
@obj1 = GameObject.new 75, 75, 60, 60, :square3, Vector.new(-75, -75)
|
10
|
-
@obj2 = Sprite.new 400, 0, :img1
|
11
|
-
@obj3 = GameObject.new 4, 50, 24, 24, :check, Vector.new(-4, -4), 2, 4
|
12
|
-
@obj3.set_animation 1
|
13
|
-
@obj4 = Sprite.new 500, 0, :img1
|
14
|
-
@objs = []
|
15
|
-
8.times { @objs << GameObject.new(384, 284, 32, 32, :check, Vector.new(0, 0), 2, 4) }
|
16
|
-
@flip = nil
|
17
|
-
|
18
|
-
@font1 = Res.font :font1, 20
|
19
|
-
@font2 = Res.font :font1, 50
|
20
|
-
@writer1 = TextHelper.new @font1, 5
|
21
|
-
@writer2 = TextHelper.new @font2, 5
|
22
|
-
@btn = Button.new(10, 560, @font1, 'Test', :btn, 0x008000, 0x808080, 0xffffff, 0xff9980, true, true, 0, 4, 0, 0, 'friends', nil, 2, 2) { |x| puts "hello #{x}" }
|
23
|
-
@btn.enabled = false
|
24
|
-
@chk =
|
25
|
-
ToggleButton.new(x: 0, y: 30, font: @font1, text: 'Click me', img: :check, center_x: false, margin_x: 36, params: 'friends', anchor: :south) { |c, x|
|
26
|
-
puts "hello #{x}, checked: #{c}"
|
27
|
-
}
|
28
|
-
@txt = TextField.new(x: 0, y: 0, font: @font1, img: :text, margin_x: 15, margin_y: 5, max_length: 16, locale: 'PT-BR', scale_x: 1.2, scale_y: 0.8, anchor: :center_right)
|
29
|
-
@txt.visible = false
|
30
|
-
|
31
|
-
@pb = ProgressBar.new(50, 0, 200, 20, :barbg, :barfg, 3456, 70, 2, 2, @font1, 0xff000080, nil, nil, 1.8, 2, :center_left)
|
32
|
-
@ddl = DropDownList.new(0, 10, @font1, nil, nil, ['olá amigos', 'opção 2', 'terceira'], 0, 3, 150, 25, 0, 0x808080, 0xffffff, 0xffff00, nil, 2, 2.5, :north) { |a, b|
|
33
|
-
puts "mudou de #{a} para #{b}"
|
34
|
-
}
|
35
|
-
|
36
|
-
@panel = Panel.new(10, 10, 720, 520, [
|
37
|
-
Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn),
|
38
|
-
Label.new(0, 70, @font1, 'Teste de label', 0xcccccc, 0x666666, 1, 1, :north),
|
39
|
-
TextField.new(x: 5, y: 40, font: @font1, text: 'Opa', img: :text, margin_x: 5, margin_y: 5, anchor: :top_left),
|
40
|
-
Button.new(x: 0, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :top),
|
41
|
-
DropDownList.new(x: 0, y: 40, width: 150, height: 25, font: @font1, options: ['olá amigos', 'opção 2', 'terceira'], anchor: :north),
|
42
|
-
Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :northeast),
|
43
|
-
Button.new(x: 5, y: 0, font: @font1, text: 'Teste', img: :btn, anchor: :left),
|
44
|
-
Button.new(x: 0, y: 0, font: @font1, text: 'Teste', img: :btn, anchor: :center),
|
45
|
-
Button.new(x: 5, y: 0, font: @font1, text: 'Teste', img: :btn, anchor: :right),
|
46
|
-
ToggleButton.new(x: 5, y: 40, img: :check, center_x: false, margin_x: 36, anchor: :east),
|
47
|
-
Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :southwest),
|
48
|
-
Button.new(x: 0, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :south),
|
49
|
-
ProgressBar.new(0, 40, 200, 20, :barbg, :barfg, 3456, 70, 2, 2, @font1, 0xff000080, nil, nil, 1, 1, :bottom)
|
50
|
-
], :text, :tiled, true, 2, 2, :bottom_right)
|
51
|
-
|
52
|
-
@eff = Effect.new(100, 100, :check, 2, 4, 10, nil, nil, '1')
|
53
|
-
|
54
|
-
@angle = 0
|
55
|
-
end
|
56
|
-
|
57
|
-
def needs_cursor?
|
58
|
-
true
|
59
|
-
end
|
60
|
-
|
61
|
-
def update
|
62
|
-
KB.update
|
63
|
-
begin @obj1.y -= 0.714; @obj4.y -= 0.714 end if KB.key_held? Gosu::KbUp
|
64
|
-
begin @obj1.x += 0.714; @obj4.x += 0.714 end if KB.key_down? Gosu::KbRight
|
65
|
-
begin @obj1.y += 0.714; @obj4.y += 0.714 end if KB.key_held? Gosu::KbDown
|
66
|
-
begin @obj1.x -= 0.714; @obj4.x -= 0.714 end if KB.key_down? Gosu::KbLeft
|
67
|
-
@btn.set_position rand(700), rand(550) if KB.key_pressed? Gosu::KbSpace
|
68
|
-
@btn.enabled = !@btn.enabled if KB.key_pressed? Gosu::KbLeftControl
|
69
|
-
@chk.checked = false if KB.key_pressed? Gosu::KbEscape
|
70
|
-
@chk.enabled = !@chk.enabled if KB.key_pressed? Gosu::KbRightControl
|
71
|
-
@txt.visible = !@txt.visible if KB.key_pressed? Gosu::KbReturn
|
72
|
-
@txt.enabled = !@txt.enabled if KB.key_pressed? Gosu::KbLeftAlt
|
73
|
-
@txt.locale = 'en-us' if KB.key_pressed? Gosu::KbX
|
74
|
-
@txt.locale = 'pt-br' if KB.key_pressed? Gosu::KbC
|
75
|
-
@pb.visible = !@pb.visible if KB.key_pressed? Gosu::KbE
|
76
|
-
@ddl.enabled = !@ddl.enabled if KB.key_pressed? Gosu::KbQ
|
77
|
-
@ddl.visible = !@ddl.visible if KB.key_pressed? Gosu::KbW
|
78
|
-
@panel.enabled = !@panel.enabled if KB.key_pressed? Gosu::KbN
|
79
|
-
@panel.visible = !@panel.visible if KB.key_pressed? Gosu::KbM
|
80
|
-
|
81
|
-
@panel.add_component(Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :southeast)) if KB.key_pressed?(Gosu::KbB)
|
82
|
-
|
83
|
-
@pb.increase 1 if KB.key_down? Gosu::KbD
|
84
|
-
@pb.decrease 1 if KB.key_down? Gosu::KbA
|
85
|
-
@pb.percentage = 0.5 if KB.key_pressed? Gosu::KbS
|
86
|
-
@pb.value = 10000 if KB.key_pressed? Gosu::KbZ
|
87
|
-
|
88
|
-
@ddl.value = 'olá amigos' if KB.key_pressed? Gosu::Kb1
|
89
|
-
@ddl.value = 'segunda' if KB.key_pressed? Gosu::Kb2
|
90
|
-
@ddl.value = 'terceira' if KB.key_pressed? Gosu::Kb3
|
91
|
-
|
92
|
-
G.window.toggle_fullscreen if KB.key_pressed?(Gosu::KB_RIGHT_ALT)
|
93
|
-
|
94
|
-
Mouse.update
|
95
|
-
if Mouse.double_click? :left
|
96
|
-
@obj1.x = Mouse.x
|
97
|
-
@obj1.y = Mouse.y
|
98
|
-
end
|
99
|
-
if Mouse.button_released? :right
|
100
|
-
if @flip.nil?; @flip = :horiz
|
101
|
-
else; @flip = nil; end
|
102
|
-
end
|
103
|
-
if Mouse.button_down? :left
|
104
|
-
@angle += 1
|
105
|
-
end
|
106
|
-
|
107
|
-
@btn.update
|
108
|
-
@chk.update
|
109
|
-
@txt.update
|
110
|
-
@ddl.update
|
111
|
-
|
112
|
-
@panel.update
|
113
|
-
|
114
|
-
@eff.update
|
115
|
-
|
116
|
-
@objs.each_with_index do |o, i|
|
117
|
-
o.move_free(i * 45, 3)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def draw
|
122
|
-
clear 0xabcdef
|
123
|
-
|
124
|
-
# @img.draw_rot 400, 100, 0, @angle, 1, 1
|
125
|
-
@obj1.draw color: 0x33ff33, angle: (@angle == 0 ? nil : @angle), scale_x: 1.5, scale_y: 1.5
|
126
|
-
@obj2.draw angle: (@angle == 0 ? nil : @angle), scale_x: 0.5, scale_y: 1.4
|
127
|
-
@obj3.draw flip: @flip
|
128
|
-
@obj4.draw round: true
|
129
|
-
@objs.each { |o| o.draw }
|
130
|
-
@writer1.write_line text: 'Testing effect 1', x: 400, y: 260, color: 0xffffff, effect: :border
|
131
|
-
@writer2.write_line 'Second effect test', 400, 280, :center, 0xffffff, 255, :border, 0xff0000, 2
|
132
|
-
@writer2.write_line 'Text with shadow!!', 400, 340, :center, 0xffff00, 255, :shadow, 0, 2, 0x80
|
133
|
-
@writer1.write_breaking "Testing multiple line text.\nThis should draw text "\
|
134
|
-
'across multiple lines, respecting a limit width
|
135
|
-
'Furthermore, the text must be right-aligned.',
|
136
|
-
780, 450, 300, :right, 0xff0000, 255, 1
|
137
|
-
|
138
|
-
@ddl.draw 0x80, 1, 0xff8080
|
139
|
-
@btn.draw 0xcc, 1, 0x33ff33
|
140
|
-
@chk.draw
|
141
|
-
@txt.draw
|
142
|
-
@pb.draw 0x66
|
143
|
-
|
144
|
-
@panel.draw(204, 10)
|
145
|
-
|
146
|
-
@eff.draw
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
MyGame.new.show
|
1
|
+
require_relative '../lib/minigl'
|
2
|
+
include MiniGL
|
3
|
+
|
4
|
+
class MyGame < GameWindow
|
5
|
+
def initialize
|
6
|
+
super 800, 600, false
|
7
|
+
|
8
|
+
# @img = Res.img :img1
|
9
|
+
@obj1 = GameObject.new 75, 75, 60, 60, :square3, Vector.new(-75, -75)
|
10
|
+
@obj2 = Sprite.new 400, 0, :img1
|
11
|
+
@obj3 = GameObject.new 4, 50, 24, 24, :check, Vector.new(-4, -4), 2, 4
|
12
|
+
@obj3.set_animation 1
|
13
|
+
@obj4 = Sprite.new 500, 0, :img1
|
14
|
+
@objs = []
|
15
|
+
8.times { @objs << GameObject.new(384, 284, 32, 32, :check, Vector.new(0, 0), 2, 4) }
|
16
|
+
@flip = nil
|
17
|
+
|
18
|
+
@font1 = Res.font :font1, 20
|
19
|
+
@font2 = Res.font :font1, 50
|
20
|
+
@writer1 = TextHelper.new @font1, 5
|
21
|
+
@writer2 = TextHelper.new @font2, 5
|
22
|
+
@btn = Button.new(10, 560, @font1, 'Test', :btn, 0x008000, 0x808080, 0xffffff, 0xff9980, true, true, 0, 4, 0, 0, 'friends', nil, 2, 2) { |x| puts "hello #{x}" }
|
23
|
+
@btn.enabled = false
|
24
|
+
@chk =
|
25
|
+
ToggleButton.new(x: 0, y: 30, font: @font1, text: 'Click me', img: :check, center_x: false, margin_x: 36, params: 'friends', anchor: :south) { |c, x|
|
26
|
+
puts "hello #{x}, checked: #{c}"
|
27
|
+
}
|
28
|
+
@txt = TextField.new(x: 0, y: 0, font: @font1, img: :text, margin_x: 15, margin_y: 5, max_length: 16, locale: 'PT-BR', scale_x: 1.2, scale_y: 0.8, anchor: :center_right)
|
29
|
+
@txt.visible = false
|
30
|
+
|
31
|
+
@pb = ProgressBar.new(50, 0, 200, 20, :barbg, :barfg, 3456, 70, 2, 2, @font1, 0xff000080, nil, nil, 1.8, 2, :center_left)
|
32
|
+
@ddl = DropDownList.new(0, 10, @font1, nil, nil, ['olá amigos', 'opção 2', 'terceira'], 0, 3, 150, 25, 0, 0x808080, 0xffffff, 0xffff00, nil, 2, 2.5, :north) { |a, b|
|
33
|
+
puts "mudou de #{a} para #{b}"
|
34
|
+
}
|
35
|
+
|
36
|
+
@panel = Panel.new(10, 10, 720, 520, [
|
37
|
+
Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn),
|
38
|
+
Label.new(0, 70, @font1, 'Teste de label', 0xcccccc, 0x666666, 1, 1, :north),
|
39
|
+
TextField.new(x: 5, y: 40, font: @font1, text: 'Opa', img: :text, margin_x: 5, margin_y: 5, anchor: :top_left),
|
40
|
+
Button.new(x: 0, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :top),
|
41
|
+
DropDownList.new(x: 0, y: 40, width: 150, height: 25, font: @font1, options: ['olá amigos', 'opção 2', 'terceira'], anchor: :north),
|
42
|
+
Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :northeast),
|
43
|
+
Button.new(x: 5, y: 0, font: @font1, text: 'Teste', img: :btn, anchor: :left),
|
44
|
+
Button.new(x: 0, y: 0, font: @font1, text: 'Teste', img: :btn, anchor: :center),
|
45
|
+
Button.new(x: 5, y: 0, font: @font1, text: 'Teste', img: :btn, anchor: :right),
|
46
|
+
ToggleButton.new(x: 5, y: 40, img: :check, center_x: false, margin_x: 36, anchor: :east),
|
47
|
+
Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :southwest),
|
48
|
+
Button.new(x: 0, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :south),
|
49
|
+
ProgressBar.new(0, 40, 200, 20, :barbg, :barfg, 3456, 70, 2, 2, @font1, 0xff000080, nil, nil, 1, 1, :bottom)
|
50
|
+
], :text, :tiled, true, 2, 2, :bottom_right)
|
51
|
+
|
52
|
+
@eff = Effect.new(100, 100, :check, 2, 4, 10, nil, nil, '1')
|
53
|
+
|
54
|
+
@angle = 0
|
55
|
+
end
|
56
|
+
|
57
|
+
def needs_cursor?
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
def update
|
62
|
+
KB.update
|
63
|
+
begin @obj1.y -= 0.714; @obj4.y -= 0.714 end if KB.key_held? Gosu::KbUp
|
64
|
+
begin @obj1.x += 0.714; @obj4.x += 0.714 end if KB.key_down? Gosu::KbRight
|
65
|
+
begin @obj1.y += 0.714; @obj4.y += 0.714 end if KB.key_held? Gosu::KbDown
|
66
|
+
begin @obj1.x -= 0.714; @obj4.x -= 0.714 end if KB.key_down? Gosu::KbLeft
|
67
|
+
@btn.set_position rand(700), rand(550) if KB.key_pressed? Gosu::KbSpace
|
68
|
+
@btn.enabled = !@btn.enabled if KB.key_pressed? Gosu::KbLeftControl
|
69
|
+
@chk.checked = false if KB.key_pressed? Gosu::KbEscape
|
70
|
+
@chk.enabled = !@chk.enabled if KB.key_pressed? Gosu::KbRightControl
|
71
|
+
@txt.visible = !@txt.visible if KB.key_pressed? Gosu::KbReturn
|
72
|
+
@txt.enabled = !@txt.enabled if KB.key_pressed? Gosu::KbLeftAlt
|
73
|
+
@txt.locale = 'en-us' if KB.key_pressed? Gosu::KbX
|
74
|
+
@txt.locale = 'pt-br' if KB.key_pressed? Gosu::KbC
|
75
|
+
@pb.visible = !@pb.visible if KB.key_pressed? Gosu::KbE
|
76
|
+
@ddl.enabled = !@ddl.enabled if KB.key_pressed? Gosu::KbQ
|
77
|
+
@ddl.visible = !@ddl.visible if KB.key_pressed? Gosu::KbW
|
78
|
+
@panel.enabled = !@panel.enabled if KB.key_pressed? Gosu::KbN
|
79
|
+
@panel.visible = !@panel.visible if KB.key_pressed? Gosu::KbM
|
80
|
+
|
81
|
+
@panel.add_component(Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :southeast)) if KB.key_pressed?(Gosu::KbB)
|
82
|
+
|
83
|
+
@pb.increase 1 if KB.key_down? Gosu::KbD
|
84
|
+
@pb.decrease 1 if KB.key_down? Gosu::KbA
|
85
|
+
@pb.percentage = 0.5 if KB.key_pressed? Gosu::KbS
|
86
|
+
@pb.value = 10000 if KB.key_pressed? Gosu::KbZ
|
87
|
+
|
88
|
+
@ddl.value = 'olá amigos' if KB.key_pressed? Gosu::Kb1
|
89
|
+
@ddl.value = 'segunda' if KB.key_pressed? Gosu::Kb2
|
90
|
+
@ddl.value = 'terceira' if KB.key_pressed? Gosu::Kb3
|
91
|
+
|
92
|
+
G.window.toggle_fullscreen if KB.key_pressed?(Gosu::KB_RIGHT_ALT)
|
93
|
+
|
94
|
+
Mouse.update
|
95
|
+
if Mouse.double_click? :left
|
96
|
+
@obj1.x = Mouse.x
|
97
|
+
@obj1.y = Mouse.y
|
98
|
+
end
|
99
|
+
if Mouse.button_released? :right
|
100
|
+
if @flip.nil?; @flip = :horiz
|
101
|
+
else; @flip = nil; end
|
102
|
+
end
|
103
|
+
if Mouse.button_down? :left
|
104
|
+
@angle += 1
|
105
|
+
end
|
106
|
+
|
107
|
+
@btn.update
|
108
|
+
@chk.update
|
109
|
+
@txt.update
|
110
|
+
@ddl.update
|
111
|
+
|
112
|
+
@panel.update
|
113
|
+
|
114
|
+
@eff.update
|
115
|
+
|
116
|
+
@objs.each_with_index do |o, i|
|
117
|
+
o.move_free(i * 45, 3)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def draw
|
122
|
+
clear 0xabcdef
|
123
|
+
|
124
|
+
# @img.draw_rot 400, 100, 0, @angle, 1, 1
|
125
|
+
@obj1.draw color: 0x33ff33, angle: (@angle == 0 ? nil : @angle), scale_x: 1.5, scale_y: 1.5
|
126
|
+
@obj2.draw angle: (@angle == 0 ? nil : @angle), scale_x: 0.5, scale_y: 1.4
|
127
|
+
@obj3.draw flip: @flip
|
128
|
+
@obj4.draw round: true
|
129
|
+
@objs.each { |o| o.draw }
|
130
|
+
@writer1.write_line text: 'Testing <b>effect</b> 1', x: 400, y: 260, color: 0xffffff, effect: :border
|
131
|
+
@writer2.write_line 'Second <i>effect</i> test', 400, 280, :center, 0xffffff, 255, :border, 0xff0000, 2
|
132
|
+
@writer2.write_line 'Text with shadow!!', 400, 340, :center, 0xffff00, 255, :shadow, 0, 2, 0x80
|
133
|
+
@writer1.write_breaking "Testing <b>multiple line</b> text.\nThis should draw text "\
|
134
|
+
'across multiple lines, <i>respecting</i> a limit <c=0000ff>width</c>. '\
|
135
|
+
'Furthermore, the text must be right-aligned.',
|
136
|
+
780, 450, 300, :right, 0xff0000, 255, 1
|
137
|
+
|
138
|
+
@ddl.draw 0x80, 1, 0xff8080
|
139
|
+
@btn.draw 0xcc, 1, 0x33ff33
|
140
|
+
@chk.draw
|
141
|
+
@txt.draw
|
142
|
+
@pb.draw 0x66
|
143
|
+
|
144
|
+
@panel.draw(204, 10)
|
145
|
+
|
146
|
+
@eff.draw
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
MyGame.new.show
|