-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.php
97 lines (71 loc) · 1.96 KB
/
loader.php
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
<?php
$ai1 = "./dummyAI.js";
$ai2 = "./dummyAI.js";
if (isset($_POST["player0"])){
if ($_POST["player0"]!==""){
$ai1 = $_POST["player0"];
}
}
if (isset($_POST["player1"])){
if ($_POST["player1"]!==""){
$ai2 = $_POST["player1"];
}
}
$ai1Data ="";
$ai2Data ="";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style>
html, body {
margin: 0;
height: 100%;
overflow: hidden;
}
body {
display: flex;
align-items: center;
justify-content: center;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.sound.min.js"></script>
<?php
//load AI1
if ($ai1!=""){
try {
$ai1Data = file_get_contents($ai1);
} catch (Exception $e) {
}
}
echo "<script>";
echo "class ai0 {";
echo "constructor(){this.team = 0;}";
echo $ai1Data;
echo "}";
echo "</script>";
//load AI2
if ($ai2!=""){
try{
$ai2Data = file_get_contents($ai2);
} catch (Exception $e) {
}
}
echo "<script>";
echo "class ai1 {";
echo "constructor(){this.team = 1;}";
echo $ai2Data;
echo "}";
echo "</script>";
?>
<script src="game.js"></script>
<script src="ctf.js"></script>
</head>
<body>
</body>
</html>