added time menu

This commit is contained in:
Arlo Filley 2022-11-18 14:51:05 +00:00
parent 30784f5b36
commit b647ec727f
30 changed files with 92 additions and 429 deletions

View File

@ -1,19 +0,0 @@
# Details
Date : 2022-11-18 12:24:29
Directory /home/arlo/code/cs_coursework
Total : 4 files, 320 codes, 0 comments, 41 blanks, all 361 lines
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
## Files
| filename | language | code | comment | blank | total |
| :--- | :--- | ---: | ---: | ---: | ---: |
| [Cargo.toml](/Cargo.toml) | TOML | 9 | 0 | 2 | 11 |
| [Rocket.toml](/Rocket.toml) | TOML | 25 | 0 | 3 | 28 |
| [src/main.rs](/src/main.rs) | Rust | 87 | 0 | 10 | 97 |
| [src/sql.rs](/src/sql.rs) | Rust | 199 | 0 | 26 | 225 |
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)

View File

@ -1,15 +0,0 @@
# Diff Details
Date : 2022-11-18 12:24:29
Directory /home/arlo/code/cs_coursework
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
## Files
| filename | language | code | comment | blank | total |
| :--- | :--- | ---: | ---: | ---: | ---: |
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details

View File

@ -1,2 +0,0 @@
"filename", "language", "", "comment", "blank", "total"
"Total", "-", , 0, 0, 0
1 filename language comment blank total
2 Total - 0 0 0

View File

@ -1,19 +0,0 @@
# Diff Summary
Date : 2022-11-18 12:24:29
Directory /home/arlo/code/cs_coursework
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
## Languages
| language | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
## Directories
| path | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)

View File

@ -1,22 +0,0 @@
Date : 2022-11-18 12:24:29
Directory : /home/arlo/code/cs_coursework
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
Languages
+----------+------------+------------+------------+------------+------------+
| language | files | code | comment | blank | total |
+----------+------------+------------+------------+------------+------------+
+----------+------------+------------+------------+------------+------------+
Directories
+------+------------+------------+------------+------------+------------+
| path | files | code | comment | blank | total |
+------+------------+------------+------------+------------+------------+
+------+------------+------------+------------+------------+------------+
Files
+----------+----------+------------+------------+------------+------------+
| filename | language | code | comment | blank | total |
+----------+----------+------------+------------+------------+------------+
| Total | | 0 | 0 | 0 | 0 |
+----------+----------+------------+------------+------------+------------+

View File

@ -1,6 +0,0 @@
"filename", "language", "TOML", "Rust", "comment", "blank", "total"
"/home/arlo/code/cs_coursework/Cargo.toml", "TOML", 9, 0, 0, 2, 11
"/home/arlo/code/cs_coursework/Rocket.toml", "TOML", 25, 0, 0, 3, 28
"/home/arlo/code/cs_coursework/src/main.rs", "Rust", 0, 87, 0, 10, 97
"/home/arlo/code/cs_coursework/src/sql.rs", "Rust", 0, 199, 0, 26, 225
"Total", "-", 34, 286, 0, 41, 361
1 filename language TOML Rust comment blank total
2 /home/arlo/code/cs_coursework/Cargo.toml TOML 9 0 0 2 11
3 /home/arlo/code/cs_coursework/Rocket.toml TOML 25 0 0 3 28
4 /home/arlo/code/cs_coursework/src/main.rs Rust 0 87 0 10 97
5 /home/arlo/code/cs_coursework/src/sql.rs Rust 0 199 0 26 225
6 Total - 34 286 0 41 361

View File

@ -1 +0,0 @@
{"file:///home/arlo/code/cs_coursework/Cargo.toml":{"language":"TOML","code":9,"comment":0,"blank":2},"file:///home/arlo/code/cs_coursework/Rocket.toml":{"language":"TOML","code":25,"comment":0,"blank":3},"file:///home/arlo/code/cs_coursework/src/sql.rs":{"language":"Rust","code":199,"comment":0,"blank":26},"file:///home/arlo/code/cs_coursework/src/main.rs":{"language":"Rust","code":87,"comment":0,"blank":10}}

View File

