commit 6a1986c9450a325f40623156f566c6a8ae09bcb7
parent e9b1e23f5be13bf12ac680849a214bbd49e43e23
Author: tongong <tongong@gmx.net>
Date: Thu, 22 Aug 2019 16:47:33 +0200
reset works with all states
Diffstat:
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/scripts/interface.js b/scripts/interface.js
@@ -1,4 +1,4 @@
-var refreshTime;
+var refreshTime = 0;
function initIconAnimation() {
var reload = document.getElementById("reloadIcon");
@@ -11,10 +11,8 @@ function initIconAnimation() {
this.classList.remove("animated");
}, false);
reload.addEventListener("click", function() {
- if (state == 3) {
refreshTime = millis();
- state = 4;
- }
+ //state = 4;
}, false);
reload.addEventListener('touchstart', function() {
this.classList.add("animated");
diff --git a/scripts/main.js b/scripts/main.js
@@ -53,16 +53,25 @@ function initVars() {
state = 0;
addHeight = 0;
stateNumber = 0;
+ refreshTime = 0;
startMillis = millis();
}
function draw() {
background(80);
-
+
+ if (refreshTime != 0) {
+ addHeight = (millis() - refreshTime) / 1000 * HEIGHT;
+ if ((millis() - refreshTime) >= 1000) {
+ statePercentage = 0;
+ initVars();
+ }
+ }
+
switch (state) {
case 0:
statePercentage = time() / 20;
- line(CENTER.x, HEIGHT, CENTER.x, CENTER.y * (2 - statePercentage / 100));
+ line(CENTER.x, HEIGHT + addHeight, CENTER.x, CENTER.y * (2 - statePercentage / 100) + addHeight);
if (statePercentage >= 100) {
state = 1;
statePercentage = 0;
@@ -98,14 +107,5 @@ function draw() {
endField = currentField.addRandom(pow(RANDOM_FACTOR, stateNumber + 1));
}
break;
- case 4:
- statePercentage = (millis() - refreshTime) / 10;
- addHeight = statePercentage / 100 * HEIGHT;
- currentField.render(SIZE / pow(2, stateNumber + 1), SIZE, getRotation());
- if (statePercentage >= 100) {
- statePercentage = 0;
- initVars();
- }
- break;
}
}
\ No newline at end of file