kaplay 3000.1.17

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2021 Replit
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,209 @@
1
+ # KAPLAY
2
+
3
+ ![kaplay](https://github.com/marklovers/kaplay/raw/master/assets/kaplay.png)
4
+
5
+ > Kaplay is the spiritual successor (and fork) of Kaboom, a JavaScript library that helps you make games fast and fun!
6
+ > For now, there's links to the Kaboom documentation and examples, but in the future, they will be linked
7
+ > to our own site.
8
+
9
+ [**Kaplay**](https://kaplaydocs.pages.dev/) is a JavaScript library that helps you make games fast and fun!
10
+
11
+ Start playing around with it in the [Kaplayground](https://kaplay.pages.dev/)
12
+
13
+ ## Examples
14
+
15
+ ```js
16
+ // initialize context
17
+ kaboom();
18
+
19
+ // define gravity
20
+ setGravity(2400);
21
+
22
+ // load a sprite called "bean"
23
+ loadSprite("bean", "sprites/bean.png");
24
+
25
+ // compose the player game object from multiple components and add it to the game
26
+ const bean = add([
27
+ sprite("bean"),
28
+ pos(80, 40),
29
+ area(),
30
+ body(),
31
+ ]);
32
+
33
+ // press space to jump
34
+ onKeyPress("space", () => {
35
+ // this method is provided by the "body" component above
36
+ bean.jump();
37
+ });
38
+ ```
39
+
40
+ kaplay uses a powerful component system to compose game objects and behaviors.
41
+
42
+ ```js
43
+ // add a game obj to the scene from a list of component
44
+ const player = add([
45
+ // it renders as a sprite
46
+ sprite("bean"),
47
+ // it has a position
48
+ pos(100, 200),
49
+ // it has a collider
50
+ area(),
51
+ // it is a physical body which will respond to physics
52
+ body(),
53
+ // it has 8 of health
54
+ health(8),
55
+ // or give it tags for easier group behaviors
56
+ "player",
57
+ "friendly",
58
+ // plain objects fields are directly assigned to the game obj
59
+ {
60
+ dir: vec2(-1, 0),
61
+ dead: false,
62
+ speed: 240,
63
+ },
64
+ ]);
65
+ ```
66
+
67
+ Blocky imperative syntax for describing behaviors
68
+
69
+ ```js
70
+ // .onCollide() comes from "area" component
71
+ player.onCollide("enemy", () => {
72
+ // .hurt() comes from "health" component
73
+ player.hurt(1);
74
+ });
75
+
76
+ // check fall death
77
+ player.onUpdate(() => {
78
+ if (player.pos.y >= height()) {
79
+ destroy(player);
80
+ gameOver();
81
+ }
82
+ });
83
+
84
+ // if 'player' onCollide with any object with tag "enemy", run the callback
85
+ player.onCollide("enemy", () => {
86
+ player.hp -= 1;
87
+ });
88
+
89
+ // all objects with tag "enemy" will move towards 'player' every frame
90
+ onUpdate("enemy", (e) => {
91
+ e.move(player.pos.sub(e.pos).unit().scale(e.speed));
92
+ });
93
+
94
+ // move up 100 pixels per second every frame when "w" key is held down
95
+ onKeyDown("w", () => {
96
+ player.move(0, 100);
97
+ });
98
+ ```
99
+
100
+ ## Usage
101
+
102
+ ### Start a Project With `create-kaboom`
103
+
104
+ The fastest way to start a Kaboom game is with [`create-kaboom`](https://github.com/replit/kaboom/tree/master/pkgs/create)
105
+
106
+ ```sh
107
+ $ npm init kaboom mygame
108
+ ```
109
+
110
+ This will create a directory called `mygame` for you, containing all the files we need
111
+
112
+ ```sh
113
+ $ cd mygame
114
+ $ npm run dev
115
+ ```
116
+
117
+ Then open http://localhost:5173 and edit `src/game.js`
118
+
119
+ ### Install as NPM Package
120
+
121
+ ```sh
122
+ $ npm install kaplay
123
+ ```
124
+
125
+ ```js
126
+ import kaboom from "kaplay";
127
+
128
+ kaboom();
129
+
130
+ add([
131
+ text("oh hi"),
132
+ pos(80, 40),
133
+ ]);
134
+ ```
135
+
136
+ also works with CommonJS
137
+
138
+ ```js
139
+ const kaboom = require("kaplay");
140
+ ```
141
+
142
+ Note that you'll need to use a bundler like `esbuild` or `webpack` to use Kaboom with NPM
143
+
144
+ ### Browser CDN
145
+
146
+ This exports a global `kaboom` function
147
+
148
+ ```html
149
+ <script src="https://unpkg.com/kaplay@3001/dist/kaboom.js"></script>
150
+ <script>
151
+ kaboom()
152
+ </script>
153
+ ```
154
+
155
+ or use with es modules
156
+
157
+ ```html
158
+ <script type="module">
159
+ import kaboom from "https://unpkg.com/kaplay@3001/dist/kaboom.mjs"
160
+ kaboom()
161
+ </script>
162
+ ```
163
+
164
+ works all CDNs that supports NPM packages, e.g. jsdelivr, skypack
165
+
166
+ ## Documentation
167
+
168
+ - **v3001**: https://kaplaydocs.pages.dev/
169
+ - **v3000**: https://kaboomjs.com/
170
+ - **v2000**: https://2000.kaboomjs.com/
171
+ - **v0.5.0**: https://legacy.kaboomjs.com/
172
+
173
+ ## Dev
174
+
175
+ 1. `npm install` to install dev packages
176
+ 1. `npm run dev` to start dev server
177
+ 1. go to http://localhost:8000/ and pick an example
178
+ 1. edit examples in `examples/` to test
179
+
180
+ Check out [CONTRIBUTION.md](CONTRIBUTING.md) for full info.
181
+
182
+ ## Community
183
+
184
+ - [Discord Server](https://discord.gg/aQ6RuQm3TF)
185
+ - [GitHub Discussions](https://github.com/marklovers/kaplay/discussions)
186
+ - [Twitter](https://twitter.com/Kaboomjs)
187
+
188
+ ### Games
189
+
190
+ Collection of games made with Kaboom, selected by Kaboom, [here](https://itch.io/c/2645141/made-in-kaboom).
191
+
192
+ - [on Itch.io](https://itch.io/games/tag-kaboomjs)
193
+ - [on Replit](https://replit.com/apps/kaboom)
194
+ - [on Newgrounds](https://www.newgrounds.com/search/conduct/games?tags=kaboomjs)
195
+
196
+ ## Misc
197
+
198
+ - This project has no relation to Activision's game [Kaboom!](https://en.wikipedia.org/wiki/Kaboom!_(video_game))
199
+ - Thanks to [tga](https://space55.xyz) for all his work on the original Kaboom.js
200
+ - Thanks to [abrudz](https://github.com/abrudz) for the amazing [APL386 font](https://abrudz.github.io/APL386/)
201
+ - Thanks to [Polyducks](http://polyducks.co.uk/) for the amazing [kitchen sink font](https://polyducks.itch.io/kitchen-sink-textmode-font) font
202
+ - Thanks to [0x72](https://0x72.itch.io/) for the amazing [Dungeon Tileset](https://0x72.itch.io/dungeontileset-ii)
203
+ - Thanks to [Kenney](https://kenney.nl/) for the amazing [1-Bit Platformer Pack](https://kenney.nl/assets/1-bit-platformer-pack)
204
+ - Thanks to [mulfok](https://twitter.com/MulfoK) for the amazing [mulfok32](https://lospec.com/palette-list/mulfok32) color palette
205
+ - Find bitmap fonts: [Oldschool PC Font](https://int10h.org/oldschool-pc-fonts)
206
+ - Featured on [Console 50](https://console.substack.com/p/console-50)
207
+ - Thanks to [Umayr](https://github.com/umayr) for kindly offering the "kaboom" npm package name
208
+ - Please buy fireworks on [kaboom.com](http://www.kaboom.com/)
209
+ - [How to do a KABOOM on a Trampoline](https://www.youtube.com/watch?v=3CemcWdc_Hc)
@@ -0,0 +1,237 @@
1
+ import { KaboomCtx } from "./kaboom"
2
+ declare global {
3
+ const add: KaboomCtx["add"]
4
+ const make: KaboomCtx["make"]
5
+ const readd: KaboomCtx["readd"]
6
+ const get: KaboomCtx["get"]
7
+ const destroy: KaboomCtx["destroy"]
8
+ const destroyAll: KaboomCtx["destroyAll"]
9
+ const pos: KaboomCtx["pos"]
10
+ const scale: KaboomCtx["scale"]
11
+ const rotate: KaboomCtx["rotate"]
12
+ const color: KaboomCtx["color"]
13
+ const opacity: KaboomCtx["opacity"]
14
+ const sprite: KaboomCtx["sprite"]
15
+ const text: KaboomCtx["text"]
16
+ const polygon: KaboomCtx["polygon"]
17
+ const rect: KaboomCtx["rect"]
18
+ const circle: KaboomCtx["circle"]
19
+ const uvquad: KaboomCtx["uvquad"]
20
+ const area: KaboomCtx["area"]
21
+ const anchor: KaboomCtx["anchor"]
22
+ const z: KaboomCtx["z"]
23
+ const outline: KaboomCtx["outline"]
24
+ const body: KaboomCtx["body"]
25
+ const doubleJump: KaboomCtx["doubleJump"]
26
+ const move: KaboomCtx["move"]
27
+ const offscreen: KaboomCtx["offscreen"]
28
+ const follow: KaboomCtx["follow"]
29
+ const shader: KaboomCtx["shader"]
30
+ const timer: KaboomCtx["timer"]
31
+ const fixed: KaboomCtx["fixed"]
32
+ const stay: KaboomCtx["stay"]
33
+ const health: KaboomCtx["health"]
34
+ const lifespan: KaboomCtx["lifespan"]
35
+ const state: KaboomCtx["state"]
36
+ const fadeIn: KaboomCtx["fadeIn"]
37
+ const mask: KaboomCtx["mask"]
38
+ const drawon: KaboomCtx["drawon"]
39
+ const tile: KaboomCtx["tile"]
40
+ const agent: KaboomCtx["agent"]
41
+ const on: KaboomCtx["on"]
42
+ const onUpdate: KaboomCtx["onUpdate"]
43
+ const onDraw: KaboomCtx["onDraw"]
44
+ const onAdd: KaboomCtx["onAdd"]
45
+ const onDestroy: KaboomCtx["onDestroy"]
46
+ const onLoad: KaboomCtx["onLoad"]
47
+ const onLoading: KaboomCtx["onLoading"]
48
+ const onError: KaboomCtx["onError"]
49
+ const onResize: KaboomCtx["onResize"]
50
+ const onCleanup: KaboomCtx["onCleanup"]
51
+ const onGamepadConnect: KaboomCtx["onGamepadConnect"]
52
+ const onGamepadDisconnect: KaboomCtx["onGamepadDisconnect"]
53
+ const onCollide: KaboomCtx["onCollide"]
54
+ const onCollideUpdate: KaboomCtx["onCollideUpdate"]
55
+ const onCollideEnd: KaboomCtx["onCollideEnd"]
56
+ const onClick: KaboomCtx["onClick"]
57
+ const onHover: KaboomCtx["onHover"]
58
+ const onHoverUpdate: KaboomCtx["onHoverUpdate"]
59
+ const onHoverEnd: KaboomCtx["onHoverEnd"]
60
+ const onKeyDown: KaboomCtx["onKeyDown"]
61
+ const onKeyPress: KaboomCtx["onKeyPress"]
62
+ const onKeyPressRepeat: KaboomCtx["onKeyPressRepeat"]
63
+ const onKeyRelease: KaboomCtx["onKeyRelease"]
64
+ const onCharInput: KaboomCtx["onCharInput"]
65
+ const onMouseDown: KaboomCtx["onMouseDown"]
66
+ const onMousePress: KaboomCtx["onMousePress"]
67
+ const onMouseRelease: KaboomCtx["onMouseRelease"]
68
+ const onMouseMove: KaboomCtx["onMouseMove"]
69
+ const onTouchStart: KaboomCtx["onTouchStart"]
70
+ const onTouchMove: KaboomCtx["onTouchMove"]
71
+ const onTouchEnd: KaboomCtx["onTouchEnd"]
72
+ const onScroll: KaboomCtx["onScroll"]
73
+ const onHide: KaboomCtx["onHide"]
74
+ const onShow: KaboomCtx["onShow"]
75
+ const onGamepadButtonDown: KaboomCtx["onGamepadButtonDown"]
76
+ const onGamepadButtonPress: KaboomCtx["onGamepadButtonPress"]
77
+ const onGamepadButtonRelease: KaboomCtx["onGamepadButtonRelease"]
78
+ const onGamepadStick: KaboomCtx["onGamepadStick"]
79
+ const onSceneLeave: KaboomCtx["onSceneLeave"]
80
+ const loadRoot: KaboomCtx["loadRoot"]
81
+ const loadSprite: KaboomCtx["loadSprite"]
82
+ const loadSpriteAtlas: KaboomCtx["loadSpriteAtlas"]
83
+ const loadAseprite: KaboomCtx["loadAseprite"]
84
+ const loadPedit: KaboomCtx["loadPedit"]
85
+ const loadBean: KaboomCtx["loadBean"]
86
+ const loadJSON: KaboomCtx["loadJSON"]
87
+ const loadSound: KaboomCtx["loadSound"]
88
+ const loadFont: KaboomCtx["loadFont"]
89
+ const loadBitmapFont: KaboomCtx["loadBitmapFont"]
90
+ const loadShader: KaboomCtx["loadShader"]
91
+ const loadShaderURL: KaboomCtx["loadShaderURL"]
92
+ const load: KaboomCtx["load"]
93
+ const loadProgress: KaboomCtx["loadProgress"]
94
+ const getSprite: KaboomCtx["getSprite"]
95
+ const getSound: KaboomCtx["getSound"]
96
+ const getFont: KaboomCtx["getFont"]
97
+ const getBitmapFont: KaboomCtx["getBitmapFont"]
98
+ const getShader: KaboomCtx["getShader"]
99
+ const getAsset: KaboomCtx["getAsset"]
100
+ const Asset: KaboomCtx["Asset"]
101
+ const SpriteData: KaboomCtx["SpriteData"]
102
+ const SoundData: KaboomCtx["SoundData"]
103
+ const width: KaboomCtx["width"]
104
+ const height: KaboomCtx["height"]
105
+ const center: KaboomCtx["center"]
106
+ const dt: KaboomCtx["dt"]
107
+ const time: KaboomCtx["time"]
108
+ const isFocused: KaboomCtx["isFocused"]
109
+ const isTouchscreen: KaboomCtx["isTouchscreen"]
110
+ const mousePos: KaboomCtx["mousePos"]
111
+ const mouseDeltaPos: KaboomCtx["mouseDeltaPos"]
112
+ const isKeyDown: KaboomCtx["isKeyDown"]
113
+ const isKeyPressed: KaboomCtx["isKeyPressed"]
114
+ const isKeyPressedRepeat: KaboomCtx["isKeyPressedRepeat"]
115
+ const isKeyReleased: KaboomCtx["isKeyReleased"]
116
+ const isMouseDown: KaboomCtx["isMouseDown"]
117
+ const isMousePressed: KaboomCtx["isMousePressed"]
118
+ const isMouseReleased: KaboomCtx["isMouseReleased"]
119
+ const isMouseMoved: KaboomCtx["isMouseMoved"]
120
+ const isGamepadButtonPressed: KaboomCtx["isGamepadButtonPressed"]
121
+ const isGamepadButtonDown: KaboomCtx["isGamepadButtonDown"]
122
+ const isGamepadButtonReleased: KaboomCtx["isGamepadButtonReleased"]
123
+ const getGamepadStick: KaboomCtx["getGamepadStick"]
124
+ const charInputted: KaboomCtx["charInputted"]
125
+ const shake: KaboomCtx["shake"]
126
+ const camPos: KaboomCtx["camPos"]
127
+ const camScale: KaboomCtx["camScale"]
128
+ const camRot: KaboomCtx["camRot"]
129
+ const toScreen: KaboomCtx["toScreen"]
130
+ const toWorld: KaboomCtx["toWorld"]
131
+ const setGravity: KaboomCtx["setGravity"]
132
+ const getGravity: KaboomCtx["getGravity"]
133
+ const setBackground: KaboomCtx["setBackground"]
134
+ const getBackground: KaboomCtx["getBackground"]
135
+ const getGamepads: KaboomCtx["getGamepads"]
136
+ const setCursor: KaboomCtx["setCursor"]
137
+ const getCursor: KaboomCtx["getCursor"]
138
+ const setCursorLocked: KaboomCtx["setCursorLocked"]
139
+ const isCursorLocked: KaboomCtx["isCursorLocked"]
140
+ const setFullscreen: KaboomCtx["setFullscreen"]
141
+ const isFullscreen: KaboomCtx["isFullscreen"]
142
+ const wait: KaboomCtx["wait"]
143
+ const loop: KaboomCtx["loop"]
144
+ const play: KaboomCtx["play"]
145
+ const burp: KaboomCtx["burp"]
146
+ const volume: KaboomCtx["volume"]
147
+ const audioCtx: KaboomCtx["audioCtx"]
148
+ const rand: KaboomCtx["rand"]
149
+ const randi: KaboomCtx["randi"]
150
+ const randSeed: KaboomCtx["randSeed"]
151
+ const vec2: KaboomCtx["vec2"]
152
+ const rgb: KaboomCtx["rgb"]
153
+ const hsl2rgb: KaboomCtx["hsl2rgb"]
154
+ const quad: KaboomCtx["quad"]
155
+ const choose: KaboomCtx["choose"]
156
+ const chance: KaboomCtx["chance"]
157
+ const lerp: KaboomCtx["lerp"]
158
+ const tween: KaboomCtx["tween"]
159
+ const easings: KaboomCtx["easings"]
160
+ const map: KaboomCtx["map"]
161
+ const mapc: KaboomCtx["mapc"]
162
+ const wave: KaboomCtx["wave"]
163
+ const deg2rad: KaboomCtx["deg2rad"]
164
+ const rad2deg: KaboomCtx["rad2deg"]
165
+ const clamp: KaboomCtx["clamp"]
166
+ const testLinePoint: KaboomCtx["testLinePoint"]
167
+ const testLineLine: KaboomCtx["testLineLine"]
168
+ const testLineCircle: KaboomCtx["testLineCircle"]
169
+ const testRectRect: KaboomCtx["testRectRect"]
170
+ const testRectLine: KaboomCtx["testRectLine"]
171
+ const testRectPoint: KaboomCtx["testRectPoint"]
172
+ const testCirclePolygon: KaboomCtx["testCirclePolygon"]
173
+ const Line: KaboomCtx["Line"]
174
+ const Rect: KaboomCtx["Rect"]
175
+ const Circle: KaboomCtx["Circle"]
176
+ const Polygon: KaboomCtx["Polygon"]
177
+ const Vec2: KaboomCtx["Vec2"]
178
+ const Color: KaboomCtx["Color"]
179
+ const Mat4: KaboomCtx["Mat4"]
180
+ const Quad: KaboomCtx["Quad"]
181
+ const RNG: KaboomCtx["RNG"]
182
+ const scene: KaboomCtx["scene"]
183
+ const go: KaboomCtx["go"]
184
+ const addLevel: KaboomCtx["addLevel"]
185
+ const getData: KaboomCtx["getData"]
186
+ const setData: KaboomCtx["setData"]
187
+ const drawSprite: KaboomCtx["drawSprite"]
188
+ const drawText: KaboomCtx["drawText"]
189
+ const drawRect: KaboomCtx["drawRect"]
190
+ const drawLine: KaboomCtx["drawLine"]
191
+ const drawLines: KaboomCtx["drawLines"]
192
+ const drawTriangle: KaboomCtx["drawTriangle"]
193
+ const drawCircle: KaboomCtx["drawCircle"]
194
+ const drawEllipse: KaboomCtx["drawEllipse"]
195
+ const drawPolygon: KaboomCtx["drawPolygon"]
196
+ const drawUVQuad: KaboomCtx["drawUVQuad"]
197
+ const drawFormattedText: KaboomCtx["drawFormattedText"]
198
+ const drawMasked: KaboomCtx["drawMasked"]
199
+ const drawSubtracted: KaboomCtx["drawSubtracted"]
200
+ const pushTransform: KaboomCtx["pushTransform"]
201
+ const popTransform: KaboomCtx["popTransform"]
202
+ const pushTranslate: KaboomCtx["pushTranslate"]
203
+ const pushScale: KaboomCtx["pushScale"]
204
+ const pushRotate: KaboomCtx["pushRotate"]
205
+ const pushMatrix: KaboomCtx["pushMatrix"]
206
+ const usePostEffect: KaboomCtx["usePostEffect"]
207
+ const formatText: KaboomCtx["formatText"]
208
+ const makeCanvas: KaboomCtx["makeCanvas"]
209
+ const debug: KaboomCtx["debug"]
210
+ const plug: KaboomCtx["plug"]
211
+ const screenshot: KaboomCtx["screenshot"]
212
+ const download: KaboomCtx["download"]
213
+ const downloadText: KaboomCtx["downloadText"]
214
+ const downloadJSON: KaboomCtx["downloadJSON"]
215
+ const downloadBlob: KaboomCtx["downloadBlob"]
216
+ const record: KaboomCtx["record"]
217
+ const addKaboom: KaboomCtx["addKaboom"]
218
+ const ASCII_CHARS: KaboomCtx["ASCII_CHARS"]
219
+ const LEFT: KaboomCtx["LEFT"]
220
+ const RIGHT: KaboomCtx["RIGHT"]
221
+ const UP: KaboomCtx["UP"]
222
+ const DOWN: KaboomCtx["DOWN"]
223
+ const RED: KaboomCtx["RED"]
224
+ const GREEN: KaboomCtx["GREEN"]
225
+ const BLUE: KaboomCtx["BLUE"]
226
+ const YELLOW: KaboomCtx["YELLOW"]
227
+ const MAGENTA: KaboomCtx["MAGENTA"]
228
+ const CYAN: KaboomCtx["CYAN"]
229
+ const WHITE: KaboomCtx["WHITE"]
230
+ const BLACK: KaboomCtx["BLACK"]
231
+ const canvas: KaboomCtx["canvas"]
232
+ const quit: KaboomCtx["quit"]
233
+ const Event: KaboomCtx["Event"]
234
+ const EventHandler: KaboomCtx["EventHandler"]
235
+ const EventController: KaboomCtx["EventController"]
236
+ const VERSION: KaboomCtx["VERSION"]
237
+ }
package/dist/global.js ADDED
File without changes