@ -1,23 +0,0 @@
# Summary
Date : 2022-11-18 12:24:29
Directory /home/arlo/code/cs_coursework
Total : 4 files, 320 codes, 0 comments, 41 blanks, all 361 lines
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
## Languages
| language | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
| Rust | 2 | 286 | 0 | 36 | 322 |
| TOML | 2 | 34 | 0 | 5 | 39 |
## Directories
| path | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
| . | 4 | 320 | 0 | 41 | 361 |
| src | 2 | 286 | 0 | 36 | 322 |
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)

View File

@ -1,30 +0,0 @@
Date : 2022-11-18 12:24:29
Directory : /home/arlo/code/cs_coursework
Total : 4 files, 320 codes, 0 comments, 41 blanks, all 361 lines
Languages
+----------+------------+------------+------------+------------+------------+
| language | files | code | comment | blank | total |
+----------+------------+------------+------------+------------+------------+
| Rust | 2 | 286 | 0 | 36 | 322 |
| TOML | 2 | 34 | 0 | 5 | 39 |
+----------+------------+------------+------------+------------+------------+
Directories
+-------------------------------------------+------------+------------+------------+------------+------------+
| path | files | code | comment | blank | total |
+-------------------------------------------+------------+------------+------------+------------+------------+
| . | 4 | 320 | 0 | 41 | 361 |
| src | 2 | 286 | 0 | 36 | 322 |
+-------------------------------------------+------------+------------+------------+------------+------------+
Files
+-------------------------------------------+----------+------------+------------+------------+------------+
| filename | language | code | comment | blank | total |
+-------------------------------------------+----------+------------+------------+------------+------------+
| /home/arlo/code/cs_coursework/Cargo.toml | TOML | 9 | 0 | 2 | 11 |
| /home/arlo/code/cs_coursework/Rocket.toml | TOML | 25 | 0 | 3 | 28 |
| /home/arlo/code/cs_coursework/src/main.rs | Rust | 87 | 0 | 10 | 97 |
| /home/arlo/code/cs_coursework/src/sql.rs | Rust | 199 | 0 | 26 | 225 |
| Total | | 320 | 0 | 41 | 361 |
+-------------------------------------------+----------+------------+------------+------------+------------+

View File

@ -1,19 +0,0 @@
# Details
Date : 2022-11-18 12:25:12
Directory /home/arlo/code/cs_coursework
Total : 4 files, 315 codes, 5 comments, 41 blanks, all 361 lines
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
## Files
| filename | language | code | comment | blank | total |
| :--- | :--- | ---: | ---: | ---: | ---: |
| [Cargo.toml](/Cargo.toml) | TOML | 9 | 0 | 2 | 11 |
| [Rocket.toml](/Rocket.toml) | TOML | 21 | 4 | 3 | 28 |
| [src/main.rs](/src/main.rs) | Rust | 86 | 1 | 10 | 97 |
| [src/sql.rs](/src/sql.rs) | Rust | 199 | 0 | 26 | 225 |
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)

View File

@ -1,17 +0,0 @@
# Diff Details
Date : 2022-11-18 12:25:12
Directory /home/arlo/code/cs_coursework
Total : 2 files, -5 codes, 5 comments, 0 blanks, all 0 lines
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
## Files
| filename | language | code | comment | blank | total |
| :--- | :--- | ---: | ---: | ---: | ---: |
| [Rocket.toml](/Rocket.toml) | TOML | -4 | 4 | 0 | 0 |
| [src/main.rs](/src/main.rs) | Rust | -1 | 1 | 0 | 0 |
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details

View File

@ -1,4 +0,0 @@
"filename", "language", "TOML", "Rust", "comment", "blank", "total"
"/home/arlo/code/cs_coursework/Rocket.toml", "TOML", -4, 0, 4, 0, 0
"/home/arlo/code/cs_coursework/src/main.rs", "Rust", 0, -1, 1, 0, 0
"Total", "-", -4, -1, 5, 0, 0
1 filename language TOML Rust comment blank total
2 /home/arlo/code/cs_coursework/Rocket.toml TOML -4 0 4 0 0
3 /home/arlo/code/cs_coursework/src/main.rs Rust 0 -1 1 0 0
4 Total - -4 -1 5 0 0

View File

