mirror of
https://github.com/swarm-game/swarm.git
synced 2024-12-13 05:10:31 +03:00
Migrate to v8 of pixi.js, vendor the library (#2144)
Include `pixi.js` in repo to avoid getting broken by upstream changes. ``` scripts/play.sh -i data/scenarios/Challenges/ice-cream.yaml ``` ![Screenshot from 2024-09-14 16-41-24](https://github.com/user-attachments/assets/89edaef0-4197-4dac-adde-a409ac5c86f4)
This commit is contained in:
parent
7b99e721a6
commit
746be8f4f6
@ -2,20 +2,20 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Web frontend</title>
|
||||
<script src="https://pixijs.download/release/pixi.js"></script>
|
||||
<script src="script/pixi.js"></script>
|
||||
|
||||
<script src="script/display.js"></script>
|
||||
<script src="script/fetch.js"></script>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
function startLoop() {
|
||||
async function startLoop() {
|
||||
const button = document.getElementById('restart-button');
|
||||
button.style.display = 'none';
|
||||
|
||||
let displayWidth = 600;
|
||||
let displayHeight = 300;
|
||||
let out = setupGraphics(button, displayWidth, displayHeight);
|
||||
let out = await setupGraphics(button, displayWidth, displayHeight);
|
||||
let appView = out[0];
|
||||
let graphics = out[1];
|
||||
doFetch(button, appView, graphics, displayWidth, displayHeight);
|
||||
|
@ -1,15 +1,16 @@
|
||||
function setupGraphics(button, displayWidth, displayHeight) {
|
||||
async function setupGraphics(button, displayWidth, displayHeight) {
|
||||
|
||||
const app = new PIXI.Application();
|
||||
// Create the application helper and add its render target to the page
|
||||
let app = new PIXI.Application({
|
||||
await app.init({
|
||||
width: displayWidth,
|
||||
height: displayHeight,
|
||||
backgroundColor: 0xFFFFFF
|
||||
});
|
||||
|
||||
document.body.insertBefore(app.view, button);
|
||||
document.body.insertBefore(app.canvas, button);
|
||||
|
||||
const graphics = new PIXI.Graphics();
|
||||
app.stage.addChild(graphics);
|
||||
return [app.view, graphics];
|
||||
return [app.canvas, graphics];
|
||||
}
|
||||
|
@ -14,11 +14,10 @@ function drawGraphics(graphics, colorMap, grid) {
|
||||
let colorIdx = row[colIdx];
|
||||
let color = colorMap[colorIdx];
|
||||
|
||||
graphics.beginFill(color);
|
||||
let xPos = colIdx * cellSize;
|
||||
let yPos = rowIdx * cellSize;
|
||||
graphics.drawRect(xPos, yPos, xPos + cellSize, yPos + cellSize);
|
||||
graphics.endFill();
|
||||
graphics.rect(xPos, yPos, xPos + cellSize, yPos + cellSize);
|
||||
graphics.fill(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
44113
web/script/pixi.js
Normal file
44113
web/script/pixi.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user