-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
127 lines (117 loc) · 5.2 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Cosmic Rising</title>
<script src="js/lib/box2d.min.js" type="text/jscript"></script>
<script src="js/lib/box2d-helpers.js" type="text/javascript"></script>
<script src="js/utils.js"></script>
<script src="js/camera.js"></script>
<script src="js/init.js"></script>
<script src="js/animation.js"></script>
<script src="js/obstacle.js"></script>
<script src="js/level.js"></script>
<script src="js/debris.js"></script>
<script src="js/bullet.js"></script>
<script src="js/change.js"></script>
<script src="js/ship.js"></script>
<script src="js/main.js"></script>
<script src="js/menu.js"></script>
<script src="js/spawn-point.js"></script>
<script src="js/level.js"></script>
<script src="js/input2.js"></script>
<script src="js/game-ai.js"></script>
</head>
<body>
<script>
window.requestAnimationFunc = (function(){
if (window.requestAnimationFrame) {
return window.requestAnimationFrame;
}
if (window.webkitRequestAnimationFrame) {
return window.webkitRequestAnimationFrame;
}
if (window.mozRequestAnimationFrame) {
window.mozRequestAnimationFrame;
}
if (window.oRequestAnimationFrame) {
window.oRequestAnimationFrame;
}
if (window.msRequestAnimationFrame) {
window.msRequestAnimationFrame;
}
return function(callback){
window.setTimeout(callback, 1000/60);
};
})();
InitGame();
loadAssets();
function start() {
listener = new JSContactListener();
listener.BeginContact = function (contactPtr) {
var contact = Box2D.wrapPointer(contactPtr, b2Contact);
if (contact.IsTouching()) {
var a = contact.GetFixtureA().GetBody().actor;
var b = contact.GetFixtureB().GetBody().actor;
if (contact.GetFixtureA().IsSensor() && !contact.GetFixtureB().IsSensor()) {
if (a.beginSensorCallback)
a.beginSensorCallback(b);
if (a.beginContactCallback)
a.beginContactCallback(b);
}
else if (contact.GetFixtureB().IsSensor() && !contact.GetFixtureA().IsSensor()) {
if (b.beginSensorCallback)
b.beginSensorCallback(a);
if(b.beginContactCallback)
b.beginContactCallback(a);
}
else if (!contact.GetFixtureA().IsSensor() && !contact.GetFixtureB().IsSensor()) {
if (a.beginContactCallback) {
a.beginContactCallback(b);
}
if (b.beginContactCallback) {
b.beginContactCallback(a);
}
}
}
}
listener.EndContact = function(contactPtr) {
var contact = Box2D.wrapPointer(contactPtr, b2Contact);
var a = contact.GetFixtureA().GetBody().actor;
var b = contact.GetFixtureB().GetBody().actor;
if (contact.GetFixtureA().IsSensor() && !contact.GetFixtureB().IsSensor()) {
if (a.endSensorCallback)
a.endSensorCallback(b);
if (a.endSensorCallback)
a.endSensorCallback(b);
}
else if (contact.GetFixtureB().IsSensor() && !contact.GetFixtureA().IsSensor()) {
if (b.endSensorCallback)
b.endSensorCallback(a);
if(b.endSensorCallback)
b.endSensorCallback(a);
}
else if (!contact.GetFixtureA().IsSensor() && !contact.GetFixtureB().IsSensor()) {
if (a.endSensorCallback) {
a.endSensorCallback(b);
}
if (b.endSensorCallback) {
b.endSensorCallback(a);
}
}
};
listener.PreSolve = function() {};
listener.PostSolve = function() {};
app.world.SetContactListener(listener);
app.level = new Level(100, 100);
switchMusicToMenu();
if (app.iOS) {
window.setInterval(main_iOS, 1000/60);
}
else{
window.requestAnimationFunc(main);
}
}
</script>
</body>
</html>