From 98dabd8fec5d2930add944997577a5f702013736 Mon Sep 17 00:00:00 2001
From: J08nY
Date: Sat, 16 Apr 2016 06:41:19 +0200
Subject: atleast got typescript working
---
.gitignore | 46 +++++++++++++++++++
Controls.ts | 4 ++
Enemy.ts | 12 +++++
Morph.ts | 43 ++++++++++++++++++
Player.ts | 15 +++++++
TargetCamera.ts | 1 +
World.ts | 11 +++++
game.ts | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
index.html | 41 +++++++++++++++--
main.ts | 68 +++++++++++++++++++++++++++-
10 files changed, 373 insertions(+), 4 deletions(-)
create mode 100644 Controls.ts
create mode 100644 Enemy.ts
create mode 100644 Morph.ts
create mode 100644 Player.ts
create mode 100644 TargetCamera.ts
create mode 100644 World.ts
create mode 100644 game.ts
diff --git a/.gitignore b/.gitignore
index bfa6a22..207cbc6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,47 @@
# Created by .ignore support plugin (hsz.mobi)
+### JetBrains template
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff:
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/dictionaries
+.idea/vcs.xml
+.idea/jsLibraryMappings.xml
+
+# Sensitive or high-churn files:
+.idea/dataSources.ids
+.idea/dataSources.xml
+.idea/dataSources.local.xml
+.idea/sqlDataSources.xml
+.idea/dynamic.xml
+.idea/uiDesigner.xml
+
+# Gradle:
+.idea/gradle.xml
+.idea/libraries
+
+# Mongo Explorer plugin:
+.idea/mongoSettings.xml
+
+## File-based project format:
+*.iws
+
+## Plugin-specific files:
+
+# IntelliJ
+/out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
diff --git a/Controls.ts b/Controls.ts
new file mode 100644
index 0000000..0c4adef
--- /dev/null
+++ b/Controls.ts
@@ -0,0 +1,4 @@
+
+module Controls{
+
+}
\ No newline at end of file
diff --git a/Enemy.ts b/Enemy.ts
new file mode 100644
index 0000000..5193991
--- /dev/null
+++ b/Enemy.ts
@@ -0,0 +1,12 @@
+///
+///
+
+import {Morph} from "./Morph";
+
+export class Enemy extends Morph {
+
+ constructor() {
+ super(null, null, null);
+ //todo
+ }
+}
\ No newline at end of file
diff --git a/Morph.ts b/Morph.ts
new file mode 100644
index 0000000..f97ea5c
--- /dev/null
+++ b/Morph.ts
@@ -0,0 +1,43 @@
+///
+///
+
+export class Morph extends Physijs.Mesh {
+ faces:number;
+ //TODO, probelm s tym ze ked extendujem Mesh, tak sa nedostanem k Geometry ale iba k BufferGeometry
+
+ constructor(numFaces:number, material:THREE.Material, mass:number) {
+ let geometry = Morph.generateGeometry(numFaces);
+ super(geometry, material, mass);
+ }
+
+ static generateGeometry(numFaces:number):THREE.Geometry {
+ if (numFaces == 4) {
+ return new THREE.TetrahedronGeometry();
+ } else if (numFaces == 6) {
+ return new THREE.BoxGeometry(1, 1, 1, 2, 2, 2);
+ } else if (numFaces == 12) {
+ return new THREE.DodecahedronGeometry(1, 0);
+ } else if (numFaces == 20) {
+ return new THREE.IcosahedronGeometry(1, 0);
+ }
+ return null;
+ }
+
+ private updateGeometry(numFaces:number) {
+ this.faces = numFaces;
+ this.geometry = Morph.generateGeometry(this.faces);
+ }
+
+ shrink(numFaces:number):void {
+ this.updateGeometry(this.faces - numFaces);
+ }
+
+ grow(numFaces:number):void {
+ this.updateGeometry(this.faces + numFaces);
+ }
+
+ wobble():void {
+
+ }
+
+}
\ No newline at end of file
diff --git a/Player.ts b/Player.ts
new file mode 100644
index 0000000..07718d2
--- /dev/null
+++ b/Player.ts
@@ -0,0 +1,15 @@
+///
+///
+
+import {Morph} from "./Morph";
+
+export class Player extends Morph {
+
+ constructor() {
+ let mat = new THREE.MeshBasicMaterial({
+ color: 0x00b0a0,
+ shading: THREE.SmoothShading
+ });
+ super(4, mat, 1);
+ }
+}
\ No newline at end of file
diff --git a/TargetCamera.ts b/TargetCamera.ts
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/TargetCamera.ts
@@ -0,0 +1 @@
+
diff --git a/World.ts b/World.ts
new file mode 100644
index 0000000..b3203be
--- /dev/null
+++ b/World.ts
@@ -0,0 +1,11 @@
+///
+///
+
+import {Player} from "./Player";
+
+export class World {
+
+ constructor(player: Player, scene:THREE.Scene, camera:THREE.Camera) {
+
+ }
+}
\ No newline at end of file
diff --git a/game.ts b/game.ts
new file mode 100644
index 0000000..8d5da32
--- /dev/null
+++ b/game.ts
@@ -0,0 +1,136 @@
+///
+///
+///
+
+import Vector3 = THREE.Vector3;
+class Morph extends Physijs.Mesh {
+ faces:number;
+ //TODO, probelm s tym ze ked extendujem Mesh, tak sa nedostanem k Geometry ale iba k BufferGeometry
+
+ constructor(numFaces:number, material:THREE.Material, mass:number) {
+ let geometry = Morph.generateGeometry(numFaces);
+ super(geometry, material, mass);
+ }
+
+ static generateGeometry(numFaces:number):THREE.Geometry {
+ if (numFaces == 4) {
+ return new THREE.TetrahedronGeometry();
+ } else if (numFaces == 6) {
+ return new THREE.BoxGeometry(1, 1, 1, 2, 2, 2);
+ } else if (numFaces == 12) {
+ return new THREE.DodecahedronGeometry(1, 0);
+ } else if (numFaces == 20) {
+ return new THREE.IcosahedronGeometry(1, 0);
+ }
+ return null;
+ }
+
+ private updateGeometry(numFaces:number) {
+ this.faces = numFaces;
+ this.geometry = Morph.generateGeometry(this.faces);
+ }
+
+ shrink(numFaces:number):void {
+ this.updateGeometry(this.faces - numFaces);
+ }
+
+ grow(numFaces:number):void {
+ this.updateGeometry(this.faces + numFaces);
+ }
+
+ wobble():void {
+
+ }
+
+}
+
+class Enemy extends Morph {
+
+ constructor() {
+ super(null, null, null);
+ //todo
+ }
+}
+
+class Player extends Morph {
+
+ constructor() {
+ let mat = new THREE.MeshBasicMaterial({
+ color: 0x00b0a0,
+ });
+ super(4, mat, 1);
+ }
+}
+
+class World {
+
+ constructor(player: Player, scene:THREE.Scene, camera:THREE.Camera) {
+ scene.add(player);
+ }
+}
+
+class Game {
+ renderer:THREE.WebGLRenderer;
+ scene:THREE.Scene;
+ camera:THREE.PerspectiveCamera;
+ player:Player;
+ world: World;
+ private ticks:number;
+ private running:boolean;
+
+ constructor() {
+ this.renderer = new THREE.WebGLRenderer({
+ antialias: true
+ });
+ this.renderer.setClearColor(0xffffff);
+ this.renderer.setPixelRatio(window.devicePixelRatio);
+ this.renderer.setSize(window.innerWidth, window.innerHeight);
+ document.body.appendChild(this.renderer.domElement);
+
+ this.scene = new THREE.Scene();
+ this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);
+ }
+
+ init():void {
+ //init world
+ this.player = new Player();
+ this.world = new World(this.player, this.scene, this.camera);
+ this.player.position.set(0,0,0);
+ this.camera.position.set(10,10,10);
+ this.camera.lookAt(this.player.position);
+ //init camera
+ }
+
+ render():void {
+ this.renderer.render(this.scene, this.camera);
+ }
+
+ tick():void {
+ this.ticks++;
+
+ }
+
+ run():void {
+ this.running = true;
+ while (this.running) {
+ this.tick();
+ let shouldRender = true;
+ if (shouldRender) {
+ this.render();
+ }
+
+ }
+ }
+
+}
+
+if (!Detector.webgl) {
+ Detector.addGetWebGLMessage();
+}
+
+window.onload = () => {
+ var game = new Game();
+ game.init();
+
+ //game.run();
+};
\ No newline at end of file
diff --git a/index.html b/index.html
index 9ebca2c..7eafeb6 100644
--- a/index.html
+++ b/index.html
@@ -3,10 +3,45 @@
Transmuto
-
-
+
+
+
-
+
+
+