@ -1,23 +0,0 @@
# Diff Summary
Date : 2022-11-18 12:25:12
Directory /home/arlo/code/cs_coursework
Total : 2 files, -5 codes, 5 comments, 0 blanks, all 0 lines
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
## Languages
| language | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
| Rust | 1 | -1 | 1 | 0 | 0 |
| TOML | 1 | -4 | 4 | 0 | 0 |
## Directories
| path | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
| . | 2 | -5 | 5 | 0 | 0 |
| src | 1 | -1 | 1 | 0 | 0 |
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)

View File

@ -1,28 +0,0 @@
Date : 2022-11-18 12:25:12
Directory : /home/arlo/code/cs_coursework
Total : 2 files, -5 codes, 5 comments, 0 blanks, all 0 lines
Languages
+----------+------------+------------+------------+------------+------------+
| language | files | code | comment | blank | total |
+----------+------------+------------+------------+------------+------------+
| Rust | 1 | -1 | 1 | 0 | 0 |
| TOML | 1 | -4 | 4 | 0 | 0 |
+----------+------------+------------+------------+------------+------------+
Directories
+-------------------------------------------+------------+------------+------------+------------+------------+
| path | files | code | comment | blank | total |
+-------------------------------------------+------------+------------+------------+------------+------------+
| . | 2 | -5 | 5 | 0 | 0 |
| src | 1 | -1 | 1 | 0 | 0 |
+-------------------------------------------+------------+------------+------------+------------+------------+
Files
+-------------------------------------------+----------+------------+------------+------------+------------+
| filename | language | code | comment | blank | total |
+-------------------------------------------+----------+------------+------------+------------+------------+
| /home/arlo/code/cs_coursework/Rocket.toml | TOML | -4 | 4 | 0 | 0 |
| /home/arlo/code/cs_coursework/src/main.rs | Rust | -1 | 1 | 0 | 0 |
| Total | | -5 | 5 | 0 | 0 |
+-------------------------------------------+----------+------------+------------+------------+------------+

View File

@ -1,6 +0,0 @@
"filename", "language", "TOML", "Rust", "comment", "blank", "total"
"/home/arlo/code/cs_coursework/Cargo.toml", "TOML", 9, 0, 0, 2, 11
"/home/arlo/code/cs_coursework/Rocket.toml", "TOML", 21, 0, 4, 3, 28
"/home/arlo/code/cs_coursework/src/main.rs", "Rust", 0, 86, 1, 10, 97
"/home/arlo/code/cs_coursework/src/sql.rs", "Rust", 0, 199, 0, 26, 225
"Total", "-", 30, 285, 5, 41, 361
1 filename language TOML Rust comment blank total
2 /home/arlo/code/cs_coursework/Cargo.toml TOML 9 0 0 2 11
3 /home/arlo/code/cs_coursework/Rocket.toml TOML 21 0 4 3 28
4 /home/arlo/code/cs_coursework/src/main.rs Rust 0 86 1 10 97
5 /home/arlo/code/cs_coursework/src/sql.rs Rust 0 199 0 26 225
6 Total - 30 285 5 41 361

View File

@ -1 +0,0 @@
{"file:///home/arlo/code/cs_coursework/Cargo.toml":{"language":"TOML","code":9,"comment":0,"blank":2},"file:///home/arlo/code/cs_coursework/Rocket.toml":{"language":"TOML","code":21,"comment":4,"blank":3},"file:///home/arlo/code/cs_coursework/src/sql.rs":{"language":"Rust","code":199,"comment":0,"blank":26},"file:///home/arlo/code/cs_coursework/src/main.rs":{"language":"Rust","code":86,"comment":1,"blank":10}}

View File

@ -1,23 +0,0 @@
# Summary
Date : 2022-11-18 12:25:12
Directory /home/arlo/code/cs_coursework
Total : 4 files, 315 codes, 5 comments, 41 blanks, all 361 lines
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
## Languages
| language | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
| Rust | 2 | 285 | 1 | 36 | 322 |
| TOML | 2 | 30 | 4 | 5 | 39 |
## Directories
| path | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
| . | 4 | 315 | 5 | 41 | 361 |
| src | 2 | 285 | 1 | 36 | 322 |
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)

View File

