commit f3d23cd48c5788b6598a78b027dc47a9bc455c69
parent 34b827052a3444884b309cd935a19cab77d7d18c
Author: tongong <tongong@gmx.net>
Date: Thu, 8 Aug 2019 23:16:29 -0400
code clean-up
Diffstat:
3 files changed, 9 insertions(+), 42 deletions(-)
diff --git a/scripts/main.js b/scripts/main.js
@@ -19,7 +19,7 @@ function setup() {
CENTER = createVector(WIDTH / 2, HEIGHT / 2);
CENTER_HORIZON = createVector(0, 0);
LEFT_HORIZON = createVector(-500, 0);
- SIZE = ((HEIGHT>WIDTH)?WIDTH:HEIGHT)/2-20;
+ SIZE = ((HEIGHT>WIDTH)?WIDTH:HEIGHT)/2-50;
createCanvas(WIDTH, HEIGHT);
stroke(255);
@@ -35,53 +35,37 @@ function draw() {
switch (state) {
case 0:
- statePercentage = millis()/10;
- line(0,CENTER.y,CENTER.x*statePercentage/100,CENTER.y);
- line(2*CENTER.x,CENTER.y,CENTER.x*(2-statePercentage/100),CENTER.y);
- line(CENTER.x,0,CENTER.x,CENTER.y*statePercentage/100);
- line(CENTER.x,2*CENTER.y,CENTER.x,CENTER.y*(2-statePercentage/100));
+ statePercentage = millis()/20;
+ line(CENTER.x,HEIGHT,CENTER.x,CENTER.y*(2-statePercentage/100));
if (statePercentage >= 100) {
state = 1;
statePercentage = 0;
}
break;
case 1:
- statePercentage = millis()/10-100;
- line(CENTER.x,CENTER.y,CENTER.x*statePercentage/100,CENTER.y);
- line(CENTER.x,CENTER.y,CENTER.x*(2-statePercentage/100),CENTER.y);
- line(CENTER.x,CENTER.y,CENTER.x,CENTER.y*statePercentage/100);
- line(CENTER.x,CENTER.y,CENTER.x,CENTER.y*2);
- if (statePercentage >= 100) {
- state = 2;
- statePercentage = 0;
- }
- break;
- case 2:
statePercentage = millis()/10-200;
currentField.render(statePercentage/100*SIZE, SIZE, getRotation());
if (statePercentage >= 100) {
- endField.bottomHeight = 0;
- state = 3;
+ state = 2;
statePercentage = 0;
}
break;
- case 3:
+ case 2:
statePercentage = millis()/10-300;
currentField.transform(endField,0.1);
currentField.render(SIZE, SIZE, getRotation());
if (statePercentage >= 100) {
- state = 4;
+ state = 3;
statePercentage = 0;
currentField = currentField.scaleUp();
endField = currentField.addRandom(RANDOM_FACTOR);
}
break;
- case 4:
+ case 3:
statePercentage = millis()/10-100*(4+stateNumber);
currentField.transform(endField,0.1);
currentField.render(SIZE/pow(2,stateNumber+1), SIZE, getRotation());
if (statePercentage >= 100 && stateNumber < MAX_STATE-2) {
- state = 4;
statePercentage = 0;
stateNumber++;
currentField = currentField.scaleUp();
@@ -89,5 +73,4 @@ function draw() {
}
break;
}
- //drawWall(3, [{x:-100,y:100,z:100},{x:100,y:-100,z:100}],getRotation()*TWO_PI);
}
\ No newline at end of file
diff --git a/scripts/rotation.js b/scripts/rotation.js
@@ -8,7 +8,7 @@ var currentRotation = 0;
var mouseState = false;
function getRotation() {
- var aktMillis = millis();
+ let aktMillis = millis();
if (mouseIsPressed) {
if (!mouseState) {
startPress = mouseX + currentRotation * 1000;
@@ -16,7 +16,7 @@ function getRotation() {
startPressRotation = currentRotation;
mouseState = true;
}
- currentRotation = (mouseX - startPress) / -1000;
+ currentRotation = - (mouseX - startPress) / 1000;
} else {
if (mouseState) {
spin = (currentRotation - startPressRotation) / (millis() - startPressTime);
diff --git a/scripts/terrain.js b/scripts/terrain.js
@@ -3,7 +3,6 @@ class Terrain {
constructor(dimension, filled) {
this.dimension = dimension;
this.field = [];
- this.bottomHeight = 0.5;
let length = dimension*2-1;
for (let i = 0; i < length; i++) {
@@ -21,9 +20,6 @@ class Terrain {
this.field[i][j] += (destination.field[i][j] - this.field[i][j])*speed;
}
}
- if (this.bottomHeight != destination.bottomHeight) {
- this.bottomHeight += (destination.bottomHeight - this.bottomHeight)*speed;
- }
}
scaleUp() {
@@ -75,18 +71,6 @@ class Terrain {
}
}
- //Border points
- points.push(tri(createVector(
- this.dimension*scaleXY,
- 0,
- this.bottomHeight*scaleZ
- )));
- points.push(tri(createVector(
- 0,
- this.dimension*scaleXY,
- this.bottomHeight*scaleZ
- )));
-
//Terrain triangles
let polygons = [];
let modes = [];