Fixed bundle bug.

This commit is contained in:
2021-09-25 21:42:43 -07:00
parent e8c15e1edd
commit c3fcddee72
4 changed files with 44 additions and 47 deletions

View File

@ -18,11 +18,8 @@ const outputFix = (output, dir) => {
const matches = out.matchAll(reg);
let match;
while(!(match = matches.next()).done) {
const exp = new RegExp(`${match.value[1]}\.`);
exp.multiline = true;
const exp = new RegExp(`${match.value[1]}\.`, 'gm');
scanFile(path.join(dir, match.value[2]), dir);
out = out.replace(match.value[0], '').replace(exp, 'exports.');
}

0
ts/asset/AssetManager.ts Normal file
View File

40
ts/game/Game.ts Normal file
View File

@ -0,0 +1,40 @@
export abstract class Game {
constructor() {
}
init() {
print("init");
}
update() {
print("update");
}
dispose() {
print("Disposed");
}
}
let GAME_MAIN:Game|null = null;
export const gameSetMain = (game:Game) => {
print("setting", game);
GAME_MAIN = game;
}
const init = () => {
if(!GAME_MAIN) return;
GAME_MAIN.init();
}
const update = () => {
if(!GAME_MAIN) return;
GAME_MAIN.update();
}
const dispose = () => {
if(!GAME_MAIN) return;
GAME_MAIN.dispose();
}

View File

@ -1,47 +1,7 @@
let cube:Primitive;
let shader:Shader;
let camera:Camera;
let texture:Texture;
let n:number;
import { Game, gameSetMain } from "./game/Game";
const init = () => {
print('Main invoked');
n = 0;
// Create Quad
cube = primitiveCreate();
quadInit(cube, 0, -1, -1, 0, 0, 1, 1, 1, 1);
// Create Camera
camera = cameraCreate();
// Load Shader
shader = shaderCreate();
assetShaderLoad(shader, "shaders/textured.vert", "shaders/textured.frag");
class MainGame extends Game {
// Texture load
texture = textureCreate();
assetTextureLoad(texture, "test_texture.png");
}
const update = () => {
shaderUse(shader);
shaderUseTexture(shader, texture);
n += epochGetDelta();
cameraLookAt(camera, 3,3,3, 0,0,0);
cameraPerspective(camera, 45, 16/9, 0.01, 100);
shaderUseCamera(shader, camera);
shaderUsePosition(shader, 0,0,0, 0,n,0);
primitiveDraw(cube, 0, -1);
}
const dispose = () => {
cameraDispose(camera);
shaderDispose(shader);
}
gameSetMain(new MainGame());