-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.html
55 lines (49 loc) · 1.57 KB
/
game.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Flappy Bird Clone</title>
<script type="text/javascript" src="phaser.js"></script>
<script type="text/javascript" src="io.js"></script>
<script type="text/javascript" src="main.js"></script>
<script language="javascript">
function getUserName(callback)
{
var UserName;
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
UserName=xmlhttp.responseText;
callback(UserName);
console.log(UserName);
}
}
xmlhttp.open("GET","server/getUser.php",true);
xmlhttp.send();
}
window.onload = function() {
// The mac I tested had the promt function replaced with null for some reason
// delete window.prompt;
// var UserName = window.prompt("Enter your name", "Unnamed");
getUserName(function(UserName){
document.getElementById("title").innerHTML="Press the spacebar to jump. UserName: "+UserName;
getName(UserName);
});
}
</script>
</head>
<body>
<p id="title" align="center">Press the spacebar to jump</p>
<div id="game_div" align="center"> </div>
</body>
</html>