sci2-ts 0.0.0-stage → 0.2.2
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/CHANGELOG.md +78 -0
- package/LICENSE +21 -0
- package/README.md +113 -2
- package/apps/viewer/editor.html +43 -0
- package/apps/viewer/explore.html +27 -0
- package/apps/viewer/index.html +26 -0
- package/apps/viewer/package.json +27 -0
- package/apps/viewer/play.html +26 -0
- package/apps/viewer/plugin.d.ts +18 -0
- package/apps/viewer/plugin.js +75 -0
- package/apps/viewer/plugin.ts +84 -0
- package/apps/viewer/src/adlib.d.ts +20 -0
- package/apps/viewer/src/adlib.js +55 -0
- package/apps/viewer/src/adlib.ts +62 -0
- package/apps/viewer/src/app.d.ts +5 -0
- package/apps/viewer/src/app.js +5 -0
- package/apps/viewer/src/app.ts +5 -0
- package/apps/viewer/src/asset-index.d.ts +22 -0
- package/apps/viewer/src/asset-index.js +74 -0
- package/apps/viewer/src/asset-index.ts +90 -0
- package/apps/viewer/src/audio.d.ts +28 -0
- package/apps/viewer/src/audio.js +102 -0
- package/apps/viewer/src/audio.ts +110 -0
- package/apps/viewer/src/editor-handles.d.ts +63 -0
- package/apps/viewer/src/editor-handles.js +332 -0
- package/apps/viewer/src/editor-handles.ts +368 -0
- package/apps/viewer/src/editor-languages.d.ts +23 -0
- package/apps/viewer/src/editor-languages.js +157 -0
- package/apps/viewer/src/editor-languages.ts +135 -0
- package/apps/viewer/src/editor.css +213 -0
- package/apps/viewer/src/editor.d.ts +1 -0
- package/apps/viewer/src/editor.js +393 -0
- package/apps/viewer/src/editor.ts +412 -0
- package/apps/viewer/src/explore/classes.d.ts +7 -0
- package/apps/viewer/src/explore/classes.js +63 -0
- package/apps/viewer/src/explore/classes.ts +61 -0
- package/apps/viewer/src/explore/context.d.ts +33 -0
- package/apps/viewer/src/explore/context.js +96 -0
- package/apps/viewer/src/explore/context.ts +124 -0
- package/apps/viewer/src/explore/explore.css +93 -0
- package/apps/viewer/src/explore/explore.d.ts +1 -0
- package/apps/viewer/src/explore/explore.js +102 -0
- package/apps/viewer/src/explore/explore.ts +104 -0
- package/apps/viewer/src/explore/inspect.d.ts +5 -0
- package/apps/viewer/src/explore/inspect.js +208 -0
- package/apps/viewer/src/explore/inspect.ts +279 -0
- package/apps/viewer/src/explore/live.d.ts +22 -0
- package/apps/viewer/src/explore/live.js +318 -0
- package/apps/viewer/src/explore/live.ts +365 -0
- package/apps/viewer/src/explore/map.d.ts +11 -0
- package/apps/viewer/src/explore/map.js +182 -0
- package/apps/viewer/src/explore/map.ts +193 -0
- package/apps/viewer/src/files.d.ts +21 -0
- package/apps/viewer/src/files.js +69 -0
- package/apps/viewer/src/files.ts +72 -0
- package/apps/viewer/src/game-profile.d.ts +19 -0
- package/apps/viewer/src/game-profile.js +4 -0
- package/apps/viewer/src/game-profile.ts +26 -0
- package/apps/viewer/src/main.d.ts +1 -0
- package/apps/viewer/src/main.js +473 -0
- package/apps/viewer/src/main.ts +527 -0
- package/apps/viewer/src/music.d.ts +14 -0
- package/apps/viewer/src/music.js +32 -0
- package/apps/viewer/src/music.ts +34 -0
- package/apps/viewer/src/opl-worklet.d.ts +1 -0
- package/apps/viewer/src/opl-worklet.js +47 -0
- package/apps/viewer/src/opl-worklet.ts +55 -0
- package/apps/viewer/src/overlay.d.ts +31 -0
- package/apps/viewer/src/overlay.js +103 -0
- package/apps/viewer/src/overlay.ts +123 -0
- package/apps/viewer/src/play.css +14 -0
- package/apps/viewer/src/play.d.ts +1 -0
- package/apps/viewer/src/play.js +179 -0
- package/apps/viewer/src/play.ts +177 -0
- package/apps/viewer/src/saves.d.ts +10 -0
- package/apps/viewer/src/saves.js +50 -0
- package/apps/viewer/src/saves.ts +51 -0
- package/apps/viewer/src/session.d.ts +91 -0
- package/apps/viewer/src/session.js +301 -0
- package/apps/viewer/src/session.ts +321 -0
- package/apps/viewer/src/sound-preview.d.ts +7 -0
- package/apps/viewer/src/sound-preview.js +214 -0
- package/apps/viewer/src/sound-preview.ts +228 -0
- package/apps/viewer/src/style.css +64 -0
- package/apps/viewer/vite.config.ts +25 -0
- package/bin/sci-ts.mjs +9 -0
- package/lib/994.sc +49 -0
- package/lib/995.sc +53 -0
- package/lib/996.sc +299 -0
- package/lib/997.sc +198 -0
- package/lib/998.sc +338 -0
- package/lib/999.sc +189 -0
- package/lib/resources.d.ts +2 -0
- package/lib/resources.js +84 -0
- package/lib/resources.ts +88 -0
- package/lib/system.sh +62 -0
- package/package.json +75 -4
- package/packages/content/room.schema.json +267 -0
- package/packages/content/src/index.d.ts +3 -0
- package/packages/content/src/index.js +3 -0
- package/packages/content/src/index.ts +3 -0
- package/packages/content/src/room.d.ts +111 -0
- package/packages/content/src/room.js +886 -0
- package/packages/content/src/room.ts +1011 -0
- package/packages/content/src/target.d.ts +80 -0
- package/packages/content/src/target.js +1 -0
- package/packages/content/src/target.ts +60 -0
- package/packages/content/src/yarn.d.ts +90 -0
- package/packages/content/src/yarn.js +214 -0
- package/packages/content/src/yarn.ts +261 -0
- package/packages/sci/src/analysis/game.d.ts +90 -0
- package/packages/sci/src/analysis/game.js +221 -0
- package/packages/sci/src/analysis/game.ts +305 -0
- package/packages/sci/src/analysis/runtime.d.ts +58 -0
- package/packages/sci/src/analysis/runtime.js +133 -0
- package/packages/sci/src/analysis/runtime.ts +163 -0
- package/packages/sci/src/audio/adlib.d.ts +73 -0
- package/packages/sci/src/audio/adlib.js +280 -0
- package/packages/sci/src/audio/adlib.ts +329 -0
- package/packages/sci/src/audio/index.d.ts +43 -0
- package/packages/sci/src/audio/index.js +99 -0
- package/packages/sci/src/audio/index.ts +122 -0
- package/packages/sci/src/audio/midi.d.ts +92 -0
- package/packages/sci/src/audio/midi.js +242 -0
- package/packages/sci/src/audio/midi.ts +262 -0
- package/packages/sci/src/audio/opl2.d.ts +74 -0
- package/packages/sci/src/audio/opl2.js +283 -0
- package/packages/sci/src/audio/opl2.ts +283 -0
- package/packages/sci/src/audio/sol.d.ts +32 -0
- package/packages/sci/src/audio/sol.js +81 -0
- package/packages/sci/src/audio/sol.ts +100 -0
- package/packages/sci/src/audio/write.d.ts +35 -0
- package/packages/sci/src/audio/write.js +91 -0
- package/packages/sci/src/audio/write.ts +108 -0
- package/packages/sci/src/gfx/cel.d.ts +36 -0
- package/packages/sci/src/gfx/cel.js +82 -0
- package/packages/sci/src/gfx/cel.ts +110 -0
- package/packages/sci/src/gfx/palette.d.ts +24 -0
- package/packages/sci/src/gfx/palette.js +49 -0
- package/packages/sci/src/gfx/palette.ts +56 -0
- package/packages/sci/src/gfx/pic-file.d.ts +46 -0
- package/packages/sci/src/gfx/pic-file.js +114 -0
- package/packages/sci/src/gfx/pic-file.ts +155 -0
- package/packages/sci/src/gfx/pic.d.ts +27 -0
- package/packages/sci/src/gfx/pic.js +34 -0
- package/packages/sci/src/gfx/pic.ts +53 -0
- package/packages/sci/src/gfx/quantize.d.ts +42 -0
- package/packages/sci/src/gfx/quantize.js +199 -0
- package/packages/sci/src/gfx/quantize.ts +218 -0
- package/packages/sci/src/gfx/view-file.d.ts +62 -0
- package/packages/sci/src/gfx/view-file.js +182 -0
- package/packages/sci/src/gfx/view-file.ts +233 -0
- package/packages/sci/src/gfx/view.d.ts +28 -0
- package/packages/sci/src/gfx/view.js +45 -0
- package/packages/sci/src/gfx/view.ts +62 -0
- package/packages/sci/src/index.d.ts +38 -0
- package/packages/sci/src/index.js +38 -0
- package/packages/sci/src/index.ts +38 -0
- package/packages/sci/src/motion/pathfinding.d.ts +40 -0
- package/packages/sci/src/motion/pathfinding.js +140 -0
- package/packages/sci/src/motion/pathfinding.ts +147 -0
- package/packages/sci/src/resource/archive.d.ts +16 -0
- package/packages/sci/src/resource/archive.js +51 -0
- package/packages/sci/src/resource/archive.ts +56 -0
- package/packages/sci/src/resource/lzs.d.ts +12 -0
- package/packages/sci/src/resource/lzs.js +64 -0
- package/packages/sci/src/resource/lzs.ts +66 -0
- package/packages/sci/src/resource/manager.d.ts +45 -0
- package/packages/sci/src/resource/manager.js +158 -0
- package/packages/sci/src/resource/manager.ts +184 -0
- package/packages/sci/src/resource/map.d.ts +18 -0
- package/packages/sci/src/resource/map.js +34 -0
- package/packages/sci/src/resource/map.ts +44 -0
- package/packages/sci/src/resource/types.d.ts +37 -0
- package/packages/sci/src/resource/types.js +45 -0
- package/packages/sci/src/resource/types.ts +57 -0
- package/packages/sci/src/script/assembly.d.ts +67 -0
- package/packages/sci/src/script/assembly.js +748 -0
- package/packages/sci/src/script/assembly.ts +714 -0
- package/packages/sci/src/script/compiler.d.ts +75 -0
- package/packages/sci/src/script/compiler.js +993 -0
- package/packages/sci/src/script/compiler.ts +1040 -0
- package/packages/sci/src/script/disasm.d.ts +81 -0
- package/packages/sci/src/script/disasm.js +318 -0
- package/packages/sci/src/script/disasm.ts +323 -0
- package/packages/sci/src/script/kernel-names.d.ts +6 -0
- package/packages/sci/src/script/kernel-names.js +165 -0
- package/packages/sci/src/script/kernel-names.ts +165 -0
- package/packages/sci/src/script/opcodes.d.ts +22 -0
- package/packages/sci/src/script/opcodes.js +45 -0
- package/packages/sci/src/script/opcodes.ts +72 -0
- package/packages/sci/src/script/script.d.ts +56 -0
- package/packages/sci/src/script/script.js +63 -0
- package/packages/sci/src/script/script.ts +111 -0
- package/packages/sci/src/script/sexpr.d.ts +45 -0
- package/packages/sci/src/script/sexpr.js +151 -0
- package/packages/sci/src/script/sexpr.ts +139 -0
- package/packages/sci/src/script/vocab.d.ts +15 -0
- package/packages/sci/src/script/vocab.js +44 -0
- package/packages/sci/src/script/vocab.ts +48 -0
- package/packages/sci/src/script/world.d.ts +25 -0
- package/packages/sci/src/script/world.js +65 -0
- package/packages/sci/src/script/world.ts +70 -0
- package/packages/sci/src/text/font.d.ts +37 -0
- package/packages/sci/src/text/font.js +103 -0
- package/packages/sci/src/text/font.ts +125 -0
- package/packages/sci/src/text/message.d.ts +69 -0
- package/packages/sci/src/text/message.js +171 -0
- package/packages/sci/src/text/message.ts +205 -0
- package/packages/sci/src/vm/kernels/arrays.d.ts +19 -0
- package/packages/sci/src/vm/kernels/arrays.js +182 -0
- package/packages/sci/src/vm/kernels/arrays.ts +164 -0
- package/packages/sci/src/vm/kernels/audio.d.ts +70 -0
- package/packages/sci/src/vm/kernels/audio.js +347 -0
- package/packages/sci/src/vm/kernels/audio.ts +349 -0
- package/packages/sci/src/vm/kernels/core.d.ts +5 -0
- package/packages/sci/src/vm/kernels/core.js +87 -0
- package/packages/sci/src/vm/kernels/core.ts +91 -0
- package/packages/sci/src/vm/kernels/graphics.d.ts +141 -0
- package/packages/sci/src/vm/kernels/graphics.js +467 -0
- package/packages/sci/src/vm/kernels/graphics.ts +502 -0
- package/packages/sci/src/vm/kernels/index.d.ts +8 -0
- package/packages/sci/src/vm/kernels/index.js +29 -0
- package/packages/sci/src/vm/kernels/index.ts +32 -0
- package/packages/sci/src/vm/kernels/lists.d.ts +6 -0
- package/packages/sci/src/vm/kernels/lists.js +127 -0
- package/packages/sci/src/vm/kernels/lists.ts +111 -0
- package/packages/sci/src/vm/kernels/motion.d.ts +7 -0
- package/packages/sci/src/vm/kernels/motion.js +204 -0
- package/packages/sci/src/vm/kernels/motion.ts +194 -0
- package/packages/sci/src/vm/kernels/palette.d.ts +82 -0
- package/packages/sci/src/vm/kernels/palette.js +292 -0
- package/packages/sci/src/vm/kernels/palette.ts +303 -0
- package/packages/sci/src/vm/kernels/saves.d.ts +45 -0
- package/packages/sci/src/vm/kernels/saves.js +123 -0
- package/packages/sci/src/vm/kernels/saves.ts +149 -0
- package/packages/sci/src/vm/kernels/system.d.ts +62 -0
- package/packages/sci/src/vm/kernels/system.js +110 -0
- package/packages/sci/src/vm/kernels/system.ts +128 -0
- package/packages/sci/src/vm/kernels/text.d.ts +13 -0
- package/packages/sci/src/vm/kernels/text.js +338 -0
- package/packages/sci/src/vm/kernels/text.ts +328 -0
- package/packages/sci/src/vm/memory.d.ts +138 -0
- package/packages/sci/src/vm/memory.js +168 -0
- package/packages/sci/src/vm/memory.ts +266 -0
- package/packages/sci/src/vm/replace.d.ts +11 -0
- package/packages/sci/src/vm/replace.js +14 -0
- package/packages/sci/src/vm/replace.ts +16 -0
- package/packages/sci/src/vm/savegame.d.ts +89 -0
- package/packages/sci/src/vm/savegame.js +161 -0
- package/packages/sci/src/vm/savegame.ts +188 -0
- package/packages/sci/src/vm/value.d.ts +17 -0
- package/packages/sci/src/vm/value.js +12 -0
- package/packages/sci/src/vm/value.ts +25 -0
- package/packages/sci/src/vm/vm.d.ts +155 -0
- package/packages/sci/src/vm/vm.js +1053 -0
- package/packages/sci/src/vm/vm.ts +914 -0
- package/tools/adlib-render.d.ts +1 -0
- package/tools/adlib-render.js +49 -0
- package/tools/adlib-render.ts +42 -0
- package/tools/analyze.d.ts +1 -0
- package/tools/analyze.js +25 -0
- package/tools/analyze.ts +25 -0
- package/tools/art/build.d.ts +34 -0
- package/tools/art/build.js +175 -0
- package/tools/art/build.ts +153 -0
- package/tools/art.d.ts +1 -0
- package/tools/art.js +31 -0
- package/tools/art.ts +29 -0
- package/tools/asm.d.ts +1 -0
- package/tools/asm.js +61 -0
- package/tools/asm.ts +55 -0
- package/tools/cli.d.ts +1 -0
- package/tools/cli.js +99 -0
- package/tools/cli.ts +100 -0
- package/tools/editor-server.d.ts +29 -0
- package/tools/editor-server.js +162 -0
- package/tools/editor-server.ts +176 -0
- package/tools/explore.d.ts +1 -0
- package/tools/explore.js +305 -0
- package/tools/explore.ts +250 -0
- package/tools/game/audio.d.ts +19 -0
- package/tools/game/audio.js +143 -0
- package/tools/game/audio.ts +130 -0
- package/tools/game/build.d.ts +46 -0
- package/tools/game/build.js +259 -0
- package/tools/game/build.ts +283 -0
- package/tools/game/defaults.d.ts +26 -0
- package/tools/game/defaults.js +82 -0
- package/tools/game/defaults.ts +83 -0
- package/tools/game/font.d.ts +3 -0
- package/tools/game/font.js +124 -0
- package/tools/game/font.ts +126 -0
- package/tools/game/kit.d.ts +7 -0
- package/tools/game/kit.js +7 -0
- package/tools/game/kit.ts +10 -0
- package/tools/game/new.d.ts +8 -0
- package/tools/game/new.js +39 -0
- package/tools/game/new.ts +38 -0
- package/tools/game/target.d.ts +7 -0
- package/tools/game/target.js +41 -0
- package/tools/game/target.ts +42 -0
- package/tools/game/template/resources.ts.tmpl +43 -0
- package/tools/game/template/rooms/1.room.yaml +9 -0
- package/tools/game/template/rooms/1.yarn +17 -0
- package/tools/game/template/scripts/0.sc +24 -0
- package/tools/game.d.ts +1 -0
- package/tools/game.js +77 -0
- package/tools/game.ts +70 -0
- package/tools/mod-build.d.ts +28 -0
- package/tools/mod-build.js +173 -0
- package/tools/mod-build.ts +179 -0
- package/tools/mod-target.d.ts +16 -0
- package/tools/mod-target.js +26 -0
- package/tools/mod-target.ts +32 -0
- package/tools/mod.d.ts +1 -0
- package/tools/mod.js +47 -0
- package/tools/mod.ts +45 -0
- package/tools/msg.d.ts +1 -0
- package/tools/msg.js +40 -0
- package/tools/msg.ts +36 -0
- package/tools/node-files.d.ts +3 -0
- package/tools/node-files.js +34 -0
- package/tools/node-files.ts +33 -0
- package/tools/patches.d.ts +3 -0
- package/tools/patches.js +13 -0
- package/tools/patches.ts +13 -0
- package/tools/pic-build.d.ts +9 -0
- package/tools/pic-build.js +26 -0
- package/tools/pic-build.ts +27 -0
- package/tools/pic.d.ts +1 -0
- package/tools/pic.js +64 -0
- package/tools/pic.ts +61 -0
- package/tools/play.d.ts +1 -0
- package/tools/play.js +54 -0
- package/tools/play.ts +54 -0
- package/tools/png.d.ts +16 -0
- package/tools/png.js +124 -0
- package/tools/png.ts +123 -0
- package/tools/res.d.ts +1 -0
- package/tools/res.js +48 -0
- package/tools/res.ts +50 -0
- package/tools/scenario.d.ts +1 -0
- package/tools/scenario.js +74 -0
- package/tools/scenario.ts +80 -0
- package/tools/site/build.d.ts +8 -0
- package/tools/site/build.js +110 -0
- package/tools/site/build.ts +116 -0
- package/tools/site/markdown.d.ts +11 -0
- package/tools/site/markdown.js +88 -0
- package/tools/site/markdown.ts +84 -0
- package/tools/view-build.d.ts +34 -0
- package/tools/view-build.js +47 -0
- package/tools/view-build.ts +71 -0
- package/tools/view.d.ts +1 -0
- package/tools/view.js +54 -0
- package/tools/view.ts +52 -0
package/lib/998.sc
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
;;; The world: the game and its main loop, rooms, and the things in them.
|
|
2
|
+
(script 998)
|
|
3
|
+
(include "system.sh")
|
|
4
|
+
|
|
5
|
+
;; A layer of the screen: a room's picture and what's on it, or text over the room.
|
|
6
|
+
(class Plane of Obj
|
|
7
|
+
(properties
|
|
8
|
+
priority 0
|
|
9
|
+
inLeft 0 inTop 0 inRight 319 inBottom 199
|
|
10
|
+
picture -1 ; -1: filled with `back`; -2: transparent
|
|
11
|
+
back 0)
|
|
12
|
+
|
|
13
|
+
(method (init)
|
|
14
|
+
(AddPlane self))
|
|
15
|
+
|
|
16
|
+
(method (dispose)
|
|
17
|
+
(DeletePlane self)
|
|
18
|
+
(super dispose:)))
|
|
19
|
+
|
|
20
|
+
;; The game: sets everything up, then runs one cycle after another until `quit`.
|
|
21
|
+
(class Game of Obj
|
|
22
|
+
(properties
|
|
23
|
+
script 0)
|
|
24
|
+
|
|
25
|
+
(method (init)
|
|
26
|
+
(= game self)
|
|
27
|
+
(= cast (Set new:))
|
|
28
|
+
(= features (Set new:))
|
|
29
|
+
(= sounds (Set new:))
|
|
30
|
+
(= theEvent (Event new:))
|
|
31
|
+
(= messager (Messager new:))
|
|
32
|
+
(= narrator (Narrator new:))
|
|
33
|
+
(= music (Sound new:))
|
|
34
|
+
(= sfx (Sound new:))
|
|
35
|
+
(= uiPlane ((Plane new:) priority: 200 picture: -2 yourself:))
|
|
36
|
+
(uiPlane init:)
|
|
37
|
+
(= user (User new:))
|
|
38
|
+
(user init:))
|
|
39
|
+
|
|
40
|
+
(method (play)
|
|
41
|
+
(self init:)
|
|
42
|
+
(while (not quit)
|
|
43
|
+
(self doit:)))
|
|
44
|
+
|
|
45
|
+
;; One cycle: scripts, the room, everything on screen, text, drawing, then input.
|
|
46
|
+
(method (doit)
|
|
47
|
+
(++ gameTime)
|
|
48
|
+
(if script (script doit:))
|
|
49
|
+
(sounds eachElementDo: #check)
|
|
50
|
+
(if curRoom (curRoom doit:))
|
|
51
|
+
(cast eachElementDo: #doit)
|
|
52
|
+
(if talking (talking doit:))
|
|
53
|
+
(FrameOut)
|
|
54
|
+
(user doit:)
|
|
55
|
+
(if newRoomNum (self newRoom: newRoomNum)))
|
|
56
|
+
|
|
57
|
+
;; Leaves the current room for room n (its script's export 0).
|
|
58
|
+
(method (newRoom n &tmp old)
|
|
59
|
+
(= newRoomNum 0)
|
|
60
|
+
(if talking (talking clear:))
|
|
61
|
+
(if dialog (dialog dispose:))
|
|
62
|
+
(if curRoom
|
|
63
|
+
(= old curRoomNum)
|
|
64
|
+
(curRoom dispose:)
|
|
65
|
+
(= curRoom 0)
|
|
66
|
+
(DisposeScript old))
|
|
67
|
+
(= prevRoomNum curRoomNum)
|
|
68
|
+
(= curRoomNum n)
|
|
69
|
+
(= curRoom (ScriptID n 0))
|
|
70
|
+
(curRoom setUp:)
|
|
71
|
+
(curRoom init:))
|
|
72
|
+
|
|
73
|
+
(method (setScript s)
|
|
74
|
+
(if script (script dispose:))
|
|
75
|
+
(= script s)
|
|
76
|
+
(if s (s init: self &rest)))
|
|
77
|
+
|
|
78
|
+
;; Clicks do nothing (but dismiss text) until handsOn: for cutscenes.
|
|
79
|
+
(method (handsOff)
|
|
80
|
+
(user canInput: FALSE))
|
|
81
|
+
|
|
82
|
+
(method (handsOn)
|
|
83
|
+
(user canInput: TRUE)))
|
|
84
|
+
|
|
85
|
+
;; A room: its picture, where you can walk, its exits, and what's said about it.
|
|
86
|
+
(class Room of Obj
|
|
87
|
+
(properties
|
|
88
|
+
picture -1
|
|
89
|
+
plane 0
|
|
90
|
+
obstacles 0 ; Polygons limiting where actors walk
|
|
91
|
+
script 0
|
|
92
|
+
noun 0
|
|
93
|
+
modNum -1 ; its message file (the room's number unless set)
|
|
94
|
+
north 0 south 0 east 0 west 0
|
|
95
|
+
edgeN 40 edgeS 189 edgeE 319 edgeW 0)
|
|
96
|
+
|
|
97
|
+
;; Before init (the game calls it): the room's plane and its list of obstacles, so init
|
|
98
|
+
;; can add things in any order.
|
|
99
|
+
(method (setUp)
|
|
100
|
+
(if (== modNum -1) (= modNum curRoomNum))
|
|
101
|
+
(= plane ((Plane new:) picture: picture priority: 1 yourself:))
|
|
102
|
+
(plane init:)
|
|
103
|
+
(= obstacles (List new:)))
|
|
104
|
+
|
|
105
|
+
;; What's in the room: rooms add their features, props and obstacles here.
|
|
106
|
+
(method (init))
|
|
107
|
+
|
|
108
|
+
;; Leaves through an edge when the hero reaches it, if there's a room that way.
|
|
109
|
+
(method (doit &tmp n)
|
|
110
|
+
(if script (script doit:))
|
|
111
|
+
(if (and ego (not newRoomNum) (== (ego plane?) plane))
|
|
112
|
+
(= n
|
|
113
|
+
(cond
|
|
114
|
+
((<= (ego y?) edgeN) north)
|
|
115
|
+
((>= (ego y?) edgeS) south)
|
|
116
|
+
((>= (ego x?) edgeE) east)
|
|
117
|
+
((<= (ego x?) edgeW) west)
|
|
118
|
+
(else 0)))
|
|
119
|
+
(if n (self newRoom: n))))
|
|
120
|
+
|
|
121
|
+
(method (newRoom n)
|
|
122
|
+
(= newRoomNum n))
|
|
123
|
+
|
|
124
|
+
(method (setScript s)
|
|
125
|
+
(if script (script dispose:))
|
|
126
|
+
(= script s)
|
|
127
|
+
(if s (s init: self &rest)))
|
|
128
|
+
|
|
129
|
+
(method (addObstacle)
|
|
130
|
+
(obstacles add: &rest))
|
|
131
|
+
|
|
132
|
+
(method (doVerb verb)
|
|
133
|
+
(messager say: noun verb 0 0 0 modNum))
|
|
134
|
+
|
|
135
|
+
(method (dispose)
|
|
136
|
+
(if script (script dispose:))
|
|
137
|
+
;; Everything in the room goes, except the hero, who walks into the next one.
|
|
138
|
+
(cast eachElementDo: #roomDisposed)
|
|
139
|
+
(features eachElementDo: #dispose)
|
|
140
|
+
(obstacles eachElementDo: #dispose)
|
|
141
|
+
(obstacles dispose:)
|
|
142
|
+
(= obstacles 0)
|
|
143
|
+
(plane dispose:)
|
|
144
|
+
(= plane 0)))
|
|
145
|
+
|
|
146
|
+
;; Something in the room that answers clicks: a rectangle of the picture and a noun in the
|
|
147
|
+
;; room's message file.
|
|
148
|
+
(class Feature of Obj
|
|
149
|
+
(properties
|
|
150
|
+
x 0 y 0
|
|
151
|
+
noun 0
|
|
152
|
+
modNum -1
|
|
153
|
+
nsLeft 0 nsTop 0 nsRight 0 nsBottom 0
|
|
154
|
+
sightAngle 180
|
|
155
|
+
approachX 0 approachY 0
|
|
156
|
+
actions 0) ; an object whose handleVerb: gets the first say (a Teller)
|
|
157
|
+
|
|
158
|
+
(method (init)
|
|
159
|
+
(if (== modNum -1) (= modNum curRoomNum))
|
|
160
|
+
(features add: self))
|
|
161
|
+
|
|
162
|
+
(method (dispose)
|
|
163
|
+
(features delete: self)
|
|
164
|
+
(super dispose:))
|
|
165
|
+
|
|
166
|
+
(method (onMe theX theY)
|
|
167
|
+
(return (and (>= theX nsLeft) (<= theX nsRight) (>= theY nsTop) (<= theY nsBottom))))
|
|
168
|
+
|
|
169
|
+
;; Says the line for this noun and verb; with none, the room answers.
|
|
170
|
+
(method (doVerb verb)
|
|
171
|
+
(if (and actions (actions handleVerb: verb)) (return))
|
|
172
|
+
(if (not (and noun (messager say: noun verb 0 0 0 modNum)))
|
|
173
|
+
(curRoom doVerb: verb))))
|
|
174
|
+
|
|
175
|
+
;; A Feature drawn with a view: a screen item in the room's plane.
|
|
176
|
+
(class View of Feature
|
|
177
|
+
(properties
|
|
178
|
+
view -1 loop 0 cel 0
|
|
179
|
+
z 0
|
|
180
|
+
priority 0 fixPriority 0
|
|
181
|
+
plane 0
|
|
182
|
+
bitmap 0
|
|
183
|
+
signal 0
|
|
184
|
+
scaleSignal 0 scaleX 128 scaleY 128
|
|
185
|
+
brLeft 0 brTop 0 brRight 0 brBottom 0
|
|
186
|
+
xStep 3 yStep 2)
|
|
187
|
+
|
|
188
|
+
(method (init)
|
|
189
|
+
(if (== modNum -1) (= modNum curRoomNum))
|
|
190
|
+
(= plane (curRoom plane?))
|
|
191
|
+
(cast add: self)
|
|
192
|
+
(AddScreenItem self))
|
|
193
|
+
|
|
194
|
+
(method (doit)
|
|
195
|
+
(if (not (& signal SIG_HIDDEN)) (UpdateScreenItem self)))
|
|
196
|
+
|
|
197
|
+
(method (onMe theX theY)
|
|
198
|
+
(return (and (not (& signal SIG_HIDDEN)) (IsOnMe theX theY self))))
|
|
199
|
+
|
|
200
|
+
(method (hide)
|
|
201
|
+
(|= signal SIG_HIDDEN)
|
|
202
|
+
(DeleteScreenItem self))
|
|
203
|
+
|
|
204
|
+
(method (show)
|
|
205
|
+
(if (& signal SIG_HIDDEN)
|
|
206
|
+
(&= signal (~ SIG_HIDDEN))
|
|
207
|
+
(AddScreenItem self)))
|
|
208
|
+
|
|
209
|
+
;; A loop that stays when the actor turns; -1 lets it follow the heading again.
|
|
210
|
+
(method (setLoop l)
|
|
211
|
+
(if (== l -1)
|
|
212
|
+
(&= signal (~ SIG_FIXED_LOOP))
|
|
213
|
+
else
|
|
214
|
+
(= loop l)
|
|
215
|
+
(|= signal SIG_FIXED_LOOP))
|
|
216
|
+
(return self))
|
|
217
|
+
|
|
218
|
+
(method (setCel c)
|
|
219
|
+
(= cel c)
|
|
220
|
+
(return self))
|
|
221
|
+
|
|
222
|
+
;; A fixed priority (drawn above things with lower ones); -1: by y again.
|
|
223
|
+
(method (setPri p)
|
|
224
|
+
(if (== p -1)
|
|
225
|
+
(= fixPriority 0)
|
|
226
|
+
else
|
|
227
|
+
(= priority p)
|
|
228
|
+
(= fixPriority 1))
|
|
229
|
+
(return self))
|
|
230
|
+
|
|
231
|
+
(method (posn newX newY)
|
|
232
|
+
(= x newX)
|
|
233
|
+
(= y newY)
|
|
234
|
+
(return self))
|
|
235
|
+
|
|
236
|
+
;; The room is going: so is this.
|
|
237
|
+
(method (roomDisposed)
|
|
238
|
+
(self dispose:))
|
|
239
|
+
|
|
240
|
+
(method (dispose)
|
|
241
|
+
(if (not (& signal SIG_HIDDEN)) (DeleteScreenItem self))
|
|
242
|
+
(cast delete: self)
|
|
243
|
+
(DisposeClone self)))
|
|
244
|
+
|
|
245
|
+
;; A View that animates (a cycler) and can run a script.
|
|
246
|
+
(class Prop of View
|
|
247
|
+
(properties
|
|
248
|
+
cycler 0
|
|
249
|
+
cycleSpeed 6 ; cycles between cels
|
|
250
|
+
script 0)
|
|
251
|
+
|
|
252
|
+
(method (doit)
|
|
253
|
+
(if script (script doit:))
|
|
254
|
+
(if cycler (cycler doit:))
|
|
255
|
+
(super doit:))
|
|
256
|
+
|
|
257
|
+
;; cls is a Cycle class (a new one is made) or object; 0 stops cycling.
|
|
258
|
+
(method (setCycle cls)
|
|
259
|
+
(if cycler (cycler dispose:))
|
|
260
|
+
(= cycler 0)
|
|
261
|
+
(if cls
|
|
262
|
+
(= cycler (if (& (cls -info-?) $8000) (cls new:) else cls))
|
|
263
|
+
(cycler init: self &rest))
|
|
264
|
+
(return self))
|
|
265
|
+
|
|
266
|
+
(method (setScript s)
|
|
267
|
+
(if script (script dispose:))
|
|
268
|
+
(= script s)
|
|
269
|
+
(if s (s init: self &rest))
|
|
270
|
+
(return self))
|
|
271
|
+
|
|
272
|
+
(method (dispose)
|
|
273
|
+
(if cycler (cycler dispose:) (= cycler 0))
|
|
274
|
+
(if script (script dispose:))
|
|
275
|
+
(super dispose:)))
|
|
276
|
+
|
|
277
|
+
;; A Prop that moves (a mover), facing where it goes.
|
|
278
|
+
(class Actor of Prop
|
|
279
|
+
(properties
|
|
280
|
+
mover 0
|
|
281
|
+
moveSpeed 2 ; cycles between steps
|
|
282
|
+
heading 0
|
|
283
|
+
scaler 0) ; sizes it by where it stands (perspective)
|
|
284
|
+
|
|
285
|
+
(method (doit)
|
|
286
|
+
(if mover
|
|
287
|
+
(mover doit:)
|
|
288
|
+
(if (and mover (mover completed?)) (mover motionCue:)))
|
|
289
|
+
(if scaler (scaler doit:))
|
|
290
|
+
(BaseSetter self)
|
|
291
|
+
(super doit:))
|
|
292
|
+
|
|
293
|
+
;; (actor setScaler: Scaler frontSize backSize frontY backY), sizes in percent; 0 stops.
|
|
294
|
+
(method (setScaler cls)
|
|
295
|
+
(if scaler (scaler dispose:))
|
|
296
|
+
(= scaler 0)
|
|
297
|
+
(if cls
|
|
298
|
+
(= scaler (cls new:))
|
|
299
|
+
(scaler init: self &rest)
|
|
300
|
+
else
|
|
301
|
+
(= scaleSignal 0))
|
|
302
|
+
(return self))
|
|
303
|
+
|
|
304
|
+
;; cls is a Motion class (a new one is made) or object; 0 stops moving.
|
|
305
|
+
(method (setMotion cls)
|
|
306
|
+
(if mover (mover dispose:))
|
|
307
|
+
(= mover 0)
|
|
308
|
+
(if cls
|
|
309
|
+
(= mover (if (& (cls -info-?) $8000) (cls new:) else cls))
|
|
310
|
+
(mover init: self &rest))
|
|
311
|
+
(return self))
|
|
312
|
+
|
|
313
|
+
;; Turns to face a direction (0 is up, clockwise in degrees); cues whoCares if given.
|
|
314
|
+
(method (setHeading h whoCares)
|
|
315
|
+
(= heading h)
|
|
316
|
+
(DirLoop self h)
|
|
317
|
+
(if (> argc 1) (whoCares cue:)))
|
|
318
|
+
|
|
319
|
+
;; Whether another actor is in the way (DoBresen asks).
|
|
320
|
+
(method (cantBeHere)
|
|
321
|
+
(return (CantBeHere self (cast elements?))))
|
|
322
|
+
|
|
323
|
+
(method (dispose)
|
|
324
|
+
(if mover (mover dispose:) (= mover 0))
|
|
325
|
+
(if scaler (scaler dispose:) (= scaler 0))
|
|
326
|
+
(super dispose:)))
|
|
327
|
+
|
|
328
|
+
;; The hero: walks where the player clicks, and goes from room to room.
|
|
329
|
+
(class Ego of Actor
|
|
330
|
+
;; Back to walking: cycling as he moves, turning as he goes, seen.
|
|
331
|
+
(method (normalize)
|
|
332
|
+
(self setLoop: -1 setCycle: Walk show:)
|
|
333
|
+
(return self))
|
|
334
|
+
|
|
335
|
+
(method (roomDisposed)
|
|
336
|
+
(self setMotion: 0)
|
|
337
|
+
(DeleteScreenItem self)
|
|
338
|
+
(cast delete: self)))
|
package/lib/999.sc
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
;;; The core of the class library: objects, collections and scripts, and the globals
|
|
2
|
+
;;; the rest of the library and every game use.
|
|
3
|
+
(script 999)
|
|
4
|
+
(include "system.sh")
|
|
5
|
+
|
|
6
|
+
(public SetFlag 0 ClearFlag 1 IsFlag 2)
|
|
7
|
+
|
|
8
|
+
(global
|
|
9
|
+
game ; the Game
|
|
10
|
+
curRoom ; the Room being played
|
|
11
|
+
curRoomNum
|
|
12
|
+
newRoomNum ; set to change rooms: the game changes at the end of the cycle
|
|
13
|
+
prevRoomNum ; where the hero came from
|
|
14
|
+
ego ; the hero
|
|
15
|
+
cast ; the Views on screen
|
|
16
|
+
features ; the Features that answer clicks
|
|
17
|
+
sounds ; the Sounds playing
|
|
18
|
+
user ; input
|
|
19
|
+
theEvent ; the Event the user fills each cycle
|
|
20
|
+
messager ; says message files' lines
|
|
21
|
+
narrator ; shows text
|
|
22
|
+
heroTalker ; says the hero's lines (the game sets it; the narrator otherwise)
|
|
23
|
+
talking ; whoever is showing a line now
|
|
24
|
+
dialog ; a menu waiting for a choice: it gets every click
|
|
25
|
+
music ; the Sound for music
|
|
26
|
+
sfx ; the Sound for effects
|
|
27
|
+
uiPlane ; the plane over the room, for text
|
|
28
|
+
gameTime ; cycles since the game started
|
|
29
|
+
quit ; set to end the game
|
|
30
|
+
[gameFlags 64]) ; story flags, a bit each
|
|
31
|
+
|
|
32
|
+
(procedure (SetFlag n)
|
|
33
|
+
(|= [gameFlags (/ n 16)] (<< 1 (mod n 16))))
|
|
34
|
+
|
|
35
|
+
(procedure (ClearFlag n)
|
|
36
|
+
(&= [gameFlags (/ n 16)] (~ (<< 1 (mod n 16)))))
|
|
37
|
+
|
|
38
|
+
(procedure (IsFlag n)
|
|
39
|
+
(return (!= 0 (& [gameFlags (/ n 16)] (<< 1 (mod n 16))))))
|
|
40
|
+
|
|
41
|
+
;; The root of every class.
|
|
42
|
+
(class Obj
|
|
43
|
+
;; A copy of this object (classes make instances this way).
|
|
44
|
+
(method (new)
|
|
45
|
+
(return (Clone self)))
|
|
46
|
+
|
|
47
|
+
(method (init))
|
|
48
|
+
|
|
49
|
+
(method (doit))
|
|
50
|
+
|
|
51
|
+
;; Frees an object made with new; does nothing to one declared in a script.
|
|
52
|
+
(method (dispose)
|
|
53
|
+
(DisposeClone self))
|
|
54
|
+
|
|
55
|
+
;; The object itself: (((Foo new:) x: 1 yourself:)) ends a chain of messages with it.
|
|
56
|
+
(method (yourself)
|
|
57
|
+
(return self))
|
|
58
|
+
|
|
59
|
+
(method (respondsTo sel)
|
|
60
|
+
(return (RespondsTo self sel)))
|
|
61
|
+
|
|
62
|
+
;; Runs a Code object's doit with this object as its first argument.
|
|
63
|
+
(method (perform code)
|
|
64
|
+
(return (code doit: self &rest))))
|
|
65
|
+
|
|
66
|
+
;; An object whose doit does one thing (for perform:).
|
|
67
|
+
(class Code of Obj)
|
|
68
|
+
|
|
69
|
+
;; A list of objects, kept by the interpreter.
|
|
70
|
+
(class Collection of Obj
|
|
71
|
+
(properties
|
|
72
|
+
elements 0 ; the kernel list
|
|
73
|
+
size 0)
|
|
74
|
+
|
|
75
|
+
(method (add item &tmp i)
|
|
76
|
+
(if (not elements) (= elements (NewList)))
|
|
77
|
+
(for ((= i 0)) (< i argc) ((++ i))
|
|
78
|
+
(AddToEnd elements (NewNode [item i] [item i]))
|
|
79
|
+
(++ size))
|
|
80
|
+
(return self))
|
|
81
|
+
|
|
82
|
+
(method (delete item &tmp i)
|
|
83
|
+
(for ((= i 0)) (< i argc) ((++ i))
|
|
84
|
+
(if (and elements (DeleteKey elements [item i]))
|
|
85
|
+
(-- size)))
|
|
86
|
+
(return self))
|
|
87
|
+
|
|
88
|
+
(method (contains item)
|
|
89
|
+
(return (and elements (FindKey elements item))))
|
|
90
|
+
|
|
91
|
+
(method (isEmpty)
|
|
92
|
+
(return (== size 0)))
|
|
93
|
+
|
|
94
|
+
;; Sends every element a message, with any further arguments.
|
|
95
|
+
(method (eachElementDo sel &tmp node nextNode)
|
|
96
|
+
(if (not elements) (return))
|
|
97
|
+
(for ((= node (FirstNode elements))) node ((= node nextNode))
|
|
98
|
+
;; Read the next one first: the element may leave the list.
|
|
99
|
+
(= nextNode (NextNode node))
|
|
100
|
+
((NodeValue node) [sel] &rest)))
|
|
101
|
+
|
|
102
|
+
;; The first element for which the message returns true, or 0.
|
|
103
|
+
(method (firstTrue sel &tmp node nextNode obj)
|
|
104
|
+
(if (not elements) (return 0))
|
|
105
|
+
(for ((= node (FirstNode elements))) node ((= node nextNode))
|
|
106
|
+
(= nextNode (NextNode node))
|
|
107
|
+
(= obj (NodeValue node))
|
|
108
|
+
(if (obj [sel] &rest) (return obj)))
|
|
109
|
+
(return 0))
|
|
110
|
+
|
|
111
|
+
;; Empties the list (the elements themselves stay).
|
|
112
|
+
(method (release)
|
|
113
|
+
(if elements (DisposeList elements))
|
|
114
|
+
(= elements 0)
|
|
115
|
+
(= size 0))
|
|
116
|
+
|
|
117
|
+
(method (dispose)
|
|
118
|
+
(self release:)
|
|
119
|
+
(super dispose:)))
|
|
120
|
+
|
|
121
|
+
(class List of Collection)
|
|
122
|
+
|
|
123
|
+
;; A Collection that holds each object once.
|
|
124
|
+
(class Set of Collection
|
|
125
|
+
(method (add item &tmp i)
|
|
126
|
+
(for ((= i 0)) (< i argc) ((++ i))
|
|
127
|
+
(if (not (self contains: [item i]))
|
|
128
|
+
(super add: [item i])))
|
|
129
|
+
(return self)))
|
|
130
|
+
|
|
131
|
+
;; A sequence of steps. changeState: runs a step; cue: goes to the next one, now or when a
|
|
132
|
+
;; wait set by the step runs out: `cycles` (game cycles), `ticks` (1/60 s) or `seconds`.
|
|
133
|
+
(class Script of Obj
|
|
134
|
+
(properties
|
|
135
|
+
client 0 ; what this script runs on
|
|
136
|
+
caller 0 ; cued when the script is disposed
|
|
137
|
+
state -1
|
|
138
|
+
start 0 ; the first state
|
|
139
|
+
register 0 ; a value given to init
|
|
140
|
+
script 0 ; a script of this script
|
|
141
|
+
cycles 0
|
|
142
|
+
ticks 0
|
|
143
|
+
seconds 0
|
|
144
|
+
lastSecond 0)
|
|
145
|
+
|
|
146
|
+
(method (init who whoCares reg)
|
|
147
|
+
(= client who)
|
|
148
|
+
(= caller (if (> argc 1) whoCares else 0))
|
|
149
|
+
(if (> argc 2) (= register reg))
|
|
150
|
+
(= cycles 0)
|
|
151
|
+
(= ticks 0)
|
|
152
|
+
(= seconds 0)
|
|
153
|
+
(self changeState: start))
|
|
154
|
+
|
|
155
|
+
(method (doit)
|
|
156
|
+
(if script (script doit:))
|
|
157
|
+
(cond
|
|
158
|
+
((> cycles 0)
|
|
159
|
+
(if (== (-- cycles) 0) (self cue:)))
|
|
160
|
+
((> ticks 0)
|
|
161
|
+
(if (<= (-- ticks) 0) (self cue:)))
|
|
162
|
+
((> seconds 0)
|
|
163
|
+
(if (not lastSecond) (= lastSecond gameTime))
|
|
164
|
+
(if (>= (- gameTime lastSecond) 60)
|
|
165
|
+
(= lastSecond gameTime)
|
|
166
|
+
(if (== (-- seconds) 0)
|
|
167
|
+
(= lastSecond 0)
|
|
168
|
+
(self cue:))))))
|
|
169
|
+
|
|
170
|
+
(method (changeState newState)
|
|
171
|
+
(= state newState))
|
|
172
|
+
|
|
173
|
+
(method (cue)
|
|
174
|
+
(self changeState: (+ state 1)))
|
|
175
|
+
|
|
176
|
+
(method (setScript s)
|
|
177
|
+
(if script (script dispose:))
|
|
178
|
+
(= script s)
|
|
179
|
+
(if s (s init: self &rest)))
|
|
180
|
+
|
|
181
|
+
(method (dispose &tmp c)
|
|
182
|
+
(if script (script dispose:) (= script 0))
|
|
183
|
+
(if (and client (== (client script?) self)) (client script: 0))
|
|
184
|
+
(= c caller)
|
|
185
|
+
(= client 0)
|
|
186
|
+
(= caller 0)
|
|
187
|
+
(= state -1)
|
|
188
|
+
(super dispose:)
|
|
189
|
+
(if c (c cue:))))
|
package/lib/resources.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Colour, ResourceType, writeView } from "../tools/game/kit.js";
|
|
2
|
+
/**
|
|
3
|
+
* The class library's own resources: a cursor for each verb, view CURSOR_BASE + verb
|
|
4
|
+
* (system.sh). X is black, W white, . transparent.
|
|
5
|
+
*/
|
|
6
|
+
const CURSOR_BASE = 990;
|
|
7
|
+
const CURSORS = {
|
|
8
|
+
// V_LOOK: an eye.
|
|
9
|
+
1: {
|
|
10
|
+
hotspot: "centre",
|
|
11
|
+
art: [
|
|
12
|
+
"....XXXXX....",
|
|
13
|
+
"..XXWWWWWXX..",
|
|
14
|
+
".XWWWXXXWWWX.",
|
|
15
|
+
"XWWWXXWXXWWWX",
|
|
16
|
+
"XWWWXXXXXWWWX",
|
|
17
|
+
".XWWWXXXWWWX.",
|
|
18
|
+
"..XXWWWWWXX..",
|
|
19
|
+
"....XXXXX....",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
// V_TALK: a speech balloon.
|
|
23
|
+
2: {
|
|
24
|
+
hotspot: "centre",
|
|
25
|
+
art: [
|
|
26
|
+
".XXXXXXXXXX.",
|
|
27
|
+
"XWWWWWWWWWWX",
|
|
28
|
+
"XWXXWXXWXXWX",
|
|
29
|
+
"XWWWWWWWWWWX",
|
|
30
|
+
"XWXXXXWXXXWX",
|
|
31
|
+
"XWWWWWWWWWWX",
|
|
32
|
+
".XXXWWXXXXX.",
|
|
33
|
+
"...XWX......",
|
|
34
|
+
"...XX.......",
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
// V_WALK: an arrow, pointing with its tip.
|
|
38
|
+
3: {
|
|
39
|
+
hotspot: "tip",
|
|
40
|
+
art: [
|
|
41
|
+
"X.......",
|
|
42
|
+
"XX......",
|
|
43
|
+
"XWX.....",
|
|
44
|
+
"XWWX....",
|
|
45
|
+
"XWWWX...",
|
|
46
|
+
"XWWWWX..",
|
|
47
|
+
"XWWWWWX.",
|
|
48
|
+
"XWWWWWWX",
|
|
49
|
+
"XWWWXXXX",
|
|
50
|
+
"XWXWWX..",
|
|
51
|
+
"XX.XWWX.",
|
|
52
|
+
"X...XWX.",
|
|
53
|
+
".....XX.",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
// V_DO: a hand.
|
|
57
|
+
4: {
|
|
58
|
+
hotspot: "centre",
|
|
59
|
+
art: [
|
|
60
|
+
"...XX......",
|
|
61
|
+
"..XWWX.....",
|
|
62
|
+
"..XWWX.....",
|
|
63
|
+
"..XWWXXX...",
|
|
64
|
+
"..XWWXWWXX.",
|
|
65
|
+
".XXWWXWWXWX",
|
|
66
|
+
"XWXWWWWWXWX",
|
|
67
|
+
"XWWWWWWWWWX",
|
|
68
|
+
".XWWWWWWWWX",
|
|
69
|
+
"..XWWWWWWX.",
|
|
70
|
+
"...XXXXXX..",
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
function cursor(art, hotspot) {
|
|
75
|
+
const width = art[0].length, height = art.length;
|
|
76
|
+
const pixels = Uint8Array.from(art.join(""), (c) => (c === "X" ? Colour.Black : c === "W" ? Colour.White : Colour.Transparent));
|
|
77
|
+
// The cel's origin is the hotspot: (width/2 - displaceX, height - 1 - displaceY).
|
|
78
|
+
const [hx, hy] = hotspot === "tip" ? [0, 0] : [width >> 1, height >> 1];
|
|
79
|
+
const cel = { width, height, displaceX: (width >> 1) - hx, displaceY: height - 1 - hy, skipColor: Colour.Transparent, pixels };
|
|
80
|
+
return writeView({ flags: 1, loops: [{ link: -1, mirror: false, cels: [cel] }], palette: undefined });
|
|
81
|
+
}
|
|
82
|
+
export default function resources() {
|
|
83
|
+
return Object.entries(CURSORS).map(([verb, c]) => ({ type: ResourceType.View, number: CURSOR_BASE + Number(verb), data: cursor(c.art, c.hotspot) }));
|
|
84
|
+
}
|
package/lib/resources.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Colour, ResourceType, writeView, type ResourceData } from "../tools/game/kit.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The class library's own resources: a cursor for each verb, view CURSOR_BASE + verb
|
|
5
|
+
* (system.sh). X is black, W white, . transparent.
|
|
6
|
+
*/
|
|
7
|
+
const CURSOR_BASE = 990;
|
|
8
|
+
|
|
9
|
+
const CURSORS: Record<number, { art: string[]; hotspot: "tip" | "centre" }> = {
|
|
10
|
+
// V_LOOK: an eye.
|
|
11
|
+
1: {
|
|
12
|
+
hotspot: "centre",
|
|
13
|
+
art: [
|
|
14
|
+
"....XXXXX....",
|
|
15
|
+
"..XXWWWWWXX..",
|
|
16
|
+
".XWWWXXXWWWX.",
|
|
17
|
+
"XWWWXXWXXWWWX",
|
|
18
|
+
"XWWWXXXXXWWWX",
|
|
19
|
+
".XWWWXXXWWWX.",
|
|
20
|
+
"..XXWWWWWXX..",
|
|
21
|
+
"....XXXXX....",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
// V_TALK: a speech balloon.
|
|
25
|
+
2: {
|
|
26
|
+
hotspot: "centre",
|
|
27
|
+
art: [
|
|
28
|
+
".XXXXXXXXXX.",
|
|
29
|
+
"XWWWWWWWWWWX",
|
|
30
|
+
"XWXXWXXWXXWX",
|
|
31
|
+
"XWWWWWWWWWWX",
|
|
32
|
+
"XWXXXXWXXXWX",
|
|
33
|
+
"XWWWWWWWWWWX",
|
|
34
|
+
".XXXWWXXXXX.",
|
|
35
|
+
"...XWX......",
|
|
36
|
+
"...XX.......",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
// V_WALK: an arrow, pointing with its tip.
|
|
40
|
+
3: {
|
|
41
|
+
hotspot: "tip",
|
|
42
|
+
art: [
|
|
43
|
+
"X.......",
|
|
44
|
+
"XX......",
|
|
45
|
+
"XWX.....",
|
|
46
|
+
"XWWX....",
|
|
47
|
+
"XWWWX...",
|
|
48
|
+
"XWWWWX..",
|
|
49
|
+
"XWWWWWX.",
|
|
50
|
+
"XWWWWWWX",
|
|
51
|
+
"XWWWXXXX",
|
|
52
|
+
"XWXWWX..",
|
|
53
|
+
"XX.XWWX.",
|
|
54
|
+
"X...XWX.",
|
|
55
|
+
".....XX.",
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
// V_DO: a hand.
|
|
59
|
+
4: {
|
|
60
|
+
hotspot: "centre",
|
|
61
|
+
art: [
|
|
62
|
+
"...XX......",
|
|
63
|
+
"..XWWX.....",
|
|
64
|
+
"..XWWX.....",
|
|
65
|
+
"..XWWXXX...",
|
|
66
|
+
"..XWWXWWXX.",
|
|
67
|
+
".XXWWXWWXWX",
|
|
68
|
+
"XWXWWWWWXWX",
|
|
69
|
+
"XWWWWWWWWWX",
|
|
70
|
+
".XWWWWWWWWX",
|
|
71
|
+
"..XWWWWWWX.",
|
|
72
|
+
"...XXXXXX..",
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
function cursor(art: string[], hotspot: "tip" | "centre") {
|
|
78
|
+
const width = art[0]!.length, height = art.length;
|
|
79
|
+
const pixels = Uint8Array.from(art.join(""), (c) => (c === "X" ? Colour.Black : c === "W" ? Colour.White : Colour.Transparent));
|
|
80
|
+
// The cel's origin is the hotspot: (width/2 - displaceX, height - 1 - displaceY).
|
|
81
|
+
const [hx, hy] = hotspot === "tip" ? [0, 0] : [width >> 1, height >> 1];
|
|
82
|
+
const cel = { width, height, displaceX: (width >> 1) - hx, displaceY: height - 1 - hy, skipColor: Colour.Transparent, pixels };
|
|
83
|
+
return writeView({ flags: 1, loops: [{ link: -1, mirror: false, cels: [cel] }], palette: undefined });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default function resources(): ResourceData[] {
|
|
87
|
+
return Object.entries(CURSORS).map(([verb, c]) => ({ type: ResourceType.View, number: CURSOR_BASE + Number(verb), data: cursor(c.art, c.hotspot) }));
|
|
88
|
+
}
|