added an endscreen for multiple tests in a row

This commit is contained in:
Arlo Filley 2022-10-11 10:29:40 +01:00
parent c2cd889fdd
commit a36c8759c1
4 changed files with 26 additions and 6 deletions

View File

@ -39,10 +39,10 @@ class API {
* Validates all the parameters used for the postTest function which it then calls * Validates all the parameters used for the postTest function which it then calls
*/ */
validateTest() { validateTest() {
const test = textbox.getLetters(); const test = screenManager.textbox.getLetters();
const testType = "words"; const testType = "words";
let testLength = test.length; let testLength = test.length;
let testTime = timer.getTime(); let testTime = screenManager.timer.getTime();
const testSeed = 0; const testSeed = 0;
const quoteId = 0; const quoteId = 0;
let wpm; let wpm;

View File

@ -0,0 +1,13 @@
class EndScreen {
constructor() {
screenManager.textbox = new Textbox(0,0,0,0,0,false,"#000", false, "#000", "#000");
}
draw() {
background("#eeeee4");
textSize(100);
textAlign(CENTER, CENTER);
fill(0);
text("Test Complete\nPress enter to start another test", 0, 0, windowWidth - 100, windowHeight - 100);
}
}

View File

@ -109,8 +109,7 @@ class Textbox {
} }
letterTyped(pKey) { letterTyped(pKey) {
console.log(pKey); if (pKey === "Enter" && (screenManager.screen.constructor.name === "StartScreen" || screenManager.screen.constructor.name === "EndScreen")) {
if (pKey === "Enter" && screenManager.screen.constructor.name === "StartScreen") {
screenManager.setScreen(new TestScreen()); screenManager.setScreen(new TestScreen());
return; return;
} }
@ -146,12 +145,19 @@ class Textbox {
draw() { draw() {
// doesn't render the textbox if it should not be visible to the user. // doesn't render the textbox if it should not be visible to the user.
if (this.visible === false) { if (!this.visible) {
return; return;
} }
noStroke();
// sets a border if there should be one
if (this.border) {
stroke(this.borderColor);
strokeWeight(1);
}
// sets the parameters of what the text should look like; // sets the parameters of what the text should look like;
color(this.textColor); fill(this.textColor);
textSize(23); textSize(23);
textAlign(LEFT); textAlign(LEFT);
// font needs to be monospaced for outputting text to the screen like I do // font needs to be monospaced for outputting text to the screen like I do

View File

@ -158,6 +158,7 @@ class Timer {
this.time = 0; this.time = 0;
// Then this function will call all other functions necessary to complete the test // Then this function will call all other functions necessary to complete the test
// this will likely including changing the screen and interacting with the api // this will likely including changing the screen and interacting with the api
screenManager.setScreen(new EndScreen());
} }
/** /**