@ -1,30 +0,0 @@
Date : 2022-11-18 12:25:12
Directory : /home/arlo/code/cs_coursework
Total : 4 files, 315 codes, 5 comments, 41 blanks, all 361 lines
Languages
+----------+------------+------------+------------+------------+------------+
| language | files | code | comment | blank | total |
+----------+------------+------------+------------+------------+------------+
| Rust | 2 | 285 | 1 | 36 | 322 |
| TOML | 2 | 30 | 4 | 5 | 39 |
+----------+------------+------------+------------+------------+------------+
Directories
+-------------------------------------------+------------+------------+------------+------------+------------+
| path | files | code | comment | blank | total |
+-------------------------------------------+------------+------------+------------+------------+------------+
| . | 4 | 315 | 5 | 41 | 361 |
| src | 2 | 285 | 1 | 36 | 322 |
+-------------------------------------------+------------+------------+------------+------------+------------+
Files
+-------------------------------------------+----------+------------+------------+------------+------------+
| filename | language | code | comment | blank | total |
+-------------------------------------------+----------+------------+------------+------------+------------+
| /home/arlo/code/cs_coursework/Cargo.toml | TOML | 9 | 0 | 2 | 11 |
| /home/arlo/code/cs_coursework/Rocket.toml | TOML | 21 | 4 | 3 | 28 |
| /home/arlo/code/cs_coursework/src/main.rs | Rust | 86 | 1 | 10 | 97 |
| /home/arlo/code/cs_coursework/src/sql.rs | Rust | 199 | 0 | 26 | 225 |
| Total | | 315 | 5 | 41 | 361 |
+-------------------------------------------+----------+------------+------------+------------+------------+

View File

@ -6,5 +6,6 @@ class User {
this.tests;
this.leaderboard;
this.nextTest = `satisfy powerful pleasant bells disastrous mean kited is gusted romantic past taste immolate productive leak close show crabby awake handsails finicky betray long-term incompetent wander show manage toys convey hop constitute number send like off ice aboard well-made vast vacuous tramp seed force divergent flower porter fire untidy soggy fetch`;
this.time = 15;
}
}

View File

@ -22,6 +22,7 @@
<script src="./ui_elements/textbox.js"></script>
<script src="./ui_elements/timemenu.js"></script>
<script src="./ui_elements/timer.js"></script>
<script src="./ui_elements/menu.js"></script>
<!-- Screen Files-->
<script src="./screens/screenmanager.js"></script>

View File

