-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu_class.js
101 lines (88 loc) · 2.47 KB
/
menu_class.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// JavaScript Document
function c_menu()
{
this.score=0;
this.scrX=0;
this.scrY=0;
this.lives=3;
this.livX=0;
this.livY=0;
this.gameName="";
this.nameX=0;
this.nameY=0;
this.restartFlag=0;
this.pauseFlag=1;
this.startFlag=0;
this.gameoverFlag=0;
this.winnerFlag=0;
this.highScoreFlag=1;
this.drawMenu = drawMenu;
this.drawScore = drawScore;
this.drawEndOfGame=drawEndOfGame;
this.drawLives = drawLives;
this.restartGame = restartGame;
this.drawHighScore = drawHighScore;
}
function drawMenu()
{
g_ctx.font="30px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText(this.gameName,this.nameX,this.nameY,250);
g_ctx.strokeRect(300,200,210,80)
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText("START",365,248,200);
g_ctx.strokeRect(300,300,210,80)
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText("HIGH SCORES",330,345,200);
}
function drawScore()
{
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText("Score:"+this.score,this.scrX,this.scrY,250);
}
function drawLives()
{
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillText("Lives: "+this.lives,this.livX,this.livY,100);
}
function drawEndOfGame()
{
if(this.gameoverFlag==1)
{
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillText("GAMEOVER!!",340,40,100);
}
if(this.winnerFlag==1)
{
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillText("You Win!!",340,40,100);
}
}
function drawHighScore()
{
g_ctx.font="30px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText("High Scores",this.nameX+50,this.nameY,150);
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText(localStorage.getItem('N1')+"----------"+localStorage.getItem('S1'),300,250,250);
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText(localStorage.getItem('N2')+"----------"+localStorage.getItem('S2'),300,300,250);
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText(localStorage.getItem('N3')+"----------"+localStorage.getItem('S3'),300,350,250);
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText(localStorage.getItem('N4')+"----------"+localStorage.getItem('S4'),300,400,250);
g_ctx.font="20px Comic Sans MS bold"
g_ctx.fillStyle="#33ccff";
g_ctx.fillText(localStorage.getItem('N5')+"----------"+localStorage.getItem('S5'),300,450,250);
}
function restartGame()
{
if(this.restartFlag==1) {window.location.reload();}
}