Dawn/ts/main.ts
2021-09-26 00:42:35 -07:00

47 lines
1.1 KiB
TypeScript

import { Game, gameSetMain } from "./game/Game";
import { Scene } from "./scene/Scene";
class TestScene extends Scene {
private quad:Primitive;
private camera:Camera;
private shader:Shader;
private texture:Texture;
init() {
this.quad = primitiveCreate();
quadInit(this.quad, 0,
-1, -1, 0, 0,
1, 1, 1, 1
);
this.shader = this.game.assets.shaderLoad(
"shaders/textured.vert", "shaders/textured.frag", this
);
this.texture = this.game.assets.textureLoad("test_texture.png", this);
this.camera = cameraCreate();
cameraLookAt(this.camera, 3,3,3, 0,0,0);
cameraPerspective(this.camera, 45, 16/9, 0.01, 1000);
}
update() {
shaderUse(this.shader);
shaderUseCamera(this.shader, this.camera);
shaderUsePosition(this.shader, 0,0,0, 0,this.game.time.current,0);
shaderUseTexture(this.shader, this.texture);
primitiveDraw(this.quad, 0, -1);
}
dispose() {
}
}
class MainGame extends Game {
constructor() {
super();
this.setScene(new TestScene(this));
this.scene.init();
}
}
gameSetMain(new MainGame());