1
0
Fork 0

Cube Scramble: Improved UX and display solve time

master
nlisgo 2021-11-24 23:52:28 +00:00
parent e040cc4e24
commit 3c984f1fee
4 changed files with 25 additions and 10 deletions

View File

@ -551,7 +551,7 @@
{
"id": "cubescramble",
"name": "Cube Scramble",
"version":"0.03",
"version":"0.04",
"description": "A random scramble generator for the 3x3 Rubik's cube",
"icon": "cube-scramble.png",
"tags": "",

View File

@ -1,3 +1,4 @@
0.01: Initial Release
0.02: Replace icon with one found on https://icons8.com
0.03: Re-render icon fixing display in settings
0.04: Improved UX and display solve time

View File

@ -1,12 +1,11 @@
# Cube Scramble
A random scramble generator for the 3x3 Rubik's cube
A random scramble generator for the 3x3 Rubik's cube with a basic timer.
## Future features
I'm keen to complete this project with
* Add a timer
* Add the ability for times to be stored and exported
## Requests

View File

@ -1,4 +1,3 @@
// Scramble code from: https://raw.githubusercontent.com/bjcarlson42/blog-post-sample-code/master/Rubik's%20Cube%20JavaScript%20Scrambler/part_two.js
const makeScramble = () => {
const options = ["F", "F2", "F'", "R", "R2", "R'", "U", "U2", "U'", "B", "B2", "B'", "L", "L2", "L'", "D", "D2", "D'"];
@ -59,16 +58,32 @@ const getRandomInt = max => Math.floor(Math.random() * Math.floor(max)); // retu
const getRandomIntBetween = (min, max) => Math.floor(Math.random() * (max - min) + min);
const presentScramble = () => {
g.clear();
E.showMessage(makeScramble().join(" "));
E.showPrompt(makeScramble().join(" "), {
title: "cube scramble",
buttons: {"solve": true, "reset": false}
}).then((v) => {
if (v) {
const start = new Date();
E.showPrompt(" ", {
title: "cube scramble",
buttons: {"stop": true}
}).then(() => {
const time = parseFloat(((new Date()).getTime() - start.getTime()) / 1000);
E.showPrompt(String(time.toFixed(3)), {
title: "cube scramble",
buttons: {"next": true}
}).then(() => {
presentScramble();
});
});
} else {
presentScramble();
}
});
};
const init = () => {
presentScramble();
setWatch(() => {
presentScramble();
}, BTN1, {repeat:true});
};
init();