From 1f18f3d16fc7a897da7abf74748dbf8ba7467a31 Mon Sep 17 00:00:00 2001 From: ajuvercr Date: Tue, 17 Sep 2019 18:27:44 +0200 Subject: [PATCH] bump --- frontend/www/bootstrap.js | 1 + frontend/www/index.html | 2 ++ frontend/www/index.js | 17 ----------------- frontend/www/index.ts | 10 ++++++++++ 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/frontend/www/bootstrap.js b/frontend/www/bootstrap.js index 7934d62..46e0b6a 100644 --- a/frontend/www/bootstrap.js +++ b/frontend/www/bootstrap.js @@ -1,5 +1,6 @@ // A dependency graph that contains any wasm must all be imported // asynchronously. This `bootstrap.js` file does the single async import, so // that no one else needs to worry about it again. +// Import index.js that executes index.ts import("./index.js") .catch(e => console.error("Error importing `index.js`:", e)); diff --git a/frontend/www/index.html b/frontend/www/index.html index ca5615c..fef4ea8 100644 --- a/frontend/www/index.html +++ b/frontend/www/index.html @@ -5,6 +5,8 @@ Hello wasm-pack! + + diff --git a/frontend/www/index.js b/frontend/www/index.js index 6967f0b..a4ce02d 100644 --- a/frontend/www/index.js +++ b/frontend/www/index.js @@ -1,5 +1,4 @@ import { Game } from "planetwars"; -import { memory } from "planetwars/plantwars_bg" import { Shader } from "./webgl/shader" import { main } from './index.ts' @@ -14,19 +13,3 @@ fetch(game_location) .then((response) => { main(Game.new(response)); }).catch(console.error); - - -// const g = Game.new(""); - -// const p1 = g.locations(); -// const s1 = g.location_count(); -// console.log(p1, s1); -// const a1 = new Float64Array(memory.buffer, p1, s1 * 3); -// console.log(a1); - -// g.add_location(0.5, 1.2, 3.14); - -// const p2 = g.locations(); -// const s2 = g.location_count(); -// const a2 = new Float64Array(memory.buffer, p2, s2 * 3); -// console.log(a2); diff --git a/frontend/www/index.ts b/frontend/www/index.ts index 142f771..dec7c89 100644 --- a/frontend/www/index.ts +++ b/frontend/www/index.ts @@ -1,5 +1,15 @@ import { Game } from "planetwars"; +import { memory } from "planetwars/plantwars_bg"; + +const CANVAS = document.getElementById("c"); + + +function create_array(ptr: number, size: number): Float64Array { + return new Float64Array(memory.buffer, ptr, size); +} export function main(game: Game) { console.log(game.turn_count()); + + console.log(create_array(game.get_viewbox(), 4)); }