@gamely/gly-engine-micro 0.1.2 → 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 +77 -91
- package/package.json +9 -2
- package/README.md +0 -3
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)
|
|
@@ -94,7 +99,6 @@ std.draw.color=native_draw_color
|
|
|
94
99
|
std.draw.font=native_draw_font
|
|
95
100
|
std.draw.rect=native_draw_rect
|
|
96
101
|
std.draw.line=native_draw_line
|
|
97
|
-
std.draw.image=native_image_draw
|
|
98
102
|
std.image.load=native_image_load
|
|
99
103
|
std.image.draw=native_image_draw
|
|
100
104
|
std.text.print=native_text_print
|
|
@@ -106,18 +110,19 @@ std.draw.clear=function(tint)
|
|
|
106
110
|
native_draw_clear(tint, 0, 0, application.data.width, application.data.height)
|
|
107
111
|
end
|
|
108
112
|
engine.root=application
|
|
113
|
+
color.install(std, engine)
|
|
109
114
|
engine_raw_memory.install(std, engine)
|
|
110
115
|
engine_game.install(std, engine, cfg_system)
|
|
111
116
|
engine_key.install(std, engine, {})
|
|
112
|
-
engine_math.install(std, engine)
|
|
113
|
-
engine_math.wave.install(std, engine)
|
|
114
|
-
engine_math.clib.install(std, engine)
|
|
115
|
-
engine_math.clib_random.install(std, engine)
|
|
116
117
|
engine_array.install(std, engine, nil, 'array')
|
|
117
118
|
engine_api_draw_text.install(std, engine, cfg_text)
|
|
118
119
|
engine_api_draw_poly.install(std, engine, cfg_poly)
|
|
119
|
-
|
|
120
|
-
|
|
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
|
|
121
126
|
engine.current=application
|
|
122
127
|
application.callbacks.init(std, application.data)
|
|
123
128
|
end
|
|
@@ -131,12 +136,12 @@ version=version
|
|
|
131
136
|
}
|
|
132
137
|
return P
|
|
133
138
|
end
|
|
134
|
-
|
|
135
|
-
return '0.1.
|
|
139
|
+
source_version_13d9 = function()
|
|
140
|
+
return '0.1.4'
|
|
136
141
|
end
|
|
137
142
|
--
|
|
138
|
-
|
|
139
|
-
local util_decorator =
|
|
143
|
+
source_engine_api_system_app_13eb = function()
|
|
144
|
+
local util_decorator = source_shared_functional_decorator_17d0()
|
|
140
145
|
local function reset(std, engine)
|
|
141
146
|
if std.node then
|
|
142
147
|
std.bus.emit('exit')
|
|
@@ -176,7 +181,7 @@ install=install
|
|
|
176
181
|
return P
|
|
177
182
|
end
|
|
178
183
|
--
|
|
179
|
-
|
|
184
|
+
source_engine_api_system_key_13f6 = function()
|
|
180
185
|
local function real_key(std, engine, rkey, rvalue)
|
|
181
186
|
local value = rvalue == 1 or rvalue == true
|
|
182
187
|
local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
|
|
@@ -213,7 +218,7 @@ install = install
|
|
|
213
218
|
return P
|
|
214
219
|
end
|
|
215
220
|
--
|
|
216
|
-
|
|
221
|
+
source_engine_api_math_basic_1401 = function()
|
|
217
222
|
local function abs(value)
|
|
218
223
|
if value < 0 then
|
|
219
224
|
return -value
|
|
@@ -292,30 +297,6 @@ index = index + 1
|
|
|
292
297
|
end
|
|
293
298
|
return min_value
|
|
294
299
|
end
|
|
295
|
-
local function sine(t, freq)
|
|
296
|
-
return math.pi and math.sin(2 * math.pi * freq * t) or 1
|
|
297
|
-
end
|
|
298
|
-
local function ramp(t, freq, ratio)
|
|
299
|
-
t = (t / 2) % (1 / freq) * freq
|
|
300
|
-
if t < ratio then
|
|
301
|
-
return 2 * t / ratio - 1
|
|
302
|
-
else
|
|
303
|
-
return (2 * t - ratio - 1) / (ratio - 1)
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
local function saw(t, freq)
|
|
307
|
-
return ramp(t, freq, 1)
|
|
308
|
-
end
|
|
309
|
-
local function triangle(t, freq)
|
|
310
|
-
return ramp(t, freq, 1/2)
|
|
311
|
-
end
|
|
312
|
-
local function rect(t, freq, duty)
|
|
313
|
-
duty = 1 - duty * 2
|
|
314
|
-
return saw(t, freq) > duty and 1 or -1
|
|
315
|
-
end
|
|
316
|
-
local function square(t, freq)
|
|
317
|
-
return rect(t, freq, 1/2)
|
|
318
|
-
end
|
|
319
300
|
local function install(std)
|
|
320
301
|
std.math = std.math or {}
|
|
321
302
|
std.math.abs=abs
|
|
@@ -330,14 +311,15 @@ std.math.map=map
|
|
|
330
311
|
std.math.max=max
|
|
331
312
|
std.math.min=min
|
|
332
313
|
end
|
|
333
|
-
local
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
std.math.square=square
|
|
338
|
-
std.math.triangle=triangle
|
|
314
|
+
local P = {
|
|
315
|
+
install = install
|
|
316
|
+
}
|
|
317
|
+
return P
|
|
339
318
|
end
|
|
340
|
-
|
|
319
|
+
--
|
|
320
|
+
source_engine_api_math_clib_140c = function()
|
|
321
|
+
local function install(std)
|
|
322
|
+
assert(math and (1/2 ~= 0))
|
|
341
323
|
std.math = std.math or {}
|
|
342
324
|
std.math.acos=math.acos
|
|
343
325
|
std.math.asin=math.asin
|
|
@@ -365,31 +347,31 @@ std.math.sqrt=math.sqrt
|
|
|
365
347
|
std.math.tan=math.tan
|
|
366
348
|
std.math.tanh=math.tanh
|
|
367
349
|
end
|
|
368
|
-
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))
|
|
369
359
|
std.math = std.math or {}
|
|
370
360
|
std.math.random = function(a, b)
|
|
371
361
|
a = a and math.floor(a)
|
|
372
362
|
b = b and math.floor(b)
|
|
363
|
+
if a > b then a, b = b, a end
|
|
373
364
|
return math.random(a, b)
|
|
374
365
|
end
|
|
375
366
|
end
|
|
376
367
|
local P = {
|
|
377
|
-
install = install
|
|
378
|
-
wave = {
|
|
379
|
-
install = install_wave
|
|
380
|
-
},
|
|
381
|
-
clib = {
|
|
382
|
-
install = install_clib
|
|
383
|
-
},
|
|
384
|
-
clib_random = {
|
|
385
|
-
install = install_clib_random
|
|
386
|
-
}
|
|
368
|
+
install = install
|
|
387
369
|
}
|
|
388
|
-
return P
|
|
370
|
+
return P
|
|
389
371
|
end
|
|
390
372
|
--
|
|
391
|
-
|
|
392
|
-
local util_decorator =
|
|
373
|
+
source_engine_api_data_array_1422 = function()
|
|
374
|
+
local util_decorator = source_shared_functional_decorator_17d0()
|
|
393
375
|
local function array_map(array, func)
|
|
394
376
|
local res = {}
|
|
395
377
|
local index = 1
|
|
@@ -550,8 +532,8 @@ install = install
|
|
|
550
532
|
return P
|
|
551
533
|
end
|
|
552
534
|
--
|
|
553
|
-
|
|
554
|
-
local util_decorator =
|
|
535
|
+
source_engine_api_draw_text_142d = function()
|
|
536
|
+
local util_decorator = source_shared_functional_decorator_17d0()
|
|
555
537
|
local function text_put(std, engine, font_previous, pos_x, pos_y, text, size)
|
|
556
538
|
size = size or 2
|
|
557
539
|
local hem = engine.current.data.width / 80
|
|
@@ -569,6 +551,8 @@ std.text.print(x - aligns_x[(align_x or 1) + 2], y - aligns_y[(align_y or 1) + 2
|
|
|
569
551
|
return w, h
|
|
570
552
|
end
|
|
571
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
|
|
572
556
|
std.text.print_ex = util_decorator.prefix2(std, engine, text_print_ex)
|
|
573
557
|
std.text.put = util_decorator.prefix3(std, engine, config.font_previous, text_put)
|
|
574
558
|
end
|
|
@@ -578,7 +562,7 @@ install=install
|
|
|
578
562
|
return P
|
|
579
563
|
end
|
|
580
564
|
--
|
|
581
|
-
|
|
565
|
+
source_engine_api_draw_poly_1438 = function()
|
|
582
566
|
local function decorator_poo(object, func)
|
|
583
567
|
if not object or not func then return func end
|
|
584
568
|
return function(a, b, c, d)
|
|
@@ -685,7 +669,7 @@ install=install
|
|
|
685
669
|
return P
|
|
686
670
|
end
|
|
687
671
|
--
|
|
688
|
-
|
|
672
|
+
source_engine_api_raw_memory_1443 = function()
|
|
689
673
|
local memory_dict_unload = {}
|
|
690
674
|
local memory_dict = {}
|
|
691
675
|
local memory_list = {}
|
|
@@ -740,7 +724,7 @@ install=install
|
|
|
740
724
|
return P
|
|
741
725
|
end
|
|
742
726
|
--
|
|
743
|
-
|
|
727
|
+
source_engine_api_system_color_1455 = function()
|
|
744
728
|
local function install(std)
|
|
745
729
|
std.color = std.color or {}
|
|
746
730
|
std.color.white = 0xFFFFFFFF
|
|
@@ -775,12 +759,14 @@ install = install
|
|
|
775
759
|
return P
|
|
776
760
|
end
|
|
777
761
|
--
|
|
778
|
-
|
|
762
|
+
source_shared_var_object_std_1460 = function()
|
|
779
763
|
local P = {
|
|
780
764
|
milis = 0,
|
|
781
765
|
delta = 0,
|
|
782
766
|
math = {
|
|
783
767
|
},
|
|
768
|
+
media = {
|
|
769
|
+
},
|
|
784
770
|
draw = {
|
|
785
771
|
image = function() end,
|
|
786
772
|
clear = function () end,
|
|
@@ -841,7 +827,7 @@ any=false
|
|
|
841
827
|
return P;
|
|
842
828
|
end
|
|
843
829
|
--
|
|
844
|
-
|
|
830
|
+
source_shared_string_eval_code_1472 = function()
|
|
845
831
|
local function script(src)
|
|
846
832
|
local loader = loadstring or load
|
|
847
833
|
if not loader then
|
|
@@ -862,7 +848,7 @@ script = script,
|
|
|
862
848
|
return P
|
|
863
849
|
end
|
|
864
850
|
--
|
|
865
|
-
|
|
851
|
+
source_shared_functional_decorator_17d0 = function()
|
|
866
852
|
local function decorator_prefix3(zig, zag, zom, func)
|
|
867
853
|
return function (a, b, c, d, e, f)
|
|
868
854
|
return func(zig, zag, zom, a, b, c, d, e, f)
|
|
@@ -920,4 +906,4 @@ prefix1_t = table_prefix1
|
|
|
920
906
|
return P
|
|
921
907
|
end
|
|
922
908
|
--
|
|
923
|
-
return
|
|
909
|
+
return main_13d0()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamely/gly-engine-micro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"author": "RodrigoDornelles",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://docs.gamely.com.br",
|
|
@@ -15,5 +15,12 @@
|
|
|
15
15
|
"game engine",
|
|
16
16
|
"game",
|
|
17
17
|
"engine"
|
|
18
|
-
]
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"step1": "cd ../.. && rm -Rf dist && mkdir -p ./dist/types",
|
|
21
|
+
"step2": "cd ../.. && node cli.js build --core micro --bundler --outdir dist/dist",
|
|
22
|
+
"step3": "cd ../.. && node cli.js meta source/cli/main.lua --infile npm/gly-engine-micro/package.json --outfile dist/package.json",
|
|
23
|
+
"step4": "cd ../.. && echo \"declare module '@gamely/gly-engine-micro' {\n const content: string;\n export default content;\n}\" > dist/types/main.d.ts",
|
|
24
|
+
"build": "npm run step1 && npm run step2 && npm run step3 && npm run step4"
|
|
25
|
+
}
|
|
19
26
|
}
|
package/README.md
DELETED