add Code section
add only journal post for 2025 update copyrights to 2026 add licenses to BPS remove unused files update to 0.14.2
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,45 +1,55 @@
|
||||
// @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0
|
||||
/****************************************************************************
|
||||
* Byte Beasties Escape!
|
||||
*
|
||||
* Copyright 2023-2026 Eric Woodward
|
||||
* Source released under CC0 Public Domain License v1.0
|
||||
* https://www.planarvagabond.com/licenses/cc0/
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
****************************************************************************/
|
||||
export const createLightning = (canvas, enemy) => {
|
||||
const { y: size } = enemy;
|
||||
var center = { x: canvas.width / 2, y: canvas.height };
|
||||
var minSegmentHeight = 5;
|
||||
var roughness = 2;
|
||||
var maxDifference = size / 5;
|
||||
const { y: size } = enemy;
|
||||
var center = { x: canvas.width / 2, y: canvas.height };
|
||||
var minSegmentHeight = 5;
|
||||
var roughness = 2;
|
||||
var maxDifference = size / 5;
|
||||
|
||||
let lightning = [];
|
||||
let segmentHeight = size / 3;
|
||||
lightning.push({
|
||||
x: center.x,
|
||||
y: center.y + 200,
|
||||
});
|
||||
lightning.push({
|
||||
x: Math.random() * (canvas.width - 100) + 50,
|
||||
y: Math.abs((Math.random() - 0.9) * 100),
|
||||
});
|
||||
let currDiff = maxDifference;
|
||||
while (segmentHeight > minSegmentHeight) {
|
||||
const newSegments = [];
|
||||
for (var i = 0; i < lightning.length - 1; i++) {
|
||||
const start = lightning[i],
|
||||
end = lightning[i + 1],
|
||||
midX = (start.x + end.x) / 2,
|
||||
newX = midX + (Math.random() * 2 - 1) * currDiff;
|
||||
newSegments.push(start, { x: newX, y: (start.y + end.y) / 2 });
|
||||
}
|
||||
let lightning = [];
|
||||
let segmentHeight = size / 3;
|
||||
lightning.push({
|
||||
x: center.x,
|
||||
y: center.y + 200,
|
||||
});
|
||||
lightning.push({
|
||||
x: Math.random() * (canvas.width - 100) + 50,
|
||||
y: Math.abs((Math.random() - 0.9) * 100),
|
||||
});
|
||||
let currDiff = maxDifference;
|
||||
while (segmentHeight > minSegmentHeight) {
|
||||
const newSegments = [];
|
||||
for (var i = 0; i < lightning.length - 1; i++) {
|
||||
const start = lightning[i],
|
||||
end = lightning[i + 1],
|
||||
midX = (start.x + end.x) / 2,
|
||||
newX = midX + (Math.random() * 2 - 1) * currDiff;
|
||||
newSegments.push(start, { x: newX, y: (start.y + end.y) / 2 });
|
||||
}
|
||||
|
||||
newSegments.push(lightning.pop());
|
||||
lightning = newSegments;
|
||||
newSegments.push(lightning.pop());
|
||||
lightning = newSegments;
|
||||
|
||||
currDiff /= roughness;
|
||||
segmentHeight /= 2;
|
||||
}
|
||||
return lightning;
|
||||
currDiff /= roughness;
|
||||
segmentHeight /= 2;
|
||||
}
|
||||
return lightning;
|
||||
};
|
||||
|
||||
// Get the position of the mouse relative to the canvas
|
||||
export const getMousePos = (canvasDom, mouseEvent) => {
|
||||
var rect = canvasDom.getBoundingClientRect();
|
||||
return {
|
||||
x: mouseEvent.clientX - rect.left,
|
||||
y: mouseEvent.clientY - rect.top,
|
||||
};
|
||||
var rect = canvasDom.getBoundingClientRect();
|
||||
return {
|
||||
x: mouseEvent.clientX - rect.left,
|
||||
y: mouseEvent.clientY - rect.top,
|
||||
};
|
||||
};
|
||||
// @license-end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0
|
||||
/****************************************************************************
|
||||
* Planar Vagabond's Guide to the Multiverse (planarvagabond.com)
|
||||
* Byte Beasties Escape!
|
||||
*
|
||||
* Copyright 2023-2024 Eric Woodward
|
||||
* Copyright 2023-2026 Eric Woodward
|
||||
* Source released under CC0 Public Domain License v1.0
|
||||
* https://www.planarvagabond.com/licenses/cc0/
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
@@ -11,22 +11,22 @@
|
||||
import { startGame } from "./bbe.js";
|
||||
|
||||
export default (() => {
|
||||
// we load this library as a module to guarantee baseline ES6 functionality
|
||||
// we load this library as a module to guarantee baseline ES6 functionality
|
||||
|
||||
// Indicate JS is loaded
|
||||
document.documentElement.className =
|
||||
document.documentElement.className.replace("no-js", "js");
|
||||
// Indicate JS is loaded
|
||||
document.documentElement.className =
|
||||
document.documentElement.className.replace("no-js", "js");
|
||||
|
||||
setTimeout(() => {
|
||||
const canvas = document.createElement("canvas"),
|
||||
contentDiv = document.getElementById("game");
|
||||
setTimeout(() => {
|
||||
const canvas = document.createElement("canvas"),
|
||||
contentDiv = document.getElementById("game");
|
||||
|
||||
canvas.setAttribute("width", "375");
|
||||
canvas.setAttribute("height", "667");
|
||||
canvas.setAttribute("id", "game");
|
||||
contentDiv.appendChild(canvas);
|
||||
canvas.setAttribute("width", "375");
|
||||
canvas.setAttribute("height", "667");
|
||||
canvas.setAttribute("id", "game");
|
||||
contentDiv.appendChild(canvas);
|
||||
|
||||
startGame(canvas);
|
||||
}, 1);
|
||||
startGame(canvas);
|
||||
}, 1);
|
||||
})();
|
||||
// @license-end
|
||||
|
||||
Reference in New Issue
Block a user