iteration 3

This commit is contained in:
Arlo Filley 2022-12-16 00:34:58 +00:00
parent 445344061c
commit ed6830b39a
3 changed files with 16 additions and 6 deletions

View File

@ -286,7 +286,7 @@ class API {
let xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
xhr.open('GET', `${this.url}get_test/`); xhr.open('GET', `${this.url}get_test/`);
xhr.send(); xhr.send();
xhr.onload = () => { xhr.onload = () =>{
const effectiveWidth = (windowWidth - 200) / 13; const effectiveWidth = (windowWidth - 200) / 13;
let textArr = JSON.parse(xhr.response); let textArr = JSON.parse(xhr.response);
let finalText = []; let finalText = [];

View File

@ -84,8 +84,8 @@ class ProfileScreen {
for (let i = user.tests.length-1-offset; i >= user.tests.length-13-offset && i >= 0; i--) { for (let i = user.tests.length-1-offset; i >= user.tests.length-13-offset && i >= 0; i--) {
this.testButtons.push([ this.testButtons.push([
new Button(400, j, 100, 30, `${i+1}`, true, true , "#000", "#000", "#fff"), // test # button new Button(400, j, 100, 30, `${i+1}`, true, true , "#000", "#000", "#fff"), // test # button
new Button(500, j, 100, 30, `${user.tests[i].accuracy}`, true, true , "#000", "#000", "#fff"), // accuracy button new Button(500, j, 100, 30, `${user.tests[i].wpm}`, true, true , "#000", "#000", "#fff"), // accuracy button
new Button(600, j, 100, 30, `${user.tests[i].wpm}`, true, true , "#000", "#000", "#fff"), // wpm button new Button(600, j, 100, 30, `${user.tests[i].accuracy}`, true, true , "#000", "#000", "#fff"), // wpm button
new Button(700, j, 240, 30, `${user.tests[i].test_length}`, true, true , "#000", "#000", "#fff") new Button(700, j, 240, 30, `${user.tests[i].test_length}`, true, true , "#000", "#000", "#fff")
]) ])
j+=30; j+=30;

View File

@ -45,8 +45,9 @@ class Timer {
this.bar = pBar; this.bar = pBar;
this.startTime; this.startTime;
this.time = pTime; this.time = pTime;
this.timeElapsed; this.timeElapsed = 0;
this.ended; this.ended;
this.hasStarted = false;
} }
getX() { getX() {
@ -153,6 +154,7 @@ class Timer {
// I am using the amount of frames passed to calculate the time, assuming that the website is running at 60q frames // I am using the amount of frames passed to calculate the time, assuming that the website is running at 60q frames
// per second // per second
this.timeElapsed = 0; this.timeElapsed = 0;
this.hasStarted = true;
} }
/** /**
@ -201,12 +203,20 @@ class Timer {
// draws a bar that move across the screen to show the time left // draws a bar that move across the screen to show the time left
if (this.bar) { if (this.bar) {
fill(user.colorScheme.timerBar); fill(user.colorScheme.timerBar);
rect(this.y, this.x, windowWidth - windowWidth * (this.timeElapsed / this.time), this.height); if (this.hasStarted) {
rect(this.y, this.x, windowWidth - windowWidth * (this.timeElapsed / this.time), this.height);
} else {
rect(this.y, this.x, windowWidth, this.height);
}
} }
// draws the text in the corner of the screen // draws the text in the corner of the screen
noStroke(); noStroke();
fill(user.colorScheme.timerText); fill(user.colorScheme.timerText);
text(Math.ceil(this.time - this.timeElapsed), this.x + this.width / 6, this.y + this.height / 2) if (this.hasStarted) {
text(Math.ceil(this.time - this.timeElapsed), this.x + this.width / 6, this.y + this.height / 2);
} else {
text("Type A Letter To Start", this.x + this.width / 6, this.y + this.height / 2);
}
} }
} }