Skip to content

Commit

Permalink
fully lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Dec 11, 2024
1 parent d1f376d commit 2ac2443
Show file tree
Hide file tree
Showing 83 changed files with 7,226 additions and 5,650 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
wormgine
--------
## wormgine

*Everything, including the name is subject to change.*
_Everything, including the name is subject to change._

This project started off as an attempt to clone Worms Armageddon for the browser,
however for a few reasons the plan has changed. This will hopefully be an entirely
Expand Down Expand Up @@ -53,4 +52,4 @@ This is far less fleshed out than other sections of the game due to frontloading

The terrain system works by being given a Texture (which is then rendered to a canvas as a bitmap), and then breaking the alpha
channel down into a quadtree. As the map is damanged, the bitmap is altered and the quadtree is re-rendered. The system is somewhat
crude but performance is reasonable.
crude but performance is reasonable.
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
"dev": "VITE_BUILD_COMMIT=`git log --pretty=format:'%h' -n 1` VITE_DEFAULT_HOMESERVER=http://localhost:8008 vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint src/",
"lint:eslint": "eslint src/",
"test": "jest",
"assets": "node scripts/generateAssetManifest.mjs > src/assets/manifest.ts"
"assets": "node scripts/generateAssetManifest.mjs > src/assets/manifest.ts",
"lint:prettier": "prettier 'src/**/*.(ts|tsx|md)' '*.md' -w",
"lint": "yarn lint:eslint && yarn lint:prettier"
},
"dependencies": {
"@dimforge/rapier2d-compat": "^0.14.0",
"@pixi/sound": "^6.0.1",
"matrix-js-sdk": "^34.8.0",
"pixi-viewport": "^5.0.3",
"pixi.js": "^8.5.1",
"preact": "^10.24.3"
"preact": "^10.24.3",
"prettier": "^3.4.2"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
Expand Down
29 changes: 29 additions & 0 deletions src/@types/matrix-js-sdk.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2024 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import {
GameConfigEvent,
GameConfigEventType,
GameStageEvent,
GameStageEventType,
FullGameStateEvent,
PlayerAckEvent,
PlayerAckEventType,
GameStateEventType,
} from "../net/models";

// Extend Matrix JS SDK types via Typescript declaration merging to support unspecced event fields and types
declare module "matrix-js-sdk" {
export interface StateEvents {
[GameConfigEventType]: GameConfigEvent["content"];
[GameStageEventType]: GameStageEvent["content"];
}
export interface TimelineEvents {
[PlayerAckEventType]: PlayerAckEvent["content"];
[GameStateEventType]: FullGameStateEvent["content"];
}
}
42 changes: 21 additions & 21 deletions src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ let textures: Record<string, Texture>;
let sounds: Record<string, Sound>;

export async function loadAssets(progressFn: (totalProgress: number) => void) {
await Assets.init({ manifest });
await Assets.init({ manifest });

const bundleCount = Object.keys(manifest.bundles).length;
let bundleIndex = 0;
for (const {name} of manifest.bundles) {
const bundle = await Assets.loadBundle(name, (progress) => {
const totalProgress = bundleIndex/bundleCount + (progress / bundleCount);
progressFn(totalProgress);
});
bundleIndex++;
if (name === 'textures') {
textures = bundle;
} else if (name === 'sounds') {
sounds = bundle;
}
const bundleCount = Object.keys(manifest.bundles).length;
let bundleIndex = 0;
for (const { name } of manifest.bundles) {
const bundle = await Assets.loadBundle(name, (progress) => {
const totalProgress = bundleIndex / bundleCount + progress / bundleCount;
progressFn(totalProgress);
});
bundleIndex++;
if (name === "textures") {
textures = bundle;
} else if (name === "sounds") {
sounds = bundle;
}
}
}

export function getAssets() {
if (!textures || !sounds) {
throw Error('Assets not preloaded');
}
return {
textures: textures as unknown as AssetTextures,
sounds: sounds as unknown as AssetSounds
}
if (!textures || !sounds) {
throw Error("Assets not preloaded");
}
return {
textures: textures as unknown as AssetTextures,
sounds: sounds as unknown as AssetSounds,
};
}

export type AssetPack = ReturnType<typeof getAssets>;
21 changes: 10 additions & 11 deletions src/assets/ASSETS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@

#### Sounds provided by https://gameburp.itch.io:

- `explosion_1.ogg`
- `explosion_2.ogg`
- `explosion_3.ogg`
- `metal_bounce_heavy.ogg`
- `metal_bounce_light.ogg`
- `explosion_1.ogg`
- `explosion_2.ogg`
- `explosion_3.ogg`
- `metal_bounce_heavy.ogg`
- `metal_bounce_light.ogg`

These are provided under a commercial licence and will need removing prior to the game being open sourced.


#### Sounds provided by https://pixabay.com

- `splash.ogg`
- `firework.ogg`
- `shotgun.ogg`
- `splash.ogg`
- `firework.ogg`
- `shotgun.ogg`

#### "Monogram" font provided by https://datagoblin.itch.io/monogram uncer [CC0](https://creativecommons.org/publicdomain/zero/1.0/)
- `monogram.woff2`

- `monogram.woff2`
150 changes: 78 additions & 72 deletions src/assets/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { AssetsManifest, Texture } from "pixi.js";
import { Sound } from "@pixi/sound";
import "@pixi/sound";
Expand Down Expand Up @@ -41,81 +40,88 @@ import splashSnd from "./splash.ogg";
import monogramFnt from "./monogram.woff2";

export interface AssetTextures {
bazooka: Texture;
boneIsles: Texture;
firework: Texture;
grenade: Texture;
island1: Texture;
mine: Texture;
mineActive: Texture;
terrain2: Texture;
testDolby: Texture;
testDolbyBlush: Texture;
testDolbyDamage1: Texture;
testDolbyDamage1Blush: Texture;
testDolbyDamage2Blush: Texture;
testDolbyDamage3: Texture;
testDolbyDamage3Blush: Texture;
testingGround: Texture;
windScroll: Texture;
bazooka: Texture;
boneIsles: Texture;
firework: Texture;
grenade: Texture;
island1: Texture;
mine: Texture;
mineActive: Texture;
terrain2: Texture;
testDolby: Texture;
testDolbyBlush: Texture;
testDolbyDamage1: Texture;
testDolbyDamage1Blush: Texture;
testDolbyDamage2Blush: Texture;
testDolbyDamage3: Texture;
testDolbyDamage3Blush: Texture;
testingGround: Texture;
windScroll: Texture;
}

export interface AssetSounds {
bazookafire: Sound;
explosion1: Sound;
explosion2: Sound;
explosion3: Sound;
firework: Sound;
metalBounceHeavy: Sound;
metalBounceLight: Sound;
mineBeep: Sound;
placeholder: Sound;
shotgun: Sound;
splash: Sound;
bazookafire: Sound;
explosion1: Sound;
explosion2: Sound;
explosion3: Sound;
firework: Sound;
metalBounceHeavy: Sound;
metalBounceLight: Sound;
mineBeep: Sound;
placeholder: Sound;
shotgun: Sound;
splash: Sound;
}

export const manifest = {
bundles: [{
name: "textures",
assets: [
{src: bazookaTex, alias: "bazooka"},
{src: boneIslesTex, alias: "boneIsles"},
{src: fireworkTex, alias: "firework"},
{src: grenadeTex, alias: "grenade"},
{src: island1Tex, alias: "island1"},
{src: mineTex, alias: "mine"},
{src: mineActiveTex, alias: "mineActive"},
{src: terrain2Tex, alias: "terrain2"},
{src: testDolbyTex, alias: "testDolby"},
{src: testDolbyBlushTex, alias: "testDolbyBlush"},
{src: testDolbyDamage1Tex, alias: "testDolbyDamage1"},
{src: testDolbyDamage1BlushTex, alias: "testDolbyDamage1Blush"},
{src: testDolbyDamage2BlushTex, alias: "testDolbyDamage2Blush"},
{src: testDolbyDamage3Tex, alias: "testDolbyDamage3"},
{src: testDolbyDamage3BlushTex, alias: "testDolbyDamage3Blush"},
{src: testingGroundTex, alias: "testingGround"},
{src: windScrollTex, alias: "windScroll"}
]
}, {
name: "sounds",
assets: [
{src: bazookafireSnd, alias: "bazookafire"},
{src: explosion1Snd, alias: "explosion1"},
{src: explosion2Snd, alias: "explosion2"},
{src: explosion3Snd, alias: "explosion3"},
{src: fireworkSnd, alias: "firework"},
{src: metalBounceHeavySnd, alias: "metalBounceHeavy"},
{src: metalBounceLightSnd, alias: "metalBounceLight"},
{src: mineBeepSnd, alias: "mineBeep"},
{src: placeholderSnd, alias: "placeholder"},
{src: shotgunSnd, alias: "shotgun"},
{src: splashSnd, alias: "splash"}
]
}, {
name: "fonts",
assets: [
{src: monogramFnt, alias: "monogram", data: {"family":"Monogram","weights":["normal"]}}
]
}]
bundles: [
{
name: "textures",
assets: [
{ src: bazookaTex, alias: "bazooka" },
{ src: boneIslesTex, alias: "boneIsles" },
{ src: fireworkTex, alias: "firework" },
{ src: grenadeTex, alias: "grenade" },
{ src: island1Tex, alias: "island1" },
{ src: mineTex, alias: "mine" },
{ src: mineActiveTex, alias: "mineActive" },
{ src: terrain2Tex, alias: "terrain2" },
{ src: testDolbyTex, alias: "testDolby" },
{ src: testDolbyBlushTex, alias: "testDolbyBlush" },
{ src: testDolbyDamage1Tex, alias: "testDolbyDamage1" },
{ src: testDolbyDamage1BlushTex, alias: "testDolbyDamage1Blush" },
{ src: testDolbyDamage2BlushTex, alias: "testDolbyDamage2Blush" },
{ src: testDolbyDamage3Tex, alias: "testDolbyDamage3" },
{ src: testDolbyDamage3BlushTex, alias: "testDolbyDamage3Blush" },
{ src: testingGroundTex, alias: "testingGround" },
{ src: windScrollTex, alias: "windScroll" },
],
},
{
name: "sounds",
assets: [
{ src: bazookafireSnd, alias: "bazookafire" },
{ src: explosion1Snd, alias: "explosion1" },
{ src: explosion2Snd, alias: "explosion2" },
{ src: explosion3Snd, alias: "explosion3" },
{ src: fireworkSnd, alias: "firework" },
{ src: metalBounceHeavySnd, alias: "metalBounceHeavy" },
{ src: metalBounceLightSnd, alias: "metalBounceLight" },
{ src: mineBeepSnd, alias: "mineBeep" },
{ src: placeholderSnd, alias: "placeholder" },
{ src: shotgunSnd, alias: "shotgun" },
{ src: splashSnd, alias: "splash" },
],
},
{
name: "fonts",
assets: [
{
src: monogramFnt,
alias: "monogram",
data: { family: "Monogram", weights: ["normal"] },
},
],
},
],
} satisfies AssetsManifest;

Loading

0 comments on commit 2ac2443

Please sign in to comment.