Skip to content

Commit 9e9c1a0

Browse files
authored
develop to master v0.3.5 (#6)
* Update README.md add wiki link * Update README.md * Update README.md * update README, lots of new info * cleaning up main and adding comments, setting up library components * more README updates * add import path aliases, minor tweaks * v0.3.5 * fix serializejs vulnerability * more package maintenance
1 parent ecb115a commit 9e9c1a0

File tree

19 files changed

+645
-1431
lines changed

19 files changed

+645
-1431
lines changed

README.md

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,64 @@
11
### Bootstrapped with DCollage (Digital Collage Boilerplate w/ PIXIJS)
22

3-
The goal of DCollage is to facilitate the creation of multi-layered, interactive, collages similar to those I created back in the days of Flash. Surprise it works for simple games too!
3+
DCollage is a lightly opinionated PIXIJS based digital collage boilerplate with game dev aspirations and a component driven paradigm written in TypeScript.
44

5-
# Project Title
5+
The goal of DCollage is to facilitate the creation of multi-layered, interactive, collages similar to those I created back in the days of Flash. Surprise it works for simple games too! [See the repo WIKI for additional information.](https://github.com/jrod-disco/dcollage-pixijs-boilerplate/wiki)
66

7-
Project description may appear here.
7+
The section of the README below can be used to bootstrap your project readme or removed when you use this template.
8+
9+
# Your Project Title
10+
11+
Your project description may appear here.
12+
13+
# Getting Started
14+
15+
DCollage is meant to get you up and running with a PIXI app in minutes. While there are a lot of nuances that can be tweaked and you are not forced to follow the patterns this boilerplate includes it should be a matter of clone, install, run.
16+
17+
## Clone or Template
18+
19+
- Clone or spin up a new repo using the github template `https://github.com/jrod-disco/dcollage-pixijs-boilerplate.git`
20+
21+
## Install and Run
22+
23+
- Run `yarn install` at the project root to install all of the `node_modules`
24+
- Run `yarn start` to begin developing locally `http://localhost:10001/`
25+
26+
## Have Fun!
27+
28+
- Edit `main.ts` to add or remove components from the main container there will be a handful of `_prebuilt` example components included to help you get started
29+
- Put your assets in `./src/assets` and add anything you want to preload to the `preloader` at the bottom of `main.ts`
30+
- Use any of the `_prebuilt` components, or make your own
31+
32+
## DCollage Prebuilt Components
33+
34+
- Components should be barreled up into a single `COMP` import, in addition "prebuilt componenents" that come with the boilerplate are double-barreled (shame on me) and available via `COMP.LIB`
35+
- if you follow this pattern you can create a new component by:
36+
37+
`const newComponent = COMP.LIB.prebuiltComponentName({prebuiltComponentPropsObject})`
38+
39+
or for a component you've created outside of the library:
40+
41+
`const myNewComponent = COMP.myComponentName({myComponentPropsObject})`
42+
43+
- The component function will return a module object which will include a `container` for components that have a visual aspect
44+
- Add this container to the existing `mainContainer` or any container you create like so:
45+
46+
`mainContainer.addChild(newComponent.container);`
47+
48+
- This allows for components to have a discreet "rendered" container as well as any logic and exposed functions the returned module object has available
49+
- It is key to note that components are functional modules rather than classes but this doesn't mean you couldn't use classes if you wanted to. See for more info: [The Revealing Module Pattern in Javascript](https://gist.github.com/zcaceres/bb0eec99c02dda6aac0e041d0d4d7bf2)
50+
51+
## Eventing and Application Access
52+
53+
- Currently events are all handled via callbacks; this has been sufficient for basic projects but a more robust pub-sub/eventBus is on the roadmap
54+
- At times you may want/need to access the PIXI Application instance; in this case you can tweak the bootstrapping function to `window.APP = bootstrapApp({ spriteSheets, sounds });` exposing the `APP` in the global space via window; this is helpful in the event that you want to freeze the app, say for a game PAUSE or something `window.APP.stop();` from within a nested component
55+
56+
# Build Scripts
57+
58+
- `yarn start` to go into development mode with live reload
59+
- `yarn clean` to clean the `/dist` directory
60+
- `yarn build` to create a distributable bundle in `/dist`
61+
- `yarn docs` to generate markdown documentation in `/docs`
862

963
## Concept and Mechanics
1064

@@ -27,9 +81,10 @@ Nothing yet
2781

2882
## Libraries Used
2983

84+
- DCollage Boilerplate [https://github.com/jrod-disco/dcollage-pixijs-boilerplate](https://github.com/jrod-disco/dcollage-pixijs-boilerplate)
3085
- PIXIJS - WebGL renderer with Canvas fallback and so much more [https://github.com/pixijs/pixi.js](https://github.com/pixijs/pixi.js)
31-
- pixi-filters - Collection of community-authored custom display filters for PixiJS [https://github.com/pixijs/pixi-filters](https://github.com/pixijs/pixi-filters) Currently yarn linked to a local version of the repo in order to use the as of yet un-merged changes to the godray filter which add alpha functionality.
3286
- GSAP - tween animation library [https://greensock.com/docs/v2/Plugins/PixiPlugin](https://greensock.com/docs/v2/Plugins/PixiPlugin)
87+
- pixi-filters - Collection of community-authored custom display filters for PixiJS [https://github.com/pixijs/pixi-filters](https://github.com/pixijs/pixi-filters) Currently yarn linked to a local version of the repo in order to use the as of yet un-merged changes to the godray filter which add alpha functionality.
3388

3489
## Tools Used
3590

@@ -39,13 +94,6 @@ Nothing yet
3994
- Audacity
4095
- Reason
4196

42-
# Build Scripts
43-
44-
- `yarn start` to go into development mode with live reload
45-
- `yarn clean` to clean the `/dist` directory
46-
- `yarn build` to create a distributable bundle in `/dist`
47-
- `yarn docs` to generate markdown documentation in `/docs`
48-
4997
# The Stack
5098

5199
- Pixi.JS

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dcollage",
3-
"version": "0.2.0",
3+
"version": "0.3.5",
44
"description": "A digital collage boilerplate.",
55
"main": "main.js",
66
"repository": "https://github.com/jrod-disco/dcollage",
@@ -10,32 +10,33 @@
1010
"devDependencies": {
1111
"@microsoft/tsdoc": "^0.12.19",
1212
"@pixi/filter-shockwave": "^3.1.1",
13-
"@rollup/plugin-json": "^4.1.0",
13+
"@rollup/plugin-commonjs": "^15.0.0",
1414
"@rollup/plugin-node-resolve": "^7.1.1",
1515
"@rollup/plugin-replace": "^2.3.3",
1616
"@typescript-eslint/eslint-plugin": "2.34.0",
1717
"@typescript-eslint/parser": "2.34.0",
18+
"@zerollup/ts-transform-paths": "^1.7.18",
1819
"eslint": "^6.8.0",
19-
"gsap": "^3.2.5",
20+
"gsap": "^3.5.0",
2021
"pixi-particles": "^4.2.1",
2122
"pixi-sound": "^3.0.4",
2223
"pixi.js": "5.2.0",
23-
"prettier": "^2.0.1",
24+
"prettier": "^2.0.5",
2425
"rimraf": "^3.0.2",
25-
"rollup": "^2.1.0",
26-
"rollup-plugin-commonjs": "^10.1.0",
26+
"rollup": "^2.26.4",
2727
"rollup-plugin-copy": "^3.3.0",
28-
"rollup-plugin-html2": "^1.0.0",
28+
"rollup-plugin-html2": "^2.0.0",
2929
"rollup-plugin-livereload": "^1.1.0",
3030
"rollup-plugin-scss": "^2.1.0",
31-
"rollup-plugin-serve": "^1.0.1",
32-
"rollup-plugin-terser": "^5.3.0",
33-
"rollup-plugin-typescript2": "^0.26.0",
31+
"rollup-plugin-serve": "^1.0.3",
32+
"rollup-plugin-terser": "^7.0.0",
33+
"rollup-plugin-typescript2": "^0.27.2",
3434
"sass": "^1.26.3",
35-
"tslib": "^2.0.0",
35+
"tslib": "^2.0.1",
36+
"ttypescript": "^1.5.10",
3637
"typedoc": "^0.17.6",
3738
"typedoc-plugin-markdown": "^2.2.17",
38-
"typescript": "3.9.7"
39+
"typescript": "4.0.2"
3940
},
4041
"dependencies": {},
4142
"scripts": {

rollup.config.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import scss from 'rollup-plugin-scss';
33
import serve from 'rollup-plugin-serve';
44
import livereload from 'rollup-plugin-livereload';
55
import typescript from 'rollup-plugin-typescript2';
6-
import commonjs from 'rollup-plugin-commonjs';
7-
import json from '@rollup/plugin-json';
6+
import commonjs from '@rollup/plugin-commonjs';
87
import resolve from '@rollup/plugin-node-resolve';
98
import replace from '@rollup/plugin-replace';
109
import copy from 'rollup-plugin-copy';
1110
import { terser } from 'rollup-plugin-terser';
11+
import ttypescript from 'ttypescript';
1212

1313
import pkg from './package.json';
1414

@@ -27,18 +27,15 @@ export default [
2727
},
2828
},
2929
],
30-
3130
plugins: [
3231
resolve({ base: 'src', browser: true, preferBuiltins: false }),
3332
replace({
3433
__VERSION__: JSON.stringify(pkg.version),
3534
}),
36-
typescript({}),
37-
commonjs({
38-
namedExports: {
39-
'node_modules/pixi.js/lib/pixi.es.js': ['sound'],
40-
},
35+
typescript({
36+
typescript: ttypescript,
4137
}),
38+
commonjs({}),
4239
scss(),
4340
html({ template: './src/index.html', inject: false }),
4441
isProd && terser(),

src/assets/example/example.mp3

643 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.
-1.04 MB
Binary file not shown.

src/components/example/index.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/components/aComponentBoilerplate/index.ts renamed to src/components/exampleComponent/index.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,30 @@ interface ComponentProps {
1717
*
1818
* @returns Interface object containing methods that can be called on this module
1919
*/
20-
export const component = (props: ComponentProps): Component => {
20+
export const exampleComponent = (props: ComponentProps): Component => {
2121
const pos = props.pos ?? { x: 0, y: 0 };
2222
const container = new PIXI.Container();
2323
container.x = pos.x;
2424
container.y = pos.y;
2525

26-
container.name = 'component name';
26+
container.name = 'exampleComponent';
2727

2828
let state = {};
2929
const initialState = { ...state };
3030

31-
// const texture = PIXI.Texture.from('./assets/coin.png');
32-
// const sprite = new PIXI.Sprite(texture);
33-
// sprite.anchor.set(0.5);
34-
// container.addChild(sprite);
31+
// Text
32+
const textStyle = new PIXI.TextStyle({
33+
fontFamily: 'Impact, Charcoal, sans-serif',
34+
fontSize: 21,
35+
fontWeight: 'bold',
36+
fill: ['#fff'],
37+
align: 'center',
38+
});
39+
40+
const sampleText = new PIXI.Text('DCollage', textStyle);
41+
sampleText.anchor.set(0.5, 0);
42+
43+
container.addChild(sampleText);
3544

3645
// Reset called by play again and also on init
3746
const reset = (): void => {

src/components/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
* Barrel file for all component modules
2+
* Barrel up our components for easy access
33
*/
4-
export { audio } from './audio';
5-
export { btnSample } from './buttons';
6-
export { runtime } from './runtime';
7-
export { bestScoreDisplay } from './bestScoreDisplay';
84

9-
// TODO Extract components such that they can be added/removed separate from the dCollage Boilerplate itself
5+
// Prebuilt Components Library
6+
export * as LIB from './library';
7+
8+
// Your Components
9+
export { exampleComponent } from './exampleComponent';

0 commit comments

Comments
 (0)