Skip to content

Commit

Permalink
Chore: Cleanup scripts, build tooling (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtimebuddy authored Apr 13, 2024
1 parent db40858 commit 5893d3b
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 104 deletions.
13 changes: 0 additions & 13 deletions .eslintrc.cjs

This file was deleted.

12 changes: 10 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"extends": "@pixi/eslint-config"
}
"root": true,
"extends": ["@pixi/eslint-config"],
"rules": {
"linebreak-style": "off",
"camelcase": "off"
},
"ignorePatterns": [
"dist"
]
}
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Automation
on:
push:
branches: [ '**' ]
tags: [ '**' ]
release:
types: [ published ]
pull_request:
branches: [ '**' ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install xvfb
run: sudo apt-get install xvfb
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Test
run: xvfb-run --auto-servernum npm test
- name: Upload to Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: dist/*
34 changes: 0 additions & 34 deletions .github/workflows/node.js.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ lib

# Intellij
*.iml
example.api.json*
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ enough manner.

### Basic demo :pen:

[webgl](https://pixijs.github.io/tilemap/basic.html)
[webgl](https://pixijs.io/tilemap/examples/basic.html)

### Settings :page_facing_up:

Expand Down Expand Up @@ -82,11 +82,11 @@ Canvas fallback is 5x slower than vanilla rpgmaker. Webgl version is faster and

### RPGMaker demo

[webgl](https://pixijs.github.io/tilemap/): [zoomin](https://pixijs.github.io/tilemap/?scale=0.6) and [zoomout](https://pixijs.github.io/tilemap/?scale=1.4)
[webgl](https://pixijs.io/tilemap/examples/): [zoomin](https://pixijs.io/tilemap/examples/?scale=0.6) and [zoomout](https://pixijs.io/tilemap/examples/?scale=1.4)

[retina webgl](https://pixijs.github.io/tilemap/?resolution=2): [zoomin](https://pixijs.github.io/pixi-tilemap/?resolution=2&scale=0.6) and [zoomout](https://pixijs.github.io/pixi-tilemap/?resolution=2&scale=1.4)
[retina webgl](https://pixijs.io/tilemap/examples/?resolution=2): [zoomin](https://pixijs.io/tilemap/examples/?resolution=2&scale=0.6) and [zoomout](https://pixijs.io/tilemap/?resolution=2&scale=1.4)

[canvas](https://pixijs.github.io/tilemap/?canvas)
[canvas](https://pixijs.io/tilemap/examples/?canvas)

## More tutorials :link:

Expand Down
1 change: 0 additions & 1 deletion examples/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<title>PIXI-TILEMAP minimal test</title>
<link type="text/css" media="all" rel="stylesheet" href="css/main.css"/>
<script src="https://pixijs.download/dev/pixi.js"></script>
<!-- <script src="lib/pixi.js"></script>-->
<script src="../dist/pixi-tilemap.js"></script>
</head>
<body>
Expand Down
38 changes: 24 additions & 14 deletions examples/demo/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,29 @@ const use_webgpu = new URLSearchParams(window.location.search).get('webgpu') !==
document.body.appendChild(app.canvas);
app.stage.addChild(tilemap);

const loadAssets = async () => {
const loadAssets = async () =>
{
PIXI.Assets.add({ alias: 'atlas', src: 'assets/atlas.json' });
PIXI.Assets.add({ alias: 'button', src: 'assets/button.png' });
await PIXI.Assets.load(['atlas', 'button']);
};

const buildTilemap = () => {
const buildTilemap = () =>
{
// Clear everything, like a PIXI.Graphics
tilemap.clear();

const size = 32;

// if you are too lazy, just specify filename and pixi will find it in cache
for (let i = 0; i < 7; i++) {
for (let j = 0; j < 5; j++) {
for (let i = 0; i < 7; i++)
{
for (let j = 0; j < 5; j++)
{
tilemap.tile('grass.png', i * size, j * size);

if (i % 2 === 1 && j % 2 === 1) {
if (i % 2 === 1 && j % 2 === 1)
{
tilemap.tile('tough.png', i * size, j * size);
}
}
Expand All @@ -43,7 +48,7 @@ const use_webgpu = new URLSearchParams(window.location.search).get('webgpu') !==
const textures = PIXI.Assets.get('atlas').textures;

tilemap.tile(textures['brick.png'], 2 * size, 2 * size);
tilemap.tile(textures['brick_wall.png'], 2 * size, 3 * size, {alpha: 0.6});
tilemap.tile(textures['brick_wall.png'], 2 * size, 3 * size, { alpha: 0.6 });

// chest will be animated!
// old way: animate on rebuild
Expand All @@ -59,10 +64,10 @@ const use_webgpu = new URLSearchParams(window.location.search).get('webgpu') !==
// 3 multiplies the 100ms we have in setInterval by 3, making the duration 300ms
tilemap.tile(textures['chest.png'], 5 * size, 4 * size).tileAnimX(34, 2).tileAnimDivisor(3);
// You can alternatively set it by passing animDivisor option when creating the tile. Below a frame duration is 600ms
tilemap.tile(textures['chest.png'], 8 * size, 4 * size, {animX: 34, animCountX: 2, animDivisor: 6});
tilemap.tile(textures['chest.png'], 8 * size, 4 * size, { animX: 34, animCountX: 2, animDivisor: 6 });

// button does not appear in the atlas, but tilemap wont surrender, it will create second layer for special for buttons
// buttons will appear above everything
// button does not appear in the atlas, but tilemap wont surrender, it will
// create second layer for special for buttons buttons will appear above everything
tilemap.tile(PIXI.Assets.get('button'), 6 * size, 2 * size);

// if you want rotations:
Expand All @@ -71,13 +76,15 @@ const use_webgpu = new URLSearchParams(window.location.search).get('webgpu') !==
// canvas in pixi-tilemap does not work with rotate!!!!
const origTex = textures['chest.png'];

for (let i = 0; i < 8; i++) {
for (let i = 0; i < 8; i++)
{
const frame = origTex.frame.clone();
const orig = origTex.orig.clone();
const trim = origTex.orig.clone();
const rotate = i * 2;

if (rotate % 4 === 2) {
if (rotate % 4 === 2)
{
orig.width = frame.height;
orig.height = frame.width;
}
Expand All @@ -90,7 +97,8 @@ const use_webgpu = new URLSearchParams(window.location.search).get('webgpu') !==
}
};

const initialize = () => {
const initialize = () =>
{
buildTilemap();

const pic = new PIXI.Sprite(PIXI.Assets.get('button'));
Expand All @@ -99,7 +107,8 @@ const use_webgpu = new URLSearchParams(window.location.search).get('webgpu') !==
app.stage.addChild(pic);

let frame = 0;
const animShader = () => {
const animShader = () =>
{
// animate X and Y frames
tilemap.tileAnim = [frame, frame];
frame++;
Expand All @@ -111,7 +120,8 @@ const use_webgpu = new URLSearchParams(window.location.search).get('webgpu') !==
setInterval(animShader, 100);
};

const runApp = async () => {
const runApp = async () =>
{
await loadAssets();
initialize();
};
Expand Down
1 change: 0 additions & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
}
</style>
<script src="https://pixijs.download/dev/pixi.js"></script>
<!-- <script src="lib/pixi.js"></script>-->
<script src="../dist/pixi-tilemap.js"></script>
<script src="demo/rpgmaker.js"></script>
<script src="demo/main.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"release": "xs release",
"docs": "xs docs",
"deploy": "xs deploy",
"test": "xs build,docs"
"test": "xs test"
},
"files": [
"lib",
Expand Down Expand Up @@ -69,12 +69,6 @@
"docsGoogleAnalytics": "UA-103772589-3",
"docsTitle": "PixiJS Tilemap API Documentation",
"docsDescription": "Documentation for PixiJS Tilemap library",
"docsKeyword": "docs, documentation, pixi, pixijs, filters, webgl, ascii, bloom, convolution, cross-hatch, dotfilter, emboss, pixelate, twist, tiltshift",
"lint": [
"src",
"scripts"
],
"deployFiles": "{dist,screenshots,examples,docs,demo}/**",
"moduleSource": "src/index.ts"
"docsKeyword": "docs, documentation, pixi, pixijs, filters, webgl, ascii, bloom, convolution, cross-hatch, dotfilter, emboss, pixelate, twist, tiltshift"
}
}
19 changes: 8 additions & 11 deletions test/Tilemap.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import { describe, it, expect } from 'vitest';
import { BaseTexture, Texture } from '@pixi/core';
import { Texture } from 'pixi.js';
import { Tilemap } from '../';

describe('Tilemap', () =>
{
it('should calculate local bounds', () =>
{
const texture = new Texture(new BaseTexture(null, {
width: 100,
height: 100,
}));
const tilemap = new Tilemap([texture.baseTexture]);
const canvas = Object.assign(document.createElement('canvas'), { width: 100, height: 100 });
const texture = Texture.from(canvas);
const tilemap = new Tilemap([texture.source]);

tilemap.tile(texture, 0, 0);
tilemap.tile(texture, 100, 0);

const bounds = tilemap.getLocalBounds();

expect(bounds.x).to.equal(0);
expect(bounds.y).to.equal(0);
expect(bounds.width).to.equal(200);
expect(bounds.height).to.equal(100);
expect(bounds.x).toEqual(0);
expect(bounds.y).toEqual(0);
expect(bounds.width).toEqual(200);
expect(bounds.height).toEqual(100);
});
});
19 changes: 6 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
{
"extends": "@pixi/extension-scripts/tsconfig",
"compilerOptions": {
"target": "es6",
"noImplicitAny": true,
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"inlineSources": true,
"declaration": true,
"esModuleInterop": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
// TODO: Remove this when null checks are strict
"strictNullChecks": false
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules/**/*",
"dist"
"node_modules",
"dist",
"lib"
]
}

0 comments on commit 5893d3b

Please sign in to comment.