-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibPhaser.fg
68 lines (63 loc) · 1.95 KB
/
libPhaser.fg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!syntax:lispish
.var initIsFinished
{deffunc setGameConfig (p_width p_height p_type)
.var readyGlobalGame
{ext (p_width p_height p_type) `
let globalGame
const behavior = {init:()=>{output(globalGame)}, preload:()=>{sugBip('initIsFinished')}, update:(phaserGame)=>{
phaserGame.updateList ||= []
for (const fun of phaserGame.updateList) {
fun(phaserGame, globalGame, fun.thisObject, fun.sugBreak)
}
},}
const phaserGame = new Phaser.Game(p_width, p_height, p_type, null, behavior)
globalGame = {phaserGame: phaserGame, behavior:behavior}
phaserGame.globalGame = globalGame
` readyGlobalGame}
:await readyGlobalGame beep
$readyGlobalGame
}
{deffunc awaitReadyForCreate (p_globalGame)
.var ready
:await initIsFinished beep
{ext (p_globalGame) `
p_globalGame.phaserGame.load.onLoadComplete.addOnce(()=>{
output(1)
})
p_globalGame.phaserGame.load.start()
` ready}
:await ready beep
}
{deffunc whileTrueAwaitUpdate_js (p_globalGame p_thisObject p_stringJsToExecute)
{ext (p_globalGame p_thisObject p_stringJsToExecute) `
const fun = new Function(
'"use strict"\n'
+ 'const phaserGame=arguments[0]\n'
+ 'const globalGame=arguments[1]\n'
+ 'const thisObject=arguments[2]\n'
+ 'const sugBreak=arguments[3]\n'
+ p_stringJsToExecute
)
fun.thisObject = p_thisObject
fun.sugBreak = sugBreak
p_globalGame.phaserGame.updateList ||= []
p_globalGame.phaserGame.updateList.push(fun)
SAVES.push({updateList: p_globalGame.phaserGame.updateList, fun: fun})
` dummy `
const l_index = SAVE.updateList.indexOf(SAVE.fun)
SAVE.updateList.splice(l_index, 1)
`}
!awaitForever
}
{deffunc whileTrueAwaitPhaser_translate (p_elt p_evtPhaser p_evtSug)
{ext (p_elt p_evtPhaser p_evtSug) `
const l_react = function(key) {
goAssign(p_evtSug, key)
}
p_elt.events[p_evtPhaser].add(l_react)
SAVES.push({elt:p_elt, react:l_react, evtPhaser:p_evtPhaser})
` dummy `
SAVE.elt.events[SAVE.evtPhaser].remove(SAVE.react)
`}
!awaitForever
}