-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTesting_2.html
130 lines (118 loc) · 2.58 KB
/
Testing_2.html
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<html>
<head>
<!--<script type="text/javascript" src="//code.jquery.com/jquery-1.7.1.js"></script>-->
<script type="text/javascript" src="js/player.js"></script>
<script type="text/javascript" src="js/level.js"></script>
<script type="text/javascript" src="js/game.js"></script>
<script type="text/javascript" >
var canvas;
var context;
var inGame = false;
var menuPos = 1;
//Create a redraw Function
function redraw()
{
context.clearRect(0,0,800,600);
drawFrame();
}
// Draw Frame Function
function drawFrame()
{
if(inGame)
{
gameDrawFrame();
}
else
{
drawMenu();
}
}
function drawMenu()
{
//document.getElementById('blah').value = menuPos +", "+ inGame;
var ctx = canvas.getContext("2d");
// Create gradient
//var grd=ctx.createRadialGradient(75,50,5,90,60,100);
//grd.addColorStop(0,"red");
//grd.addColorStop(1,"white");
// Fill with gradient
ctx.fillStyle='#FF0000'//grd;
ctx.fillRect(150,90+(50*menuPos),500,40);
ctx.fillStyle = '#000000';
ctx.font = "30px Arial";
ctx.fillText("Epic LOTRs Adventure Fighting Game", 150, 70);
ctx.fillText("START GAME", 300, 170);
}
// Keypresses
document.onkeydown = keydown;
document.onkeyup = keyup;
function keydown(e)
{
if(inGame)
{
gamekeydown(e);
}
else
{
e = e || e.which || e.keycode || window.event;
//alert(e.which);
if(e.which == '38')
{
if(menuPos > 1)
{
menuPos--;
}
}
else if(e.which == '40')
{
if(menuPos < 1)
{
menuPos++;
}
}
else if(e.which == '13') // Enter Key
{
//alert("yolo");
switch(menuPos)
{
case 1:
inGame = true;
break;
default:
break;
}
}
}
}
function keyup(e)
{
if(inGame)
{
gamekeyup(e);
}
else
{
e = e || window.event;
}
}
//Init Function
function init()
{
//alert("Hello");
canvas = document.getElementById("gameCanvas");
context = canvas.getContext("2d");
setInterval(redraw, 30);
}
</script>
</head>
<body onload="init()">
<center>
<canvas id="gameCanvas" name="gameCanvas" width="800" height="600" style="border:1px solid #000000;"></canvas>
<audio autoplay loop>
<source src="resources/audio/isengard.mp3">
<source src="resources/audio/isengard.ogg">
<embed src="resources/audio/isengard.mp3">
</audio>
<input type="text" id="blah" size="60">
</body>
</html>