-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.js
53 lines (49 loc) · 1.76 KB
/
form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Form{
constructor(){
this.input = createInput("Name");
this.button = createButton('Play');
this.greeting = createElement('h2');
this.title = createElement('h2');
this.reset = createButton('Reset');
}
hide() {
this.greeting.hide();
this.button.hide();
this.input.hide();
this.title.hide();
}
display() {
this.title.html("FRUIT CATCHER");
this.title.position(350, 50);
this.title.style('font-size', '70px');
this.title.style('color', 'skyblue');
this.input.position(550,400);
this.input.style('width', '200px');
this.input.style('height', '20px');
this.input.style('background', 'lavender');
this.button.position(560,500);
this.button.style('width', '200px');
this.button.style('height', '40px');
this.button.style('background', 'lightpink');
this.reset.position(900, 660);
this.reset.style('width', '100px');
this.reset.style('height', '30px');
this.reset.style('background', 'lightpink');
this.button.mousePressed(() => {
this.input.hide();
this.button.hide();
player.name = this.input.value();
playerCount += 1;
player.index = playerCount;
player.update();
player.updateCount(playerCount);
this.greeting.html("Hello " + player.name)
this.greeting.position(400,250);
this.greeting.style('color', 'white');
this.greeting.style('font-size', '100px');
});
this.reset.mousePressed(() => {
//add code to reset the values of the gameState and the playerCount nodes to 0 in the database
});
}
}