diff --git a/.VSCodeCounter/2022-11-18_12-24-29/details.md b/.VSCodeCounter/2022-11-18_12-24-29/details.md new file mode 100644 index 0000000..ed43d2a --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-24-29/details.md @@ -0,0 +1,19 @@ +# 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) \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-24-29/diff-details.md b/.VSCodeCounter/2022-11-18_12-24-29/diff-details.md new file mode 100644 index 0000000..6296cb1 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-24-29/diff-details.md @@ -0,0 +1,15 @@ +# 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 \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-24-29/diff.csv b/.VSCodeCounter/2022-11-18_12-24-29/diff.csv new file mode 100644 index 0000000..b7d8d75 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-24-29/diff.csv @@ -0,0 +1,2 @@ +"filename", "language", "", "comment", "blank", "total" +"Total", "-", , 0, 0, 0 \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-24-29/diff.md b/.VSCodeCounter/2022-11-18_12-24-29/diff.md new file mode 100644 index 0000000..fbd9480 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-24-29/diff.md @@ -0,0 +1,19 @@ +# 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) \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-24-29/diff.txt b/.VSCodeCounter/2022-11-18_12-24-29/diff.txt new file mode 100644 index 0000000..b807794 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-24-29/diff.txt @@ -0,0 +1,22 @@ +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 | ++----------+----------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-24-29/results.csv b/.VSCodeCounter/2022-11-18_12-24-29/results.csv new file mode 100644 index 0000000..3cf4b9b --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-24-29/results.csv @@ -0,0 +1,6 @@ +"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 \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-24-29/results.json b/.VSCodeCounter/2022-11-18_12-24-29/results.json new file mode 100644 index 0000000..56673ba --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-24-29/results.json @@ -0,0 +1 @@ +{"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}} \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-24-29/results.md b/.VSCodeCounter/2022-11-18_12-24-29/results.md new file mode 100644 index 0000000..4c461ca --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-24-29/results.md @@ -0,0 +1,23 @@ +# 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) \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-24-29/results.txt b/.VSCodeCounter/2022-11-18_12-24-29/results.txt new file mode 100644 index 0000000..b072b08 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-24-29/results.txt @@ -0,0 +1,30 @@ +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 | ++-------------------------------------------+----------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-25-12/details.md b/.VSCodeCounter/2022-11-18_12-25-12/details.md new file mode 100644 index 0000000..c4bb011 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-25-12/details.md @@ -0,0 +1,19 @@ +# 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) \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-25-12/diff-details.md b/.VSCodeCounter/2022-11-18_12-25-12/diff-details.md new file mode 100644 index 0000000..f30d590 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-25-12/diff-details.md @@ -0,0 +1,17 @@ +# 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 \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-25-12/diff.csv b/.VSCodeCounter/2022-11-18_12-25-12/diff.csv new file mode 100644 index 0000000..acc5aa4 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-25-12/diff.csv @@ -0,0 +1,4 @@ +"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 \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-25-12/diff.md b/.VSCodeCounter/2022-11-18_12-25-12/diff.md new file mode 100644 index 0000000..6e845fd --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-25-12/diff.md @@ -0,0 +1,23 @@ +# 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) \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-25-12/diff.txt b/.VSCodeCounter/2022-11-18_12-25-12/diff.txt new file mode 100644 index 0000000..b239117 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-25-12/diff.txt @@ -0,0 +1,28 @@ +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 | ++-------------------------------------------+----------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-25-12/results.csv b/.VSCodeCounter/2022-11-18_12-25-12/results.csv new file mode 100644 index 0000000..78f71e8 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-25-12/results.csv @@ -0,0 +1,6 @@ +"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 \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-25-12/results.json b/.VSCodeCounter/2022-11-18_12-25-12/results.json new file mode 100644 index 0000000..2b89ba5 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-25-12/results.json @@ -0,0 +1 @@ +{"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}} \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-25-12/results.md b/.VSCodeCounter/2022-11-18_12-25-12/results.md new file mode 100644 index 0000000..1101149 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-25-12/results.md @@ -0,0 +1,23 @@ +# 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) \ No newline at end of file diff --git a/.VSCodeCounter/2022-11-18_12-25-12/results.txt b/.VSCodeCounter/2022-11-18_12-25-12/results.txt new file mode 100644 index 0000000..19f2cc1 --- /dev/null +++ b/.VSCodeCounter/2022-11-18_12-25-12/results.txt @@ -0,0 +1,30 @@ +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 | ++-------------------------------------------+----------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/website/api/api.js b/website/api/api.js index 767415b..c98fc5d 100644 --- a/website/api/api.js +++ b/website/api/api.js @@ -63,11 +63,19 @@ class API { let wpm; const accuracy = 0; const userId = Number(user.userId); + let test_content = screenManager.screen.textbox.testContent; + + let string = ""; + for (let letter = 0; letter < test.length; letter++) { + if (test[letter] === test_content[letter]) { + string += test[letter]; + } + } // this is the wpm calculation factoring in the time of test // it assumes that all words are 5 characters long because on average // they are - wpm = Math.round((testLength / 5) * (60 / testTime)); + wpm = Math.round((string.length / 5) * (60 / testTime)); // the following code is a series of if statements that checks the // types of the variables is correct if not it errors it and returns @@ -238,4 +246,18 @@ class API { user.leaderboard = JSON.parse(xhr.response); }; } + + getTest() { + let xhr = new XMLHttpRequest(); + xhr.open('GET', `https://random-word-api.herokuapp.com/word?number=100`); + xhr.send(); + xhr.onload = () => { + let textArr = JSON.parse(xhr.response); + let text = ""; + for (let i = 0; i < textArr.length; i++) { + text += `${textArr[i]} ` + } + user.nextTest = text; + }; + } } \ No newline at end of file diff --git a/website/api/user.js b/website/api/user.js index 5e0390c..f94fa94 100644 --- a/website/api/user.js +++ b/website/api/user.js @@ -5,5 +5,6 @@ class User { this.userId = 0; 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`; } } \ No newline at end of file diff --git a/website/index.js b/website/index.js index 96b7794..bb29d32 100644 --- a/website/index.js +++ b/website/index.js @@ -19,6 +19,7 @@ function setup() { // will log the user in if there details are in local storage api.login(); + api.getTest(); textFont(roboto); } diff --git a/website/screens/leaderboardscreen.js b/website/screens/leaderboardscreen.js index 4f6b3fb..478f89e 100644 --- a/website/screens/leaderboardscreen.js +++ b/website/screens/leaderboardscreen.js @@ -43,6 +43,6 @@ class LeaderboardScreen { } } fill("#000"); - text(`Logged in as ${user.username}`, windowWidth-100, 15); + text(`Logged in as ${user.username}`, windowWidth-400, 15); } } \ No newline at end of file diff --git a/website/screens/loginscreen.js b/website/screens/loginscreen.js index a5ba925..b9b9069 100644 --- a/website/screens/loginscreen.js +++ b/website/screens/loginscreen.js @@ -8,7 +8,8 @@ class LoginScreen { true, "#000", false, "#000", - "#000" + "#000", + true ), new Textbox( @@ -18,7 +19,8 @@ class LoginScreen { true, "#000", false,"000", - "#000" + "#000", + false ) ] @@ -83,9 +85,13 @@ class LoginScreen { text("Password", 110, 325); if (this.buttons[0].isPressed()) { + this.textboxes[this.activeTextBox].line = false; this.activeTextBox=0; + this.textboxes[this.activeTextBox].line = true; } else if (this.buttons[1].isPressed()) { + this.textboxes[this.activeTextBox].line = false; this.activeTextBox=1; + this.textboxes[this.activeTextBox].line = true; } else if (this.buttons[2].isPressed()) { api.login( this.textboxes[0].getWords(), @@ -114,6 +120,22 @@ class LoginScreen { * @param {key} key */ letterTyped(key) { - this.textboxes[this.activeTextBox].letterTyped(key); + if (key === "Tab" && this.activeTextBox === 0) { + this.textboxes[this.activeTextBox].line = false; + this.activeTextBox=1; + this.textboxes[this.activeTextBox].line = true; + } else if (key === "Tab" && this.activeTextBox === 1) { + this.textboxes[this.activeTextBox].line = false; + this.activeTextBox=0; + this.textboxes[this.activeTextBox].line = true; + } else if (key === "Enter") { + api.login( + this.textboxes[0].getWords(), + this.textboxes[1].getWords() + ) + screenManager.setScreen(new StartScreen()); + } else { + this.textboxes[this.activeTextBox].letterTyped(key); + } } } \ No newline at end of file diff --git a/website/screens/profilescreen.js b/website/screens/profilescreen.js index 82ae277..20c8f76 100644 --- a/website/screens/profilescreen.js +++ b/website/screens/profilescreen.js @@ -43,6 +43,6 @@ class ProfileScreen { } } fill("#000"); - text(`Logged in as ${user.username}`, windowWidth-100, 15); + text(`Logged in as ${user.username}`, windowWidth-400, 15); } } \ No newline at end of file diff --git a/website/screens/signUpScreen.js b/website/screens/signUpScreen.js index 12dd24d..ab3d16e 100644 --- a/website/screens/signUpScreen.js +++ b/website/screens/signUpScreen.js @@ -8,7 +8,8 @@ class SignUpScreen { true, "#000", false, "#000", - "#000" + "#000", + true ), new Textbox( @@ -18,7 +19,8 @@ class SignUpScreen { true, "#000", false,"000", - "#000" + "#000", + false ) ] @@ -83,9 +85,13 @@ class SignUpScreen { text("Password", 110, 325); if (this.buttons[0].isPressed()) { + this.textboxes[this.activeTextBox].line = false; this.activeTextBox=0; + this.textboxes[this.activeTextBox].line = true; } else if (this.buttons[1].isPressed()) { + this.textboxes[this.activeTextBox].line = false; this.activeTextBox=1; + this.textboxes[this.activeTextBox].line = true; } else if (this.buttons[2].isPressed()) { api.createUser( this.textboxes[0].getWords(), @@ -102,7 +108,7 @@ class SignUpScreen { screenManager.setScreen(new ProfileScreen()); } else if (this.buttons[7].isPressed()) { screenManager.setScreen(new TestScreen()) - } else if (this.buttons[5].isPressed()) { + } else if (this.buttons[8].isPressed()) { screenManager.setScreen(new LeaderboardScreen()) } } @@ -111,7 +117,23 @@ class SignUpScreen { * * @param {key} key */ - letterTyped(key) { - this.textboxes[this.activeTextBox].letterTyped(key); + letterTyped(key) { + if (key === "Tab" && this.activeTextBox === 0) { + this.textboxes[this.activeTextBox].line = false; + this.activeTextBox=1; + this.textboxes[this.activeTextBox].line = true; + } else if (key === "Tab" && this.activeTextBox === 1) { + this.textboxes[this.activeTextBox].line = false; + this.activeTextBox=0; + this.textboxes[this.activeTextBox].line = true; + } else if (key === "Enter") { + api.createUser( + this.textboxes[0].getWords(), + this.textboxes[1].getWords() + ) + screenManager.setScreen(new StartScreen()); + } else { + this.textboxes[this.activeTextBox].letterTyped(key); + } } } \ No newline at end of file diff --git a/website/screens/startscreen.js b/website/screens/startscreen.js index b37a527..fdbe2e4 100644 --- a/website/screens/startscreen.js +++ b/website/screens/startscreen.js @@ -35,7 +35,7 @@ class StartScreen { } fill("#000"); - text(`${user.username}`, windowWidth-100, 15); + text(`Logged in as ${user.username}`, windowWidth-400, 15); } letterTyped(key) { diff --git a/website/screens/testscreen.js b/website/screens/testscreen.js index e730300..6b18dc4 100644 --- a/website/screens/testscreen.js +++ b/website/screens/testscreen.js @@ -1,6 +1,6 @@ class TestScreen { constructor() { - this.textbox = new Textbox(100,100,windowWidth - 100,windowHeight,0,true,"#000", false, "#000", "#000"); + 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.start(); } diff --git a/website/ui_elements/textbox.js b/website/ui_elements/textbox.js index 5746688..92a87ea 100644 --- a/website/ui_elements/textbox.js +++ b/website/ui_elements/textbox.js @@ -12,7 +12,15 @@ class Textbox { * @param {hexcode} pBorderColor * @param {hexcode} pBackgroundColor */ - constructor(pX, pY, pWidth, pHeight, pLayer, pVisible, pTextColor, pBorder, pBorderColor, pBackgroundColor) { + constructor( + pX, pY, + pWidth, pHeight, + pLayer, pVisible, + pTextColor, + pBorder, pBorderColor, + pBackgroundColor, + pLine, pIsTest + ) { this.x = pX; this.y = pY; this.width = pWidth; @@ -31,6 +39,13 @@ class Textbox { 'l', 'm','n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\'', '"', ',', '.', ' ' ] + + this.line = pLine; + this.isTest = pIsTest; + + if (this.isTest) { + this.testContent = user.nextTest; + } } getX() { @@ -183,19 +198,71 @@ class Textbox { fill(this.textColor); textSize(23); textAlign(LEFT); + if (this.words.length == 0 && this.line) { + fill("#000") + rect(this.x, this.y-15, 1, 30) + } // these variables allow me to use the values of x and y while updating them let i = this.x; let j = this.y; - // currently this loop just prints out every letter in the array, including any enter characters - for (let x = 0; x < this.letters.length; x++) { - if (i > this.x + this.width) i = this.x, j += 30; - if (this.letters[x] === "Enter") { - i = this.x, j+= 30; - } else { - text(this.letters[x], i, j); - i += 13 + if (this.isTest) { + let i = this.x; + let j = this.y; + + // currently this loop just prints out every letter in the array, including any enter characters + for (let x = 0; x < this.testContent.length; x++) { + if (i > this.x + this.width) i = this.x, j += 30; + if (this.testContent[x] === "Enter") { + i = this.x, j+= 30; + } else { + text(this.testContent[x], i, j); + i += 13 + } + } + + // these variables allow me to use the values of x and y while updating them + i = this.x; + j = this.y; + + // currently this loop just prints out every letter in the array, including any enter characters + for (let x = 0; x < this.letters.length; x++) { + if (i > this.x + this.width) i = this.x, j += 30; + if (this.letters[x] === "Enter") { + i = this.x, j+= 30; + } else { + if (this.letters[x] === this.testContent[x]) { + fill('green'); + } else { + fill('red'); + } + text(this.testContent[x], i, j); + i += 13 + } + if (this.letters.length > 0 && x == this.letters.length-1 && this.line) { + fill("black") + rect(i, j-15, 1, 30) + } + } + } else { + // these variables allow me to use the values of x and y while updating them + let i = this.x; + let j = this.y; + + // currently this loop just prints out every letter in the array, including any enter characters + for (let x = 0; x < this.letters.length; x++) { + if (i > this.x + this.width) i = this.x, j += 30; + if (this.letters[x] === "Enter") { + i = this.x, j+= 30; + } else { + text(this.letters[x], i, j); + i += 13 + } + if (this.letters.length > 0 && x == this.letters.length-1 && this.line) { + fill("black") + rect(i, j-15, 1, 30) + } } } }