2022-11-06 23:52:00 +00:00
|
|
|
class SignUpScreen {
|
|
|
|
constructor() {
|
2022-11-11 13:04:13 +00:00
|
|
|
this.textboxes = [
|
2022-11-06 23:52:00 +00:00
|
|
|
new Textbox(
|
2022-11-11 13:04:13 +00:00
|
|
|
120,250,
|
|
|
|
500,100,
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
"#000",
|
|
|
|
false, "#000",
|
|
|
|
"#000"
|
2022-11-06 23:52:00 +00:00
|
|
|
),
|
|
|
|
|
|
|
|
new Textbox(
|
2022-11-11 13:04:13 +00:00
|
|
|
120,400,
|
|
|
|
500,100,
|
|
|
|
0,
|
2022-11-06 23:52:00 +00:00
|
|
|
true,
|
|
|
|
"#000",
|
|
|
|
false,"000",
|
|
|
|
"#000"
|
|
|
|
)
|
|
|
|
]
|
2022-11-11 13:04:13 +00:00
|
|
|
|
|
|
|
this.buttons = [
|
|
|
|
new Button(
|
|
|
|
100,200,
|
|
|
|
500,100,
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
"#000",
|
|
|
|
false,"#000",
|
|
|
|
"#fff",""
|
|
|
|
),
|
|
|
|
|
|
|
|
new Button(
|
|
|
|
100,350,
|
|
|
|
500,100,
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
"#000",
|
|
|
|
false,"#000",
|
|
|
|
"#fff",""
|
|
|
|
),
|
|
|
|
|
|
|
|
new Button(
|
|
|
|
700,300,
|
|
|
|
100,50,
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
"#000",
|
|
|
|
false,"#000",
|
|
|
|
"#00ff00","Sign Up"
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
this.activeTextBox = 0
|
|
|
|
// keeps track of which textbox the user last clicked on
|
2022-11-06 23:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws the SignUpScreen class with all
|
|
|
|
* appropriate elements
|
|
|
|
*/
|
|
|
|
draw() {
|
|
|
|
background("#eeeee4");
|
2022-11-11 13:04:13 +00:00
|
|
|
for (let i = 0; i < this.buttons.length; i++) {
|
|
|
|
this.buttons[i].draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i < this.textboxes.length; i++) {
|
|
|
|
this.textboxes[i].draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
text("Username", 110, 175);
|
|
|
|
text("Password", 110, 325);
|
|
|
|
|
|
|
|
if (this.buttons[0].isPressed()) {
|
|
|
|
this.activeTextBox=0;
|
|
|
|
} else if (this.buttons[1].isPressed()) {
|
|
|
|
this.activeTextBox=1;
|
|
|
|
} else if (this.buttons[2].isPressed()) {
|
|
|
|
api.createUser(
|
|
|
|
this.textboxes[0].getWords(),
|
|
|
|
this.textboxes[1].getWords()
|
|
|
|
)
|
|
|
|
screenManager.setScreen(new StartScreen());
|
2022-11-06 23:52:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {key} key
|
|
|
|
*/
|
|
|
|
letterTyped(key) {
|
2022-11-11 13:04:13 +00:00
|
|
|
this.textboxes[this.activeTextBox].letterTyped(key);
|
2022-11-06 23:52:00 +00:00
|
|
|
}
|
|
|
|
}
|