libtcod 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +4 -4
- data/LICENSE +21 -21
- data/README.md +81 -81
- data/Rakefile +2 -2
- data/clib/i686/SDL.dll +0 -0
- data/clib/i686/libtcod-mingw.dll +0 -0
- data/examples/python_tutorial_part_1/main.rb +58 -58
- data/examples/tile_demo/oryx_tiles.png +0 -0
- data/examples/tile_demo/tile_demo.rb +341 -0
- data/lib/libtcod.rb +10 -9
- data/lib/libtcod/bindings.rb +642 -640
- data/lib/libtcod/color_consts.rb +225 -225
- data/lib/libtcod/console.rb +80 -46
- data/lib/libtcod/consts.rb +218 -218
- data/lib/libtcod/struct.rb +34 -34
- data/lib/libtcod/system.rb +7 -0
- data/lib/libtcod/version.rb +3 -3
- data/libtcod.gemspec +21 -21
- data/test/color.rb +39 -39
- data/test/console.rb +8 -8
- data/test/helpers.rb +2 -2
- metadata +7 -2
data/lib/libtcod/consts.rb
CHANGED
@@ -1,218 +1,218 @@
|
|
1
|
-
module TCOD
|
2
|
-
# background rendering modes
|
3
|
-
BKGND_NONE = 0
|
4
|
-
BKGND_SET = 1
|
5
|
-
BKGND_MULTIPLY = 2
|
6
|
-
BKGND_LIGHTEN = 3
|
7
|
-
BKGND_DARKEN = 4
|
8
|
-
BKGND_SCREEN = 5
|
9
|
-
BKGND_COLOR_DODGE = 6
|
10
|
-
BKGND_COLOR_BURN = 7
|
11
|
-
BKGND_ADD = 8
|
12
|
-
BKGND_ADDA = 9
|
13
|
-
BKGND_BURN = 10
|
14
|
-
BKGND_OVERLAY = 11
|
15
|
-
BKGND_ALPH = 12
|
16
|
-
BKGND_DEFAULT=13
|
17
|
-
|
18
|
-
# non blocking key events types
|
19
|
-
KEY_PRESSED = 1
|
20
|
-
KEY_RELEASED = 2
|
21
|
-
|
22
|
-
# key codes
|
23
|
-
KEY_NONE = 0
|
24
|
-
KEY_ESCAPE = 1
|
25
|
-
KEY_BACKSPACE = 2
|
26
|
-
KEY_TAB = 3
|
27
|
-
KEY_ENTER = 4
|
28
|
-
KEY_SHIFT = 5
|
29
|
-
KEY_CONTROL = 6
|
30
|
-
KEY_ALT = 7
|
31
|
-
KEY_PAUSE = 8
|
32
|
-
KEY_CAPSLOCK = 9
|
33
|
-
KEY_PAGEUP = 10
|
34
|
-
KEY_PAGEDOWN = 11
|
35
|
-
KEY_END = 12
|
36
|
-
KEY_HOME = 13
|
37
|
-
KEY_UP = 14
|
38
|
-
KEY_LEFT = 15
|
39
|
-
KEY_RIGHT = 16
|
40
|
-
KEY_DOWN = 17
|
41
|
-
KEY_PRINTSCREEN = 18
|
42
|
-
KEY_INSERT = 19
|
43
|
-
KEY_DELETE = 20
|
44
|
-
KEY_LWIN = 21
|
45
|
-
KEY_RWIN = 22
|
46
|
-
KEY_APPS = 23
|
47
|
-
KEY_0 = 24
|
48
|
-
KEY_1 = 25
|
49
|
-
KEY_2 = 26
|
50
|
-
KEY_3 = 27
|
51
|
-
KEY_4 = 28
|
52
|
-
KEY_5 = 29
|
53
|
-
KEY_6 = 30
|
54
|
-
KEY_7 = 31
|
55
|
-
KEY_8 = 32
|
56
|
-
KEY_9 = 33
|
57
|
-
KEY_KP0 = 34
|
58
|
-
KEY_KP1 = 35
|
59
|
-
KEY_KP2 = 36
|
60
|
-
KEY_KP3 = 37
|
61
|
-
KEY_KP4 = 38
|
62
|
-
KEY_KP5 = 39
|
63
|
-
KEY_KP6 = 40
|
64
|
-
KEY_KP7 = 41
|
65
|
-
KEY_KP8 = 42
|
66
|
-
KEY_KP9 = 43
|
67
|
-
KEY_KPADD = 44
|
68
|
-
KEY_KPSUB = 45
|
69
|
-
KEY_KPDIV = 46
|
70
|
-
KEY_KPMUL = 47
|
71
|
-
KEY_KPDEC = 48
|
72
|
-
KEY_KPENTER = 49
|
73
|
-
KEY_F1 = 50
|
74
|
-
KEY_F2 = 51
|
75
|
-
KEY_F3 = 52
|
76
|
-
KEY_F4 = 53
|
77
|
-
KEY_F5 = 54
|
78
|
-
KEY_F6 = 55
|
79
|
-
KEY_F7 = 56
|
80
|
-
KEY_F8 = 57
|
81
|
-
KEY_F9 = 58
|
82
|
-
KEY_F10 = 59
|
83
|
-
KEY_F11 = 60
|
84
|
-
KEY_F12 = 61
|
85
|
-
KEY_NUMLOCK = 62
|
86
|
-
KEY_SCROLLLOCK = 63
|
87
|
-
KEY_SPACE = 64
|
88
|
-
KEY_CHAR = 65
|
89
|
-
|
90
|
-
### special chars
|
91
|
-
|
92
|
-
# single walls
|
93
|
-
CHAR_HLINE = 196
|
94
|
-
CHAR_VLINE = 179
|
95
|
-
CHAR_NE = 191
|
96
|
-
CHAR_NW = 218
|
97
|
-
CHAR_SE = 217
|
98
|
-
CHAR_SW = 192
|
99
|
-
CHAR_TEEW = 180
|
100
|
-
CHAR_TEEE = 195
|
101
|
-
CHAR_TEEN = 193
|
102
|
-
CHAR_TEES = 194
|
103
|
-
CHAR_CROSS = 197
|
104
|
-
|
105
|
-
# double walls
|
106
|
-
CHAR_DHLINE = 205
|
107
|
-
CHAR_DVLINE = 186
|
108
|
-
CHAR_DNE = 187
|
109
|
-
CHAR_DNW = 201
|
110
|
-
CHAR_DSE = 188
|
111
|
-
CHAR_DSW = 200
|
112
|
-
CHAR_DTEEW = 185
|
113
|
-
CHAR_DTEEE = 204
|
114
|
-
CHAR_DTEEN = 202
|
115
|
-
CHAR_DTEES = 203
|
116
|
-
CHAR_DCROSS = 206
|
117
|
-
|
118
|
-
# blocks
|
119
|
-
CHAR_BLOCK1 = 176
|
120
|
-
CHAR_BLOCK2 = 177
|
121
|
-
CHAR_BLOCK3 = 178
|
122
|
-
|
123
|
-
# arrows
|
124
|
-
CHAR_ARROW_N = 24
|
125
|
-
CHAR_ARROW_S = 25
|
126
|
-
CHAR_ARROW_E = 26
|
127
|
-
CHAR_ARROW_W = 27
|
128
|
-
|
129
|
-
# arrows without tail
|
130
|
-
CHAR_ARROW2_N = 30
|
131
|
-
CHAR_ARROW2_S = 31
|
132
|
-
CHAR_ARROW2_E = 16
|
133
|
-
CHAR_ARROW2_W = 17
|
134
|
-
|
135
|
-
# double arrows
|
136
|
-
CHAR_DARROW_H = 29
|
137
|
-
CHAR_DARROW_V = 18
|
138
|
-
|
139
|
-
# GUI stuff
|
140
|
-
CHAR_CHECKBOX_UNSET = 224
|
141
|
-
CHAR_CHECKBOX_SET = 225
|
142
|
-
CHAR_RADIO_UNSET = 9
|
143
|
-
CHAR_RADIO_SET = 10
|
144
|
-
|
145
|
-
# sub-pixel resolution kit
|
146
|
-
CHAR_SUBP_NW = 226
|
147
|
-
CHAR_SUBP_NE = 227
|
148
|
-
CHAR_SUBP_N = 228
|
149
|
-
CHAR_SUBP_SE = 229
|
150
|
-
CHAR_SUBP_DIAG = 230
|
151
|
-
CHAR_SUBP_E = 231
|
152
|
-
CHAR_SUBP_SW = 232
|
153
|
-
|
154
|
-
# misc characters
|
155
|
-
CHAR_BULLET = 7
|
156
|
-
CHAR_BULLET_INV = 8
|
157
|
-
CHAR_BULLET_SQUARE = 254
|
158
|
-
CHAR_CENT = 189
|
159
|
-
CHAR_CLUB = 5
|
160
|
-
CHAR_COPYRIGHT = 184
|
161
|
-
CHAR_CURRENCY = 207
|
162
|
-
CHAR_DIAMOND = 4
|
163
|
-
CHAR_DIVISION = 246
|
164
|
-
CHAR_EXCLAM_DOUBLE = 19
|
165
|
-
CHAR_FEMALE = 12
|
166
|
-
CHAR_FUNCTION = 159
|
167
|
-
CHAR_GRADE = 248
|
168
|
-
CHAR_HALF = 171
|
169
|
-
CHAR_HEART = 3
|
170
|
-
CHAR_LIGHT = 15
|
171
|
-
CHAR_MALE = 11
|
172
|
-
CHAR_MULTIPLICATION = 158
|
173
|
-
CHAR_NOTE = 13
|
174
|
-
CHAR_NOTE_DOUBLE = 14
|
175
|
-
CHAR_ONE_QUARTER = 172
|
176
|
-
CHAR_PILCROW = 20
|
177
|
-
CHAR_POUND = 156
|
178
|
-
CHAR_POW1 = 251
|
179
|
-
CHAR_POW2 = 253
|
180
|
-
CHAR_POW3 = 252
|
181
|
-
CHAR_RESERVED = 169
|
182
|
-
CHAR_SECTION = 21
|
183
|
-
CHAR_SMILIE = 1
|
184
|
-
CHAR_SMILIE_INV = 2
|
185
|
-
CHAR_SPADE = 6
|
186
|
-
CHAR_THREE_QUARTERS = 243
|
187
|
-
CHAR_UMLAUT = 249
|
188
|
-
CHAR_YEN = 190
|
189
|
-
|
190
|
-
# font flags
|
191
|
-
FONT_LAYOUT_ASCII_INCOL = 1
|
192
|
-
FONT_LAYOUT_ASCII_INROW = 2
|
193
|
-
FONT_TYPE_GREYSCALE = 4
|
194
|
-
FONT_TYPE_GRAYSCALE = 4
|
195
|
-
FONT_LAYOUT_TCOD = 8
|
196
|
-
|
197
|
-
# color control codes
|
198
|
-
COLCTRL_1=1
|
199
|
-
COLCTRL_2=2
|
200
|
-
COLCTRL_3=3
|
201
|
-
COLCTRL_4=4
|
202
|
-
COLCTRL_5=5
|
203
|
-
COLCTRL_NUMBER=5
|
204
|
-
COLCTRL_FORE_RGB=6
|
205
|
-
COLCTRL_BACK_RGB=7
|
206
|
-
COLCTRL_STOP=8
|
207
|
-
|
208
|
-
# renderers
|
209
|
-
RENDERER_GLSL=0
|
210
|
-
RENDERER_OPENGL=1
|
211
|
-
RENDERER_SDL=2
|
212
|
-
NB_RENDERERS=3
|
213
|
-
|
214
|
-
# alignment
|
215
|
-
LEFT=0
|
216
|
-
RIGHT=1
|
217
|
-
CENTER=2
|
218
|
-
end
|
1
|
+
module TCOD
|
2
|
+
# background rendering modes
|
3
|
+
BKGND_NONE = 0
|
4
|
+
BKGND_SET = 1
|
5
|
+
BKGND_MULTIPLY = 2
|
6
|
+
BKGND_LIGHTEN = 3
|
7
|
+
BKGND_DARKEN = 4
|
8
|
+
BKGND_SCREEN = 5
|
9
|
+
BKGND_COLOR_DODGE = 6
|
10
|
+
BKGND_COLOR_BURN = 7
|
11
|
+
BKGND_ADD = 8
|
12
|
+
BKGND_ADDA = 9
|
13
|
+
BKGND_BURN = 10
|
14
|
+
BKGND_OVERLAY = 11
|
15
|
+
BKGND_ALPH = 12
|
16
|
+
BKGND_DEFAULT=13
|
17
|
+
|
18
|
+
# non blocking key events types
|
19
|
+
KEY_PRESSED = 1
|
20
|
+
KEY_RELEASED = 2
|
21
|
+
|
22
|
+
# key codes
|
23
|
+
KEY_NONE = 0
|
24
|
+
KEY_ESCAPE = 1
|
25
|
+
KEY_BACKSPACE = 2
|
26
|
+
KEY_TAB = 3
|
27
|
+
KEY_ENTER = 4
|
28
|
+
KEY_SHIFT = 5
|
29
|
+
KEY_CONTROL = 6
|
30
|
+
KEY_ALT = 7
|
31
|
+
KEY_PAUSE = 8
|
32
|
+
KEY_CAPSLOCK = 9
|
33
|
+
KEY_PAGEUP = 10
|
34
|
+
KEY_PAGEDOWN = 11
|
35
|
+
KEY_END = 12
|
36
|
+
KEY_HOME = 13
|
37
|
+
KEY_UP = 14
|
38
|
+
KEY_LEFT = 15
|
39
|
+
KEY_RIGHT = 16
|
40
|
+
KEY_DOWN = 17
|
41
|
+
KEY_PRINTSCREEN = 18
|
42
|
+
KEY_INSERT = 19
|
43
|
+
KEY_DELETE = 20
|
44
|
+
KEY_LWIN = 21
|
45
|
+
KEY_RWIN = 22
|
46
|
+
KEY_APPS = 23
|
47
|
+
KEY_0 = 24
|
48
|
+
KEY_1 = 25
|
49
|
+
KEY_2 = 26
|
50
|
+
KEY_3 = 27
|
51
|
+
KEY_4 = 28
|
52
|
+
KEY_5 = 29
|
53
|
+
KEY_6 = 30
|
54
|
+
KEY_7 = 31
|
55
|
+
KEY_8 = 32
|
56
|
+
KEY_9 = 33
|
57
|
+
KEY_KP0 = 34
|
58
|
+
KEY_KP1 = 35
|
59
|
+
KEY_KP2 = 36
|
60
|
+
KEY_KP3 = 37
|
61
|
+
KEY_KP4 = 38
|
62
|
+
KEY_KP5 = 39
|
63
|
+
KEY_KP6 = 40
|
64
|
+
KEY_KP7 = 41
|
65
|
+
KEY_KP8 = 42
|
66
|
+
KEY_KP9 = 43
|
67
|
+
KEY_KPADD = 44
|
68
|
+
KEY_KPSUB = 45
|
69
|
+
KEY_KPDIV = 46
|
70
|
+
KEY_KPMUL = 47
|
71
|
+
KEY_KPDEC = 48
|
72
|
+
KEY_KPENTER = 49
|
73
|
+
KEY_F1 = 50
|
74
|
+
KEY_F2 = 51
|
75
|
+
KEY_F3 = 52
|
76
|
+
KEY_F4 = 53
|
77
|
+
KEY_F5 = 54
|
78
|
+
KEY_F6 = 55
|
79
|
+
KEY_F7 = 56
|
80
|
+
KEY_F8 = 57
|
81
|
+
KEY_F9 = 58
|
82
|
+
KEY_F10 = 59
|
83
|
+
KEY_F11 = 60
|
84
|
+
KEY_F12 = 61
|
85
|
+
KEY_NUMLOCK = 62
|
86
|
+
KEY_SCROLLLOCK = 63
|
87
|
+
KEY_SPACE = 64
|
88
|
+
KEY_CHAR = 65
|
89
|
+
|
90
|
+
### special chars
|
91
|
+
|
92
|
+
# single walls
|
93
|
+
CHAR_HLINE = 196
|
94
|
+
CHAR_VLINE = 179
|
95
|
+
CHAR_NE = 191
|
96
|
+
CHAR_NW = 218
|
97
|
+
CHAR_SE = 217
|
98
|
+
CHAR_SW = 192
|
99
|
+
CHAR_TEEW = 180
|
100
|
+
CHAR_TEEE = 195
|
101
|
+
CHAR_TEEN = 193
|
102
|
+
CHAR_TEES = 194
|
103
|
+
CHAR_CROSS = 197
|
104
|
+
|
105
|
+
# double walls
|
106
|
+
CHAR_DHLINE = 205
|
107
|
+
CHAR_DVLINE = 186
|
108
|
+
CHAR_DNE = 187
|
109
|
+
CHAR_DNW = 201
|
110
|
+
CHAR_DSE = 188
|
111
|
+
CHAR_DSW = 200
|
112
|
+
CHAR_DTEEW = 185
|
113
|
+
CHAR_DTEEE = 204
|
114
|
+
CHAR_DTEEN = 202
|
115
|
+
CHAR_DTEES = 203
|
116
|
+
CHAR_DCROSS = 206
|
117
|
+
|
118
|
+
# blocks
|
119
|
+
CHAR_BLOCK1 = 176
|
120
|
+
CHAR_BLOCK2 = 177
|
121
|
+
CHAR_BLOCK3 = 178
|
122
|
+
|
123
|
+
# arrows
|
124
|
+
CHAR_ARROW_N = 24
|
125
|
+
CHAR_ARROW_S = 25
|
126
|
+
CHAR_ARROW_E = 26
|
127
|
+
CHAR_ARROW_W = 27
|
128
|
+
|
129
|
+
# arrows without tail
|
130
|
+
CHAR_ARROW2_N = 30
|
131
|
+
CHAR_ARROW2_S = 31
|
132
|
+
CHAR_ARROW2_E = 16
|
133
|
+
CHAR_ARROW2_W = 17
|
134
|
+
|
135
|
+
# double arrows
|
136
|
+
CHAR_DARROW_H = 29
|
137
|
+
CHAR_DARROW_V = 18
|
138
|
+
|
139
|
+
# GUI stuff
|
140
|
+
CHAR_CHECKBOX_UNSET = 224
|
141
|
+
CHAR_CHECKBOX_SET = 225
|
142
|
+
CHAR_RADIO_UNSET = 9
|
143
|
+
CHAR_RADIO_SET = 10
|
144
|
+
|
145
|
+
# sub-pixel resolution kit
|
146
|
+
CHAR_SUBP_NW = 226
|
147
|
+
CHAR_SUBP_NE = 227
|
148
|
+
CHAR_SUBP_N = 228
|
149
|
+
CHAR_SUBP_SE = 229
|
150
|
+
CHAR_SUBP_DIAG = 230
|
151
|
+
CHAR_SUBP_E = 231
|
152
|
+
CHAR_SUBP_SW = 232
|
153
|
+
|
154
|
+
# misc characters
|
155
|
+
CHAR_BULLET = 7
|
156
|
+
CHAR_BULLET_INV = 8
|
157
|
+
CHAR_BULLET_SQUARE = 254
|
158
|
+
CHAR_CENT = 189
|
159
|
+
CHAR_CLUB = 5
|
160
|
+
CHAR_COPYRIGHT = 184
|
161
|
+
CHAR_CURRENCY = 207
|
162
|
+
CHAR_DIAMOND = 4
|
163
|
+
CHAR_DIVISION = 246
|
164
|
+
CHAR_EXCLAM_DOUBLE = 19
|
165
|
+
CHAR_FEMALE = 12
|
166
|
+
CHAR_FUNCTION = 159
|
167
|
+
CHAR_GRADE = 248
|
168
|
+
CHAR_HALF = 171
|
169
|
+
CHAR_HEART = 3
|
170
|
+
CHAR_LIGHT = 15
|
171
|
+
CHAR_MALE = 11
|
172
|
+
CHAR_MULTIPLICATION = 158
|
173
|
+
CHAR_NOTE = 13
|
174
|
+
CHAR_NOTE_DOUBLE = 14
|
175
|
+
CHAR_ONE_QUARTER = 172
|
176
|
+
CHAR_PILCROW = 20
|
177
|
+
CHAR_POUND = 156
|
178
|
+
CHAR_POW1 = 251
|
179
|
+
CHAR_POW2 = 253
|
180
|
+
CHAR_POW3 = 252
|
181
|
+
CHAR_RESERVED = 169
|
182
|
+
CHAR_SECTION = 21
|
183
|
+
CHAR_SMILIE = 1
|
184
|
+
CHAR_SMILIE_INV = 2
|
185
|
+
CHAR_SPADE = 6
|
186
|
+
CHAR_THREE_QUARTERS = 243
|
187
|
+
CHAR_UMLAUT = 249
|
188
|
+
CHAR_YEN = 190
|
189
|
+
|
190
|
+
# font flags
|
191
|
+
FONT_LAYOUT_ASCII_INCOL = 1
|
192
|
+
FONT_LAYOUT_ASCII_INROW = 2
|
193
|
+
FONT_TYPE_GREYSCALE = 4
|
194
|
+
FONT_TYPE_GRAYSCALE = 4
|
195
|
+
FONT_LAYOUT_TCOD = 8
|
196
|
+
|
197
|
+
# color control codes
|
198
|
+
COLCTRL_1=1
|
199
|
+
COLCTRL_2=2
|
200
|
+
COLCTRL_3=3
|
201
|
+
COLCTRL_4=4
|
202
|
+
COLCTRL_5=5
|
203
|
+
COLCTRL_NUMBER=5
|
204
|
+
COLCTRL_FORE_RGB=6
|
205
|
+
COLCTRL_BACK_RGB=7
|
206
|
+
COLCTRL_STOP=8
|
207
|
+
|
208
|
+
# renderers
|
209
|
+
RENDERER_GLSL=0
|
210
|
+
RENDERER_OPENGL=1
|
211
|
+
RENDERER_SDL=2
|
212
|
+
NB_RENDERERS=3
|
213
|
+
|
214
|
+
# alignment
|
215
|
+
LEFT=0
|
216
|
+
RIGHT=1
|
217
|
+
CENTER=2
|
218
|
+
end
|
data/lib/libtcod/struct.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
module TCOD
|
2
|
-
# Wrapper for FFI::Struct which allows access of
|
3
|
-
# properties by method as well as indexing.
|
4
|
-
|
5
|
-
class MethodStruct < FFI::Struct
|
6
|
-
class << self
|
7
|
-
alias_method :old_layout, :layout
|
8
|
-
|
9
|
-
def layout(*keys)
|
10
|
-
old_layout(*keys)
|
11
|
-
keys.each_slice(2).each do |key,type|
|
12
|
-
define_method(key) do
|
13
|
-
self[key]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class MethodUnion < FFI::Union
|
21
|
-
class << self
|
22
|
-
alias_method :old_layout, :layout
|
23
|
-
|
24
|
-
def layout(*keys)
|
25
|
-
old_layout(*keys)
|
26
|
-
keys.each_slice(2).each do |key,type|
|
27
|
-
define_method(key) do
|
28
|
-
self[key]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
module TCOD
|
2
|
+
# Wrapper for FFI::Struct which allows access of
|
3
|
+
# properties by method as well as indexing.
|
4
|
+
|
5
|
+
class MethodStruct < FFI::Struct
|
6
|
+
class << self
|
7
|
+
alias_method :old_layout, :layout
|
8
|
+
|
9
|
+
def layout(*keys)
|
10
|
+
old_layout(*keys)
|
11
|
+
keys.each_slice(2).each do |key,type|
|
12
|
+
define_method(key) do
|
13
|
+
self[key]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class MethodUnion < FFI::Union
|
21
|
+
class << self
|
22
|
+
alias_method :old_layout, :layout
|
23
|
+
|
24
|
+
def layout(*keys)
|
25
|
+
old_layout(*keys)
|
26
|
+
keys.each_slice(2).each do |key,type|
|
27
|
+
define_method(key) do
|
28
|
+
self[key]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|