fix types

This commit is contained in:
ajuvercr 2019-09-17 14:03:16 +02:00
parent 2bd6d3a6d7
commit 35747ae6cb
2 changed files with 23 additions and 18 deletions

View file

@ -2,31 +2,31 @@ import { Game } from "planetwars";
import { memory } from "planetwars/plantwars_bg" import { memory } from "planetwars/plantwars_bg"
import { Shader } from "./webgl/shader" import { Shader } from "./webgl/shader"
import { main } from './index.ts'
const URL = window.location.origin+window.location.pathname; const URL = window.location.origin+window.location.pathname;
const LOCATION = URL.substring(0, URL.lastIndexOf("/") + 1); const LOCATION = URL.substring(0, URL.lastIndexOf("/") + 1);
const game_location = LOCATION + "static/game.json"; const game_location = LOCATION + "static/game.json";
// fetch(game_location) fetch(game_location)
// .then((r) => r.text()) .then((r) => r.text())
// .then((response) => { .then((response) => {
// console.log(response); main(Game.new(response));
// let game = Game.new(response); }).catch(console.error);
// console.log(game.turn_count());
// }).catch(console.error);
const g = Game.new(""); // const g = Game.new("");
const p1 = g.locations(); // const p1 = g.locations();
const s1 = g.location_count(); // const s1 = g.location_count();
console.log(p1, s1); // console.log(p1, s1);
const a1 = new Float64Array(memory.buffer, p1, s1 * 3); // const a1 = new Float64Array(memory.buffer, p1, s1 * 3);
console.log(a1); // console.log(a1);
g.add_location(0.5, 1.2, 3.14); // g.add_location(0.5, 1.2, 3.14);
const p2 = g.locations(); // const p2 = g.locations();
const s2 = g.location_count(); // const s2 = g.location_count();
const a2 = new Float64Array(memory.buffer, p2, s2 * 3); // const a2 = new Float64Array(memory.buffer, p2, s2 * 3);
console.log(a2); // console.log(a2);

5
frontend/www/index.ts Normal file
View file

@ -0,0 +1,5 @@
import { Game } from "planetwars";
export function main(game: Game) {
console.log(game.turn_count());
}