From f9fc4d26ec5fca9ee175c8a6fbcdd0fa36f10947 Mon Sep 17 00:00:00 2001 From: sanine Date: Thu, 16 Nov 2023 14:50:00 -0600 Subject: clear out js files --- src/ui/index.js | 75 --------------------------------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 src/ui/index.js (limited to 'src/ui/index.js') diff --git a/src/ui/index.js b/src/ui/index.js deleted file mode 100644 index 01068cb..0000000 --- a/src/ui/index.js +++ /dev/null @@ -1,75 +0,0 @@ -import { draw } from './canvas.js'; -import { create_team, create_epoch, update_epoch } from '../simulation/game.js'; - - -console.log("generating agents..."); -const start_teams = [...Array(4)].map(x => create_team(2, 400, 50)); -console.log("creating epoch..."); -let epoch = create_epoch(60, start_teams); -console.log("ready!"); - - -function draw_cell(ctx, x, y, cell) { - ctx.fillStyle = (() => { - switch (cell.type) { - case 'empty': - return '#ffffff'; - case 'immutable': - return '#0000ff'; - case 'mutable': - return '#555555'; - case 'active': - return '#000000'; - case 'flag': - return '#ffff00'; - default: - return '#00ff00'; - } - })(); - ctx.fillRect(x, y, 1, 1); -} - -function draw_agent(ctx, agent) { - ctx.beginPath(); - ctx.fillStyle = '#ff0000'; - const { x, y } = agent; - ctx.arc(x+.5, y+.5, .5, 0, 2*Math.PI); - ctx.fill(); -} - - -function render(canvas) { - draw(canvas, epoch.size, (ctx) => { - for (let y=0; y draw_agent(ctx, a)); - }); -} - - -function update(canvas) { - console.log('update'); - epoch = update_epoch(epoch); - render(canvas); - setTimeout(() => update(canvas), 1); -} - - -function main() { - const canvas = document.getElementById('canvas'); - window.onresize = () => { - const size = 0.95*window.innerWidth - canvas.width = size; - canvas.height = size; - render(canvas); - } - window.onresize(); - console.log("c:"); - update(canvas); -} - - -window.onload = main; -- cgit v1.2.1