Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
node-version: 24
registry-url: https://registry.npmjs.org/

- name: Build library
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 24
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 24

- name: Unit tests
run: |
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v24.14.0
12 changes: 1 addition & 11 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"bracketSameLine": false,
"jsxSingleQuote": true,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"printWidth": 100
}
"@krutoo/presets/prettier"
90 changes: 90 additions & 0 deletions docs/docs/dungeon-next.story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { DungeonNext } from 'rglk';

export const meta = {
category: 'Dungeons (next)',
title: 'Demo',
};

function init(canvas: HTMLCanvasElement | null) {
if (!canvas) {
return;
}

const context = canvas.getContext('2d')!;

if (!context) {
return;
}

context.imageSmoothingEnabled = false;

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.style.display = 'block';
canvas.style.position = 'fixed';
canvas.style.setProperty('image-rendering', 'pixelated');
canvas.style.top = '0';
canvas.style.left = '0';
canvas.style.width = `${window.innerWidth}px`;
canvas.style.height = `${window.innerHeight}px`;

const generator = DungeonNext.createDungeon({
roomAmount: 24,
roomMinSize: 6,
roomMaxSize: 12,
roomMargin: 1,
});

const loop = () => {
const { done, value } = generator.next();

render(value);

if (!done) {
requestAnimationFrame(loop);
}
};

const render = ({ rooms, corridors }: any) => {
const scale = 5;
context.clearRect(0, 0, canvas.width, canvas.height);
context.translate(canvas.width / 2, canvas.height / 2);
context.save();

// rooms:
context.strokeStyle = '#000';
for (const room of rooms) {
context.fillRect(room.x * scale, room.y * scale, room.width * scale, room.height * scale);
}

// corridors:
context.lineWidth = scale;
for (const { a, b } of corridors) {
context.beginPath();
context.moveTo(a.x * scale, a.y * scale);
context.lineTo(b.x * scale, b.y * scale);
context.stroke();
context.closePath();
}
context.lineWidth = 1;

// connections:
// context.strokeStyle = '#f00';
// for (const { a: from, b: to } of connections) {
// context.beginPath();
// context.moveTo(from.x, from.y);
// context.lineTo(to.x, to.y);
// context.stroke();
// context.closePath();
// }
// context.strokeStyle = '#000';

context.translate(-canvas.width / 2, -canvas.height / 2);
};

loop();
}

export default function Example() {
return <canvas ref={init}></canvas>;
}
2 changes: 1 addition & 1 deletion docs/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const meta = {
menuPriority: 1000,
};

# `rglk.js`
<h1 style={{ fontSize: '56px', fontWeight: '800' }}>rglk.js</h1>

Simple library for development roguelike games, designed for training/educational purposes.
Inspired by [rot.js](http://ondras.github.io/rot.js/hp/).
Expand Down
1 change: 1 addition & 0 deletions docs/rspack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
resolve: {
alias: {
'#found-stories$': path.resolve(import.meta.dirname, './.generated/found-stories.js'),
rglk$: path.resolve(import.meta.dirname, '../src/index.ts'),
},
},
module: {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Showcase</title>
<title>rglk.js - Library for rogue-like games development</title>
</head>
<body>
<div id="root"></div>
Expand Down
Loading
Loading