kaplay 3001.0.0-alpha.1

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,208 @@
1
+ # KAPLAY
2
+
3
+ ![kaplay](assets/kaplay.gif)
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
+
10
+ [**Kaboom**](https://kaboomjs.com) is a JavaScript library that helps you make games fast and fun!
11
+
12
+ Start playing around with it in the [Kaboom Playground](https://kaboomjs.com/play)
13
+
14
+ ## Examples
15
+
16
+ ```js
17
+ // initialize context
18
+ kaboom()
19
+
20
+ // define gravity
21
+ setGravity(2400)
22
+
23
+ // load a sprite called "bean"
24
+ loadSprite("bean", "sprites/bean.png")
25
+
26
+ // compose the player game object from multiple components and add it to the game
27
+ const bean = add([
28
+ sprite("bean"),
29
+ pos(80, 40),
30
+ area(),
31
+ body(),
32
+ ])
33
+
34
+ // press space to jump
35
+ onKeyPress("space", () => {
36
+ // this method is provided by the "body" component above
37
+ bean.jump()
38
+ })
39
+ ```
40
+
41
+ Kaboom uses a powerful component system to compose game objects and behaviors.
42
+
43
+ ```js
44
+ // add a game obj to the scene from a list of component
45
+ const player = add([
46
+ // it renders as a sprite
47
+ sprite("bean"),
48
+ // it has a position
49
+ pos(100, 200),
50
+ // it has a collider
51
+ area(),
52
+ // it is a physical body which will respond to physics
53
+ body(),
54
+ // it has 8 of health
55
+ health(8),
56
+ // or give it tags for easier group behaviors
57
+ "player",
58
+ "friendly",
59
+ // plain objects fields are directly assigned to the game obj
60
+ {
61
+ dir: vec2(-1, 0),
62
+ dead: false,
63
+ speed: 240,
64
+ },
65
+ ])
66
+ ```
67
+
68
+ Blocky imperative syntax for describing behaviors
69
+
70
+ ```js
71
+ // .onCollide() comes from "area" component
72
+ player.onCollide("enemy", () => {
73
+ // .hurt() comes from "health" component
74
+ player.hurt(1)
75
+ })
76
+
77
+ // check fall death
78
+ player.onUpdate(() => {
79
+ if (player.pos.y >= height()) {
80
+ destroy(player)
81
+ gameOver()
82
+ }
83
+ })
84
+
85
+ // if 'player' onCollide with any object with tag "enemy", run the callback
86
+ player.onCollide("enemy", () => {
87
+ player.hp -= 1
88
+ })
89
+
90
+ // all objects with tag "enemy" will move towards 'player' every frame
91
+ onUpdate("enemy", (e) => {
92
+ e.move(player.pos.sub(e.pos).unit().scale(e.speed))
93
+ })
94
+
95
+ // move up 100 pixels per second every frame when "w" key is held down
96
+ onKeyDown("w", () => {
97
+ player.move(0, 100)
98
+ })
99
+ ```
100
+
101
+ ## Usage
102
+
103
+ ### Start a Project With `create-kaboom`
104
+
105
+ The fastest way to start a Kaboom game is with [`create-kaboom`](https://github.com/replit/kaboom/tree/master/pkgs/create)
106
+
107
+ ```sh
108
+ $ npm init kaboom mygame
109
+ ```
110
+
111
+ This will create a directory called `mygame` for you, containing all the files we need
112
+
113
+ ```sh
114
+ $ cd mygame
115
+ $ npm run dev
116
+ ```
117
+
118
+ Then open http://localhost:5173 and edit `src/game.js`
119
+
120
+ ### Install as NPM Package
121
+
122
+ ```sh
123
+ $ npm install kaboom
124
+ ```
125
+
126
+ ```js
127
+ import kaboom from "kaboom"
128
+
129
+ kaboom()
130
+
131
+ add([
132
+ text("oh hi"),
133
+ pos(80, 40),
134
+ ])
135
+ ```
136
+
137
+ also works with CommonJS
138
+
139
+ ```js
140
+ const kaboom = require("kaboom")
141
+ ```
142
+
143
+ Note that you'll need to use a bundler like `esbuild` or `webpack` to use Kaboom with NPM
144
+
145
+ ### Browser CDN
146
+
147
+ This exports a global `kaboom` function
148
+
149
+ ```html
150
+ <script src="https://unpkg.com/kaboom@3000/dist/kaboom.js"></script>
151
+ <script>
152
+ kaboom()
153
+ </script>
154
+ ```
155
+
156
+ or use with es modules
157
+
158
+ ```html
159
+ <script type="module">
160
+ import kaboom from "https://unpkg.com/kaboom@3000/dist/kaboom.mjs"
161
+ kaboom()
162
+ </script>
163
+ ```
164
+
165
+ works all CDNs that supports NPM packages, e.g. jsdelivr, skypack
166
+
167
+ ## Documentation
168
+ - **v3000**: https://kaboomjs.com/
169
+ - **v2000**: https://2000.kaboomjs.com/
170
+ - **v0.5.0**: https://legacy.kaboomjs.com/
171
+
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/replit/kaboom/discussions)
186
+ - [Twitter](https://twitter.com/Kaboomjs)
187
+
188
+ ### Games
189
+ Collection of games made with Kaboom, selected by Kaboom, [here](https://itch.io/c/2645141/made-in-kaboom).
190
+
191
+ - [on Itch.io](https://itch.io/games/tag-kaboomjs)
192
+ - [on Replit](https://replit.com/apps/kaboom)
193
+ - [on Newgrounds](https://www.newgrounds.com/search/conduct/games?tags=kaboomjs)
194
+
195
+ ## Misc
196
+
197
+ - This project has no relation to Activision's game [Kaboom!](https://en.wikipedia.org/wiki/Kaboom!_(video_game))
198
+ - Thanks to [lajbel](https://lajbel.github.io/) for help building the Kaboom community
199
+ - Thanks to [abrudz](https://github.com/abrudz) for the amazing [APL386 font](https://abrudz.github.io/APL386/)
200
+ - Thanks to [Polyducks](http://polyducks.co.uk/) for the amazing [kitchen sink font](https://polyducks.itch.io/kitchen-sink-textmode-font) font
201
+ - Thanks to [0x72](https://0x72.itch.io/) for the amazing [Dungeon Tileset](https://0x72.itch.io/dungeontileset-ii)
202
+ - Thanks to [Kenney](https://kenney.nl/) for the amazing [1-Bit Platformer Pack](https://kenney.nl/assets/1-bit-platformer-pack)
203
+ - Thanks to [mulfok](https://twitter.com/MulfoK) for the amazing [mulfok32](https://lospec.com/palette-list/mulfok32) color palette
204
+ - Find bitmap fonts: [Oldschool PC Font](https://int10h.org/oldschool-pc-fonts)
205
+ - Featured on [Console 50](https://console.substack.com/p/console-50)
206
+ - Thanks to [Umayr](https://github.com/umayr) for kindly offering the "kaboom" npm package name
207
+ - Please buy fireworks on [kaboom.com](http://www.kaboom.com/)
208
+ - [How to do a KABOOM on a Trampoline](https://www.youtube.com/watch?v=3CemcWdc_Hc)
@@ -0,0 +1,244 @@
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 loadMusic: KaboomCtx["loadMusic"]
89
+ const loadFont: KaboomCtx["loadFont"]
90
+ const loadBitmapFont: KaboomCtx["loadBitmapFont"]
91
+ const loadShader: KaboomCtx["loadShader"]
92
+ const loadShaderURL: KaboomCtx["loadShaderURL"]
93
+ const load: KaboomCtx["load"]
94
+ const loadProgress: KaboomCtx["loadProgress"]
95
+ const getSprite: KaboomCtx["getSprite"]
96
+ const getSound: KaboomCtx["getSound"]
97
+ const getFont: KaboomCtx["getFont"]
98
+ const getBitmapFont: KaboomCtx["getBitmapFont"]
99
+ const getShader: KaboomCtx["getShader"]
100
+ const getAsset: KaboomCtx["getAsset"]
101
+ const Asset: KaboomCtx["Asset"]
102
+ const SpriteData: KaboomCtx["SpriteData"]
103
+ const SoundData: KaboomCtx["SoundData"]
104
+ const width: KaboomCtx["width"]
105
+ const height: KaboomCtx["height"]
106
+ const center: KaboomCtx["center"]
107
+ const dt: KaboomCtx["dt"]
108
+ const time: KaboomCtx["time"]
109
+ const isFocused: KaboomCtx["isFocused"]
110
+ const isTouchscreen: KaboomCtx["isTouchscreen"]
111
+ const mousePos: KaboomCtx["mousePos"]
112
+ const mouseDeltaPos: KaboomCtx["mouseDeltaPos"]
113
+ const isKeyDown: KaboomCtx["isKeyDown"]
114
+ const isKeyPressed: KaboomCtx["isKeyPressed"]
115
+ const isKeyPressedRepeat: KaboomCtx["isKeyPressedRepeat"]
116
+ const isKeyReleased: KaboomCtx["isKeyReleased"]
117
+ const isMouseDown: KaboomCtx["isMouseDown"]
118
+ const isMousePressed: KaboomCtx["isMousePressed"]
119
+ const isMouseReleased: KaboomCtx["isMouseReleased"]
120
+ const isMouseMoved: KaboomCtx["isMouseMoved"]
121
+ const isGamepadButtonPressed: KaboomCtx["isGamepadButtonPressed"]
122
+ const isGamepadButtonDown: KaboomCtx["isGamepadButtonDown"]
123
+ const isGamepadButtonReleased: KaboomCtx["isGamepadButtonReleased"]
124
+ const getGamepadStick: KaboomCtx["getGamepadStick"]
125
+ const charInputted: KaboomCtx["charInputted"]
126
+ const shake: KaboomCtx["shake"]
127
+ const camPos: KaboomCtx["camPos"]
128
+ const camScale: KaboomCtx["camScale"]
129
+ const camRot: KaboomCtx["camRot"]
130
+ const toScreen: KaboomCtx["toScreen"]
131
+ const toWorld: KaboomCtx["toWorld"]
132
+ const setGravity: KaboomCtx["setGravity"]
133
+ const getGravity: KaboomCtx["getGravity"]
134
+ const setBackground: KaboomCtx["setBackground"]
135
+ const getBackground: KaboomCtx["getBackground"]
136
+ const getGamepads: KaboomCtx["getGamepads"]
137
+ const setCursor: KaboomCtx["setCursor"]
138
+ const getCursor: KaboomCtx["getCursor"]
139
+ const setCursorLocked: KaboomCtx["setCursorLocked"]
140
+ const isCursorLocked: KaboomCtx["isCursorLocked"]
141
+ const setFullscreen: KaboomCtx["setFullscreen"]
142
+ const isFullscreen: KaboomCtx["isFullscreen"]
143
+ const wait: KaboomCtx["wait"]
144
+ const loop: KaboomCtx["loop"]
145
+ const play: KaboomCtx["play"]
146
+ const burp: KaboomCtx["burp"]
147
+ const volume: KaboomCtx["volume"]
148
+ const audioCtx: KaboomCtx["audioCtx"]
149
+ const rand: KaboomCtx["rand"]
150
+ const randi: KaboomCtx["randi"]
151
+ const randSeed: KaboomCtx["randSeed"]
152
+ const vec2: KaboomCtx["vec2"]
153
+ const rgb: KaboomCtx["rgb"]
154
+ const hsl2rgb: KaboomCtx["hsl2rgb"]
155
+ const quad: KaboomCtx["quad"]
156
+ const choose: KaboomCtx["choose"]
157
+ const chooseMultiple: KaboomCtx["chooseMultiple"]
158
+ const shuffle: KaboomCtx["shuffle"]
159
+ const chance: KaboomCtx["chance"]
160
+ const lerp: KaboomCtx["lerp"]
161
+ const tween: KaboomCtx["tween"]
162
+ const easings: KaboomCtx["easings"]
163
+ const map: KaboomCtx["map"]
164
+ const mapc: KaboomCtx["mapc"]
165
+ const wave: KaboomCtx["wave"]
166
+ const deg2rad: KaboomCtx["deg2rad"]
167
+ const rad2deg: KaboomCtx["rad2deg"]
168
+ const clamp: KaboomCtx["clamp"]
169
+ const evaluateBezier: KaboomCtx["evaluateBezier"]
170
+ const testLinePoint: KaboomCtx["testLinePoint"]
171
+ const testLineLine: KaboomCtx["testLineLine"]
172
+ const testLineCircle: KaboomCtx["testLineCircle"]
173
+ const testRectRect: KaboomCtx["testRectRect"]
174
+ const testRectLine: KaboomCtx["testRectLine"]
175
+ const testRectPoint: KaboomCtx["testRectPoint"]
176
+ const testCirclePolygon: KaboomCtx["testCirclePolygon"]
177
+ const Line: KaboomCtx["Line"]
178
+ const Rect: KaboomCtx["Rect"]
179
+ const Circle: KaboomCtx["Circle"]
180
+ const Ellipse: KaboomCtx["Ellipse"]
181
+ const Polygon: KaboomCtx["Polygon"]
182
+ const Vec2: KaboomCtx["Vec2"]
183
+ const Color: KaboomCtx["Color"]
184
+ const Mat4: KaboomCtx["Mat4"]
185
+ const Quad: KaboomCtx["Quad"]
186
+ const RNG: KaboomCtx["RNG"]
187
+ const scene: KaboomCtx["scene"]
188
+ const go: KaboomCtx["go"]
189
+ const addLevel: KaboomCtx["addLevel"]
190
+ const getData: KaboomCtx["getData"]
191
+ const setData: KaboomCtx["setData"]
192
+ const drawSprite: KaboomCtx["drawSprite"]
193
+ const drawText: KaboomCtx["drawText"]
194
+ const drawRect: KaboomCtx["drawRect"]
195
+ const drawLine: KaboomCtx["drawLine"]
196
+ const drawLines: KaboomCtx["drawLines"]
197
+ const drawCurve: KaboomCtx["drawCurve"]
198
+ const drawBezier: KaboomCtx["drawBezier"]
199
+ const drawTriangle: KaboomCtx["drawTriangle"]
200
+ const drawCircle: KaboomCtx["drawCircle"]
201
+ const drawEllipse: KaboomCtx["drawEllipse"]
202
+ const drawPolygon: KaboomCtx["drawPolygon"]
203
+ const drawUVQuad: KaboomCtx["drawUVQuad"]
204
+ const drawFormattedText: KaboomCtx["drawFormattedText"]
205
+ const drawMasked: KaboomCtx["drawMasked"]
206
+ const drawSubtracted: KaboomCtx["drawSubtracted"]
207
+ const pushTransform: KaboomCtx["pushTransform"]
208
+ const popTransform: KaboomCtx["popTransform"]
209
+ const pushTranslate: KaboomCtx["pushTranslate"]
210
+ const pushScale: KaboomCtx["pushScale"]
211
+ const pushRotate: KaboomCtx["pushRotate"]
212
+ const pushMatrix: KaboomCtx["pushMatrix"]
213
+ const usePostEffect: KaboomCtx["usePostEffect"]
214
+ const formatText: KaboomCtx["formatText"]
215
+ const makeCanvas: KaboomCtx["makeCanvas"]
216
+ const debug: KaboomCtx["debug"]
217
+ const plug: KaboomCtx["plug"]
218
+ const screenshot: KaboomCtx["screenshot"]
219
+ const download: KaboomCtx["download"]
220
+ const downloadText: KaboomCtx["downloadText"]
221
+ const downloadJSON: KaboomCtx["downloadJSON"]
222
+ const downloadBlob: KaboomCtx["downloadBlob"]
223
+ const record: KaboomCtx["record"]
224
+ const addKaboom: KaboomCtx["addKaboom"]
225
+ const ASCII_CHARS: KaboomCtx["ASCII_CHARS"]
226
+ const LEFT: KaboomCtx["LEFT"]
227
+ const RIGHT: KaboomCtx["RIGHT"]
228
+ const UP: KaboomCtx["UP"]
229
+ const DOWN: KaboomCtx["DOWN"]
230
+ const RED: KaboomCtx["RED"]
231
+ const GREEN: KaboomCtx["GREEN"]
232
+ const BLUE: KaboomCtx["BLUE"]
233
+ const YELLOW: KaboomCtx["YELLOW"]
234
+ const MAGENTA: KaboomCtx["MAGENTA"]
235
+ const CYAN: KaboomCtx["CYAN"]
236
+ const WHITE: KaboomCtx["WHITE"]
237
+ const BLACK: KaboomCtx["BLACK"]
238
+ const canvas: KaboomCtx["canvas"]
239
+ const quit: KaboomCtx["quit"]
240
+ const Event: KaboomCtx["Event"]
241
+ const EventHandler: KaboomCtx["EventHandler"]
242
+ const EventController: KaboomCtx["EventController"]
243
+ const VERSION: KaboomCtx["VERSION"]
244
+ }
package/dist/global.js ADDED
File without changes