@ -1,13 +1,6 @@
class EndScreen {
constructor() {
this.buttons = [
new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
new Button(440,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
new Button(550,0,140,30,0,true,"#fff",false,"#000","#000","Leaderboard"),
]
this.menu = new Menu();
}
draw() {
@ -16,26 +9,10 @@ class EndScreen {
textAlign(CENTER, CENTER);
fill(0);
text("Test Complete\nPress enter to start another test", 0, 0, windowWidth - 100, windowHeight - 100);
for (let i = 0; i < this.buttons.length; i++) {
this.buttons[i].draw()
}
if (this.buttons[0].isPressed()) {
screenManager.setScreen(new SignUpScreen());
} else if (this.buttons[1].isPressed()) {
screenManager.setScreen(new LoginScreen());
} else if (this.buttons[2].isPressed()) {
api.logout();
} else if (this.buttons[3].isPressed()) {
screenManager.setScreen(new ProfileScreen());
} else if (this.buttons[4].isPressed()) {
screenManager.setScreen(new TestScreen())
} else if (this.buttons[5].isPressed()) {
screenManager.setScreen(new LeaderboardScreen())
}
this.menu.draw();
}
letterTyped(key) {
if (key === "ENTER") screenManager.setScreen(new StartScreen());
if (key === "Enter") screenManager.setScreen(new TestScreen());
}
}

View File

@ -1,13 +1,6 @@
class LeaderboardScreen {
constructor() {
this.buttons = [
new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
new Button(440,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
new Button(550,0,140,30,0,true,"#fff",false,"#000","#000","Leaderboard"),
];
this.menu = new Menu();
api.getLeaderBoard()
}
@ -17,23 +10,7 @@ class LeaderboardScreen {
textAlign(CENTER, CENTER);
fill("#000");
text("Leaderboard", 0, 100, windowWidth, 120);
for (let i = 0; i < this.buttons.length; i++) {
this.buttons[i].draw()
}
if (this.buttons[0].isPressed()) {
screenManager.setScreen(new SignUpScreen());
} else if (this.buttons[1].isPressed()) {
screenManager.setScreen(new LoginScreen());
} else if (this.buttons[2].isPressed()) {
api.logout();
} else if (this.buttons[3].isPressed()) {
screenManager.setScreen(new ProfileScreen());
} else if (this.buttons[4].isPressed()) {
screenManager.setScreen(new TestScreen())
} else if (this.buttons[5].isPressed()) {
screenManager.setScreen(new LeaderboardScreen())
}
this.menu.draw();
textSize(20);
fill("#000");

View File

@ -54,15 +54,10 @@ class LoginScreen {
false,"#000",
"#00ff00","Login"
),
new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
new Button(440,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
new Button(550,0,140,30,0,true,"#fff",false,"#000","#000","Leaderboard"),
]
this.menu = new Menu();
this.activeTextBox = 0
// keeps track of which textbox the user last clicked on
}
@ -99,20 +94,7 @@ class LoginScreen {
)
screenManager.setScreen(new StartScreen());
}
if (this.buttons[3].isPressed()) {
screenManager.setScreen(new SignUpScreen());
} else if (this.buttons[4].isPressed()) {
screenManager.setScreen(new LoginScreen());
} else if (this.buttons[5].isPressed()) {
api.logout();
} else if (this.buttons[6].isPressed()) {
screenManager.setScreen(new ProfileScreen());
} else if (this.buttons[7].isPressed()) {
screenManager.setScreen(new TestScreen())
} else if (this.buttons[8].isPressed()) {
screenManager.setScreen(new LeaderboardScreen())
}
this.menu.draw();
}
/**

View File

@ -1,13 +1,6 @@
class ProfileScreen {
constructor() {
this.buttons = [
new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
new Button(440,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
new Button(550,0,140,30,0,true,"#fff",false,"#000","#000","Leaderboard"),
];
this.menu = new Menu();
api.getUserTests();
}
@ -18,28 +11,13 @@ class ProfileScreen {
fill("#000");
text("Profile", 0, 100, windowWidth, 120);
for (let i = 0; i < this.buttons.length; i++) {
this.buttons[i].draw()
}
if (this.buttons[0].isPressed()) {
screenManager.setScreen(new SignUpScreen());
} else if (this.buttons[1].isPressed()) {
screenManager.setScreen(new LoginScreen());
} else if (this.buttons[2].isPressed()) {
api.logout();
} else if (this.buttons[3].isPressed()) {
screenManager.setScreen(new ProfileScreen());
} else if (this.buttons[4].isPressed()) {
screenManager.setScreen(new TestScreen())
} else if (this.buttons[5].isPressed()) {
screenManager.setScreen(new LeaderboardScreen())
}
this.menu.draw();
textSize(20);
fill("#000");
if (user.tests != undefined) {
for (let i = 0; i < user.tests.length; i++) {
text(`Tests ${i+1}: ${user.tests[i].wpm}wpm | Type: ${user.tests[i].test_type} | Time: ${user.tests[i].test_time} | Characters Typed: ${user.tests[i].test_length}`, 0, i*30+300, windowWidth, 30);
text(`Test ${i+1}: ${user.tests[i].wpm}wpm | Characters Typed: ${user.tests[i].test_length}`, 0, i*30+300, windowWidth, 30);
}
}
fill("#000");

View File

@ -54,14 +54,10 @@ class SignUpScreen {
false,"#000",
"#00ff00","Sign Up"
),
new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
new Button(440,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
new Button(550,0,140,30,0,true,"#fff",false,"#000","#000","Leaderboard"),
]
this.menu = new Menu();
this.activeTextBox = 0
// keeps track of which textbox the user last clicked on
}
@ -98,19 +94,8 @@ class SignUpScreen {
this.textboxes[1].getWords()
)
screenManager.setScreen(new StartScreen());
} else if (this.buttons[3].isPressed()) {
screenManager.setScreen(new SignUpScreen());
} else if (this.buttons[4].isPressed()) {
screenManager.setScreen(new LoginScreen());
} else if (this.buttons[5].isPressed()) {
api.logout();
} else if (this.buttons[6].isPressed()) {
screenManager.setScreen(new ProfileScreen());
} else if (this.buttons[7].isPressed()) {
screenManager.setScreen(new TestScreen())
} else if (this.buttons[8].isPressed()) {
screenManager.setScreen(new LeaderboardScreen())
}
}
this.menu.draw();
}
/**

View File

@ -1,13 +1,6 @@
class StartScreen {
constructor() {
this.buttons = [
new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
new Button(440,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
new Button(550,0,140,30,0,true,"#fff",false,"#000","#000","Leaderboard"),
]
this.menu = new Menu();
}
draw() {
@ -17,22 +10,7 @@ class StartScreen {
fill("#000");
text("Press enter to start test", 0, 0, windowWidth - 100, windowHeight - 100);
for (let i = 0; i < this.buttons.length; i++) {
this.buttons[i].draw()
}
if (this.buttons[0].isPressed()) {
screenManager.setScreen(new SignUpScreen());
} else if (this.buttons[1].isPressed()) {
screenManager.setScreen(new LoginScreen());
} else if (this.buttons[2].isPressed()) {
api.logout();
} else if (this.buttons[3].isPressed()) {
screenManager.setScreen(new ProfileScreen());
} else if (this.buttons[4].isPressed()) {
screenManager.setScreen(new TestScreen());
} else if (this.buttons[5].isPressed()) {
screenManager.setScreen(new LeaderboardScreen())
}
this.menu.draw();
fill("#000");
text(`Logged in as ${user.username}`, windowWidth-400, 15);

View File

@ -1,7 +1,7 @@
class TestScreen {
constructor() {
this.textbox = new Textbox(100,100,windowWidth - 200,windowHeight,0,true,"#000", false, "#000", "#000", true, true);
screenManager.timer = new Timer(0,0,windowWidth,50,0,true,"#fff", true, "#000", "#666", 15, true);
screenManager.timer = new Timer(0,0,windowWidth,50,0,true,"#fff", true, "#000", "#666", user.time, true);
screenManager.timer.start();
}

View File

@ -0,0 +1,35 @@
class Menu {
constructor() {
this.buttons = [
new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
new Button(440,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
new Button(550,0,140,30,0,true,"#fff",false,"#000","#000","Leaderboard"),
]
this.timeMenu = new TimeMenu();
}
draw() {
for (let i = 0; i < this.buttons.length; i++) {
this.buttons[i].draw()
}
if (this.buttons[0].isPressed()) {
screenManager.setScreen(new SignUpScreen());
} else if (this.buttons[1].isPressed()) {
screenManager.setScreen(new LoginScreen());
} else if (this.buttons[2].isPressed()) {
api.logout();
} else if (this.buttons[3].isPressed()) {
screenManager.setScreen(new ProfileScreen());
} else if (this.buttons[4].isPressed()) {
screenManager.setScreen(new TestScreen())
} else if (this.buttons[5].isPressed()) {
screenManager.setScreen(new LeaderboardScreen())
}
this.timeMenu.draw();
}
}

View File

@ -1,5 +1,41 @@
class TimeMenu {
constructor() {
this.buttons = [
new Button(660,0,100,30,0,true,"#fff",false,"#000","#000","15s"),
new Button(660,30,100,30,0,true,"#fff",false,"#000","#000","30s"),
new Button(660,60,100,30,0,true,"#fff",false,"#000","#000","45s"),
new Button(660,90,100,30,0,true,"#fff",false,"#000","#000","60s"),
];
this.dropdown = false;
}
draw() {
this.buttons[0].draw();
if (this.dropdown) {
for (let i = 0; i < this.buttons.length; i++) {
this.buttons[i].draw()
if (this.buttons[0].isPressed() && user.time != 15) {
user.time = 15;
this.dropdown = false;
} else if (this.buttons[1].isPressed()) {
user.time = 30;
this.dropdown = false;
} else if (this.buttons[2].isPressed()) {
user.time = 45;
this.dropdown = false;
} else if (this.buttons[3].isPressed()) {
user.time = 60;
this.dropdown = false;
}
}
}
if (this.buttons[0].isPressed()) {
this.dropdown = true;
} else if (mouseIsPressed) {
this.dropdown = false;
}
}
}

View File

@ -156,6 +156,7 @@ class Timer {
api.validateTest();
this.timeElapsed = 0;
this.time = 0;
api.getTest();
// 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
screenManager.setScreen(new EndScreen());