CS-Coursework/websites/Typing/screens/endscreen.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-11-28 11:04:49 +00:00
/**
* @file This file provides a screen class that can be displayed at the end of a test
* @author Arlo Filley
*
* TODO:
* - provide the user with the data of the test that they have just
* completed, such as their wpm, accuracy, etc.
*/
/**
* This class is for a screen that is displayed at the end of a test,
* currently it just tells the user to press start to enter another test
*/
class EndScreen {
constructor() {
2022-11-18 14:51:05 +00:00
this.menu = new Menu();
}
draw() {
textSize(100);
textAlign(CENTER, CENTER);
2022-12-01 14:41:14 +00:00
fill(user.colorScheme.text);
2022-11-28 11:04:49 +00:00
text("Test Complete", 0, 0, windowWidth - 100, windowHeight / 6);
textSize(30);
text(`${user.lastTest.wpm} words per minute`, windowWidth / 2, 200);
text(`${user.lastTest.accuracy}% accuracy`, windowWidth / 2, 240);
text(`${user.lastTest.test_length} characters typed`, windowWidth / 2, 280);
text(`${user.lastTest.test_time}s`, windowWidth / 2, 320);
2022-11-18 14:51:05 +00:00
this.menu.draw();
}
2022-11-18 11:33:25 +00:00
letterTyped(key) {
2022-11-18 14:51:05 +00:00
if (key === "Enter") screenManager.setScreen(new TestScreen());
}
}