@gamely/gly-engine-micro 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.lua +75 -90
- package/package.json +1 -1
package/dist/main.lua
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
local math = ((function() local x, y = pcall(require, 'math'); return x and y end)()) or _G.math
|
|
2
|
-
local
|
|
3
|
-
local
|
|
4
|
-
local
|
|
5
|
-
local
|
|
6
|
-
local
|
|
7
|
-
local
|
|
8
|
-
local
|
|
9
|
-
local
|
|
10
|
-
local
|
|
11
|
-
local
|
|
12
|
-
local
|
|
13
|
-
local
|
|
14
|
-
local
|
|
15
|
-
local
|
|
16
|
-
local
|
|
17
|
-
local
|
|
18
|
-
local
|
|
19
|
-
local
|
|
20
|
-
local
|
|
21
|
-
local
|
|
22
|
-
local
|
|
23
|
-
local
|
|
24
|
-
local
|
|
25
|
-
local
|
|
2
|
+
local source_version_13d9 = nil
|
|
3
|
+
local source_engine_api_system_app_13eb = nil
|
|
4
|
+
local source_engine_api_system_key_13f6 = nil
|
|
5
|
+
local source_engine_api_math_basic_1401 = nil
|
|
6
|
+
local source_engine_api_math_clib_140c = nil
|
|
7
|
+
local source_engine_api_math_random_1417 = nil
|
|
8
|
+
local source_engine_api_data_array_1422 = nil
|
|
9
|
+
local source_engine_api_draw_text_142d = nil
|
|
10
|
+
local source_engine_api_draw_poly_1438 = nil
|
|
11
|
+
local source_engine_api_raw_memory_1443 = nil
|
|
12
|
+
local source_engine_api_system_color_1455 = nil
|
|
13
|
+
local source_shared_var_object_std_1460 = nil
|
|
14
|
+
local source_shared_string_eval_code_1472 = nil
|
|
15
|
+
local source_shared_functional_decorator_17d0 = nil
|
|
16
|
+
local function main_13d0()
|
|
17
|
+
local version = source_version_13d9()
|
|
18
|
+
local engine_game = source_engine_api_system_app_13eb()
|
|
19
|
+
local engine_key = source_engine_api_system_key_13f6()
|
|
20
|
+
local engine_math = source_engine_api_math_basic_1401()
|
|
21
|
+
local engine_math_clib = source_engine_api_math_clib_140c()
|
|
22
|
+
local engine_math_random = source_engine_api_math_random_1417()
|
|
23
|
+
local engine_array = source_engine_api_data_array_1422()
|
|
24
|
+
local engine_api_draw_text = source_engine_api_draw_text_142d()
|
|
25
|
+
local engine_api_draw_poly = source_engine_api_draw_poly_1438()
|
|
26
|
+
local engine_raw_memory = source_engine_api_raw_memory_1443()
|
|
27
|
+
local color = source_engine_api_system_color_1455()
|
|
28
|
+
local std = source_shared_var_object_std_1460()
|
|
29
|
+
local eval_code = source_shared_string_eval_code_1472()
|
|
26
30
|
local f=function(a,b)end
|
|
27
31
|
local engine={keyboard=f}
|
|
28
32
|
local application={
|
|
@@ -54,6 +58,7 @@ poly=native_draw_poly,
|
|
|
54
58
|
line=native_draw_line
|
|
55
59
|
}
|
|
56
60
|
local cfg_text={
|
|
61
|
+
is_tui = native_text_is_tui,
|
|
57
62
|
font_previous=native_text_font_previous
|
|
58
63
|
}
|
|
59
64
|
function native_callback_loop(dt)
|
|
@@ -105,18 +110,19 @@ std.draw.clear=function(tint)
|
|
|
105
110
|
native_draw_clear(tint, 0, 0, application.data.width, application.data.height)
|
|
106
111
|
end
|
|
107
112
|
engine.root=application
|
|
113
|
+
color.install(std, engine)
|
|
108
114
|
engine_raw_memory.install(std, engine)
|
|
109
115
|
engine_game.install(std, engine, cfg_system)
|
|
110
116
|
engine_key.install(std, engine, {})
|
|
111
|
-
engine_math.install(std, engine)
|
|
112
|
-
engine_math.wave.install(std, engine)
|
|
113
|
-
engine_math.clib.install(std, engine)
|
|
114
|
-
engine_math.clib_random.install(std, engine)
|
|
115
117
|
engine_array.install(std, engine, nil, 'array')
|
|
116
118
|
engine_api_draw_text.install(std, engine, cfg_text)
|
|
117
119
|
engine_api_draw_poly.install(std, engine, cfg_poly)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
engine_math.install(std, engine)
|
|
121
|
+
if math or flr then engine_math_clib.install(std, engine) end
|
|
122
|
+
if math then engine_math_random.install(std, engine) end
|
|
123
|
+
if application.meta and application.meta.title then
|
|
124
|
+
std.app.title(application.meta.title..' - '..(application.meta.version or ''))
|
|
125
|
+
end
|
|
120
126
|
engine.current=application
|
|
121
127
|
application.callbacks.init(std, application.data)
|
|
122
128
|
end
|
|
@@ -130,12 +136,12 @@ version=version
|
|
|
130
136
|
}
|
|
131
137
|
return P
|
|
132
138
|
end
|
|
133
|
-
|
|
134
|
-
return '0.1.
|
|
139
|
+
source_version_13d9 = function()
|
|
140
|
+
return '0.1.4'
|
|
135
141
|
end
|
|
136
142
|
--
|
|
137
|
-
|
|
138
|
-
local util_decorator =
|
|
143
|
+
source_engine_api_system_app_13eb = function()
|
|
144
|
+
local util_decorator = source_shared_functional_decorator_17d0()
|
|
139
145
|
local function reset(std, engine)
|
|
140
146
|
if std.node then
|
|
141
147
|
std.bus.emit('exit')
|
|
@@ -175,7 +181,7 @@ install=install
|
|
|
175
181
|
return P
|
|
176
182
|
end
|
|
177
183
|
--
|
|
178
|
-
|
|
184
|
+
source_engine_api_system_key_13f6 = function()
|
|
179
185
|
local function real_key(std, engine, rkey, rvalue)
|
|
180
186
|
local value = rvalue == 1 or rvalue == true
|
|
181
187
|
local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
|
|
@@ -212,7 +218,7 @@ install = install
|
|
|
212
218
|
return P
|
|
213
219
|
end
|
|
214
220
|
--
|
|
215
|
-
|
|
221
|
+
source_engine_api_math_basic_1401 = function()
|
|
216
222
|
local function abs(value)
|
|
217
223
|
if value < 0 then
|
|
218
224
|
return -value
|
|
@@ -291,30 +297,6 @@ index = index + 1
|
|
|
291
297
|
end
|
|
292
298
|
return min_value
|
|
293
299
|
end
|
|
294
|
-
local function sine(t, freq)
|
|
295
|
-
return math.pi and math.sin(2 * math.pi * freq * t) or 1
|
|
296
|
-
end
|
|
297
|
-
local function ramp(t, freq, ratio)
|
|
298
|
-
t = (t / 2) % (1 / freq) * freq
|
|
299
|
-
if t < ratio then
|
|
300
|
-
return 2 * t / ratio - 1
|
|
301
|
-
else
|
|
302
|
-
return (2 * t - ratio - 1) / (ratio - 1)
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
local function saw(t, freq)
|
|
306
|
-
return ramp(t, freq, 1)
|
|
307
|
-
end
|
|
308
|
-
local function triangle(t, freq)
|
|
309
|
-
return ramp(t, freq, 1/2)
|
|
310
|
-
end
|
|
311
|
-
local function rect(t, freq, duty)
|
|
312
|
-
duty = 1 - duty * 2
|
|
313
|
-
return saw(t, freq) > duty and 1 or -1
|
|
314
|
-
end
|
|
315
|
-
local function square(t, freq)
|
|
316
|
-
return rect(t, freq, 1/2)
|
|
317
|
-
end
|
|
318
300
|
local function install(std)
|
|
319
301
|
std.math = std.math or {}
|
|
320
302
|
std.math.abs=abs
|
|
@@ -329,14 +311,15 @@ std.math.map=map
|
|
|
329
311
|
std.math.max=max
|
|
330
312
|
std.math.min=min
|
|
331
313
|
end
|
|
332
|
-
local
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
std.math.square=square
|
|
337
|
-
std.math.triangle=triangle
|
|
314
|
+
local P = {
|
|
315
|
+
install = install
|
|
316
|
+
}
|
|
317
|
+
return P
|
|
338
318
|
end
|
|
339
|
-
|
|
319
|
+
--
|
|
320
|
+
source_engine_api_math_clib_140c = function()
|
|
321
|
+
local function install(std)
|
|
322
|
+
assert(math and (1/2 ~= 0))
|
|
340
323
|
std.math = std.math or {}
|
|
341
324
|
std.math.acos=math.acos
|
|
342
325
|
std.math.asin=math.asin
|
|
@@ -364,31 +347,31 @@ std.math.sqrt=math.sqrt
|
|
|
364
347
|
std.math.tan=math.tan
|
|
365
348
|
std.math.tanh=math.tanh
|
|
366
349
|
end
|
|
367
|
-
local
|
|
350
|
+
local P = {
|
|
351
|
+
install = install
|
|
352
|
+
}
|
|
353
|
+
return P
|
|
354
|
+
end
|
|
355
|
+
--
|
|
356
|
+
source_engine_api_math_random_1417 = function()
|
|
357
|
+
local function install(std)
|
|
358
|
+
assert(math and (1/2 ~= 0))
|
|
368
359
|
std.math = std.math or {}
|
|
369
360
|
std.math.random = function(a, b)
|
|
370
361
|
a = a and math.floor(a)
|
|
371
362
|
b = b and math.floor(b)
|
|
363
|
+
if a > b then a, b = b, a end
|
|
372
364
|
return math.random(a, b)
|
|
373
365
|
end
|
|
374
366
|
end
|
|
375
367
|
local P = {
|
|
376
|
-
install = install
|
|
377
|
-
wave = {
|
|
378
|
-
install = install_wave
|
|
379
|
-
},
|
|
380
|
-
clib = {
|
|
381
|
-
install = install_clib
|
|
382
|
-
},
|
|
383
|
-
clib_random = {
|
|
384
|
-
install = install_clib_random
|
|
385
|
-
}
|
|
368
|
+
install = install
|
|
386
369
|
}
|
|
387
|
-
return P
|
|
370
|
+
return P
|
|
388
371
|
end
|
|
389
372
|
--
|
|
390
|
-
|
|
391
|
-
local util_decorator =
|
|
373
|
+
source_engine_api_data_array_1422 = function()
|
|
374
|
+
local util_decorator = source_shared_functional_decorator_17d0()
|
|
392
375
|
local function array_map(array, func)
|
|
393
376
|
local res = {}
|
|
394
377
|
local index = 1
|
|
@@ -549,8 +532,8 @@ install = install
|
|
|
549
532
|
return P
|
|
550
533
|
end
|
|
551
534
|
--
|
|
552
|
-
|
|
553
|
-
local util_decorator =
|
|
535
|
+
source_engine_api_draw_text_142d = function()
|
|
536
|
+
local util_decorator = source_shared_functional_decorator_17d0()
|
|
554
537
|
local function text_put(std, engine, font_previous, pos_x, pos_y, text, size)
|
|
555
538
|
size = size or 2
|
|
556
539
|
local hem = engine.current.data.width / 80
|
|
@@ -568,6 +551,8 @@ std.text.print(x - aligns_x[(align_x or 1) + 2], y - aligns_y[(align_y or 1) + 2
|
|
|
568
551
|
return w, h
|
|
569
552
|
end
|
|
570
553
|
local function install(std, engine, config)
|
|
554
|
+
std.text.font_previous = config.font_previous
|
|
555
|
+
std.text.is_tui = config.is_tui or function() return false end
|
|
571
556
|
std.text.print_ex = util_decorator.prefix2(std, engine, text_print_ex)
|
|
572
557
|
std.text.put = util_decorator.prefix3(std, engine, config.font_previous, text_put)
|
|
573
558
|
end
|
|
@@ -577,7 +562,7 @@ install=install
|
|
|
577
562
|
return P
|
|
578
563
|
end
|
|
579
564
|
--
|
|
580
|
-
|
|
565
|
+
source_engine_api_draw_poly_1438 = function()
|
|
581
566
|
local function decorator_poo(object, func)
|
|
582
567
|
if not object or not func then return func end
|
|
583
568
|
return function(a, b, c, d)
|
|
@@ -684,7 +669,7 @@ install=install
|
|
|
684
669
|
return P
|
|
685
670
|
end
|
|
686
671
|
--
|
|
687
|
-
|
|
672
|
+
source_engine_api_raw_memory_1443 = function()
|
|
688
673
|
local memory_dict_unload = {}
|
|
689
674
|
local memory_dict = {}
|
|
690
675
|
local memory_list = {}
|
|
@@ -739,7 +724,7 @@ install=install
|
|
|
739
724
|
return P
|
|
740
725
|
end
|
|
741
726
|
--
|
|
742
|
-
|
|
727
|
+
source_engine_api_system_color_1455 = function()
|
|
743
728
|
local function install(std)
|
|
744
729
|
std.color = std.color or {}
|
|
745
730
|
std.color.white = 0xFFFFFFFF
|
|
@@ -774,7 +759,7 @@ install = install
|
|
|
774
759
|
return P
|
|
775
760
|
end
|
|
776
761
|
--
|
|
777
|
-
|
|
762
|
+
source_shared_var_object_std_1460 = function()
|
|
778
763
|
local P = {
|
|
779
764
|
milis = 0,
|
|
780
765
|
delta = 0,
|
|
@@ -842,7 +827,7 @@ any=false
|
|
|
842
827
|
return P;
|
|
843
828
|
end
|
|
844
829
|
--
|
|
845
|
-
|
|
830
|
+
source_shared_string_eval_code_1472 = function()
|
|
846
831
|
local function script(src)
|
|
847
832
|
local loader = loadstring or load
|
|
848
833
|
if not loader then
|
|
@@ -863,7 +848,7 @@ script = script,
|
|
|
863
848
|
return P
|
|
864
849
|
end
|
|
865
850
|
--
|
|
866
|
-
|
|
851
|
+
source_shared_functional_decorator_17d0 = function()
|
|
867
852
|
local function decorator_prefix3(zig, zag, zom, func)
|
|
868
853
|
return function (a, b, c, d, e, f)
|
|
869
854
|
return func(zig, zag, zom, a, b, c, d, e, f)
|
|
@@ -921,4 +906,4 @@ prefix1_t = table_prefix1
|
|
|
921
906
|
return P
|
|
922
907
|
end
|
|
923
908
|
--
|
|
924
|
-
return
|
|
909
|
+
return main_13d0()
|