Removed unnecessary files
This commit is contained in:
parent
8bdfd8b9ac
commit
4fb6cdb7f2
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
src/*.js
|
||||||
|
src/*.map
|
||||||
|
|
||||||
|
dist
|
33
src/app.js
33
src/app.js
@ -1,33 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const p5_1 = __importDefault(require("p5"));
|
|
||||||
require("/assets/styles/main.scss");
|
|
||||||
const cell_1 = require("./cell");
|
|
||||||
const environment_1 = require("./environment");
|
|
||||||
new p5_1.default((p5) => {
|
|
||||||
const position = [0, 0];
|
|
||||||
const player = new cell_1.Cell([0, 0], '');
|
|
||||||
const environment = new environment_1.Environment([player]);
|
|
||||||
let drag;
|
|
||||||
p5.setup = () => {
|
|
||||||
p5.createCanvas(document.body.offsetWidth, document.body.offsetHeight);
|
|
||||||
};
|
|
||||||
p5.draw = () => {
|
|
||||||
environment.draw(p5, position[0], position[1]);
|
|
||||||
};
|
|
||||||
p5.windowResized = () => { p5.resizeCanvas(p5.windowWidth, p5.windowHeight); };
|
|
||||||
p5.mousePressed = () => { drag = [p5.mouseX, p5.mouseY]; };
|
|
||||||
p5.mouseReleased = () => { drag = null; };
|
|
||||||
p5.mouseDragged = () => {
|
|
||||||
if (drag) {
|
|
||||||
position[0] += drag[0] - p5.mouseX;
|
|
||||||
drag[0] = p5.mouseX;
|
|
||||||
position[1] -= drag[1] - p5.mouseY;
|
|
||||||
drag[1] = p5.mouseY;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=app.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":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I,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;YACpB,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;SACpB;IACF,CAAC,CAAA;AACF,CAAC,CAAC,CAAC"}
|
|
46
src/cell.js
46
src/cell.js
@ -1,46 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.Cell = void 0;
|
|
||||||
const MAX_CELL_SIZE = 100;
|
|
||||||
class Cell {
|
|
||||||
constructor(pos, script = '') {
|
|
||||||
this.pos = pos;
|
|
||||||
this.script = script;
|
|
||||||
this.energy = 100;
|
|
||||||
this.cellWall = 5;
|
|
||||||
this.api = {
|
|
||||||
move: {
|
|
||||||
down: () => this.move(0, -1),
|
|
||||||
left: () => this.move(-1, 0),
|
|
||||||
right: () => this.move(1, 0),
|
|
||||||
up: () => this.move(0, 1)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
get dead() { return this.energy <= 20; }
|
|
||||||
get size() { return Math.min(MAX_CELL_SIZE, 50 * (this.energy / 100)); }
|
|
||||||
draw(p5, offsetX, offsetY) {
|
|
||||||
if (!this.dead)
|
|
||||||
this.run();
|
|
||||||
p5.fill(100, 100, 200);
|
|
||||||
p5.stroke(150, 150, 255);
|
|
||||||
p5.strokeWeight(this.cellWall);
|
|
||||||
p5.circle(offsetX + this.pos[0], offsetY - this.pos[1], this.size);
|
|
||||||
}
|
|
||||||
move(x, y) {
|
|
||||||
const energyCost = Math.round(this.size / 25 * 10) / 10;
|
|
||||||
if (this.energy - energyCost <= 20)
|
|
||||||
return;
|
|
||||||
this.energy -= energyCost;
|
|
||||||
this.pos[0] += x;
|
|
||||||
this.pos[1] += y;
|
|
||||||
}
|
|
||||||
run() {
|
|
||||||
if (!this.script)
|
|
||||||
return;
|
|
||||||
const script = `${this.script}; run(this);`;
|
|
||||||
return function () { return eval(script); }.call(this.api);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Cell = Cell;
|
|
||||||
//# sourceMappingURL=cell.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"cell.js","sourceRoot":"","sources":["cell.ts"],"names":[],"mappings":";;;AAWA,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,MAAa,IAAI;IAOhB,YAAoB,GAAqB,EAAU,SAAiB,EAAE;QAAlD,QAAG,GAAH,GAAG,CAAkB;QAAU,WAAM,GAAN,MAAM,CAAa;QANtE,WAAM,GAAW,GAAG,CAAC;QACrB,aAAQ,GAAW,CAAC,CAAC;QAOrB,QAAG,GAAY;YACd,IAAI,EAAE;gBACL,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC5B,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC5B,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC5B,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;aACzB;SACD,CAAA;IATyE,CAAC;IAH3E,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;IACxC,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAA,CAAC,CAAC;IAavE,IAAI,CAAC,EAAM,EAAE,OAAe,EAAE,OAAe;QAC5C,IAAG,C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
function mulberry32(seed) {
|
|
||||||
return function () {
|
|
||||||
let t = seed += 0x6D2B79F5;
|
|
||||||
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
||||||
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
||||||
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
exports.mulberry32 = mulberry32;
|
|
||||||
const RENDER_DIST = 500;
|
|
||||||
class Environment {
|
|
||||||
constructor(cells = [], size = 1000, seed = Math.random()) {
|
|
||||||
this.cells = cells;
|
|
||||||
this.size = size;
|
|
||||||
this.seed = seed;
|
|
||||||
this.food = [];
|
|
||||||
this.generator = mulberry32(seed);
|
|
||||||
this.food = Array(500).fill([]).map(() => [
|
|
||||||
this.generator() * this.size * (this.generator() > 0.5 ? 1 : -1),
|
|
||||||
this.generator() * this.size * (this.generator() > 0.5 ? 1 : -1)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
addCell(cell) {
|
|
||||||
this.cells.push(cell);
|
|
||||||
cell.environment = this;
|
|
||||||
}
|
|
||||||
draw(p5, x, y) {
|
|
||||||
const center = [p5.windowWidth / 2, p5.windowHeight / 2];
|
|
||||||
const offset = [center[0] - x, center[1] + y];
|
|
||||||
// Background
|
|
||||||
p5.background(245, 245, 255);
|
|
||||||
// Food
|
|
||||||
this.food.filter(f => (Math.abs((f[0] - x) / (f[1] - y)) <= RENDER_DIST)).forEach(f => {
|
|
||||||
p5.fill(100);
|
|
||||||
p5.stroke(10);
|
|
||||||
p5.strokeWeight(2);
|
|
||||||
p5.circle(offset[0] + f[0], offset[1] - f[1], 10);
|
|
||||||
});
|
|
||||||
// Cells
|
|
||||||
this.cells.forEach(c => c.draw(p5, offset[0], offset[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Environment = Environment;
|
|
||||||
//# sourceMappingURL=environment.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"environment.js","sourceRoot":"","sources":["environment.ts"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CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;CACD;AAtCD,kCAsCC"}
|
|
@ -1,3 +0,0 @@
|
|||||||
const run = (cell) => {
|
|
||||||
cell.move.up();
|
|
||||||
};
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"example.js","sourceRoot":"","sources":["example.ts"],"names":[],"mappings":";;AAEA,IAAM,GAAG,GAAG,UAAC,IAAa;IACzB,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AAChB,CAAC,CAAC"}
|
|
Loading…
Reference in New Issue
Block a user