forked from coding-blocks/angry-coders-game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
225 lines (197 loc) · 6.88 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!DOCTYPE html>
<html>
<head>
<title>Happy Coders - The Coders Game</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
<link type="text/css" rel="stylesheet" href="./css/bootstrap.css">
<link type="text/css" rel="stylesheet" href="./css/main.css">
<link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css">
</head>
<body>
<script src="ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8">
</script>
<script src="js/jquery-3.2.1.js"></script>
<script src="js/phaser.js"></script>
<script src="js/states/Boot.js"></script>
<script src="js/states/Preload.js"></script>
<script src="js/states/Game.js"></script>
<script src="js/main.js"></script>
<script src="js/modal.js"></script>
<nav class="navbar-fixed-top">
<div class="nav-bar">
<div class="module left">
<a href="/">
<div class="vnu"><img class="logo logo-dark" alt="Foundry" src="https://codingblocks.com/img/cb/cb_tshirt_logo.png"></div>
</a>
</div>
<h2 class="vnu">Angry Coders Game</h2>
<div class="module widget-handle mobile-toggle right visible-sm visible-xs menuHead">
<i class="ti-menu"></i>
</div>
<div class="module-group right">
<div class="module left">
<ul class="menu">
<li style="display:inline-block">
<button class="btn btn-filled btn-md" onclick="toggleModal()">ReadMe</button>
</li>
<li style="display:inline-block">
<button class="btn btn-filled btn-md" onclick="runcode()">Run Code</button>
</li>
<li style="display:inline-block">
<button class="btn btn-filled btn-md" id='reset' onclick="resetGame()">Reset Level</button>
</li>
<li style="display:inline-block">
<button class="btn btn-filled btn-md" id='next' onclick="nextLevel()">Next Level</button>
</li>
</ul>
</div>
</div>
</div>
</nav>
<div id="readMeModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title text-center">Welcome to Angry Coders</h4>
</div>
<div class="modal-body">
<p>Run Code Button evaluates your code and runs it accordingly.</p>
<p>Reset Level Button restarts the game for this level.</p>
<p>Next level Button takes you to a random next level</p>
<p>You need to write the code for the two functions to get Angle and Velocity at which the ball should be thrown so that it hits the bird.</p>
<b>Extra Information:</b>
<pre>
gravity = 1000
mass=10
<b>Helper Functions:</b>
function degreeToRadian(deg){
  return deg*(Math.PI/180);
}
function radianToDegree(rad){
  return rad*(180/Math.PI);
}
function sin(deg){
  theta = degreeToRadian(deg);
  return Math.sin(theta);
}
function cos(deg){
  theta = degreeToRadian(deg);
  return Math.sin(theta)
}
function tanInv (val) {
  var rad = (Math.atan(val))
  var deg = radianToDegree(rad)
  return deg;
}
function squareRoot(no){
  return Math.sqrt(no);
}
</pre>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="btn-group col-xs-12 menuContent">
<center>
<button class="btn btn-filled btn-md" onclick="toggleModal()">ReadMe</button>
<button class="btn btn-filled btn-md" onclick="runcode()">Run Code</button>
<button class="btn btn-filled btn-md" id='reset' onclick="resetGame()">Reset Level</button>
<button class="btn btn-filled btn-md" id='next' onclick="nextLevel()">Next Level</button>
</center>
</div>
</div>
<div class="row content">
<br>
<div class="col-xs-12 leftbox" id="gamediv"></div>
<div class="col-xs-12 rightbox">
<div id="editor" class="hover-light">
/* YOU CAN EDIT THIS
IN THE BEGINNING */
function getVelocity(h,range){
//Complete this
return 600;
}
/* YOU CAN EDIT THIS
IN THE BEGINNING */
function getAngle(h,range){
//Complete this
return 45;
}
/* THE VARIABLES ARE UPDATED
ACCORDING TO THE LEVEL */
velocity = getVelocity();
angle = getAngle();
kickBall(velocity,angle);
</div>
</div>
</div>
<!--<div class="row" style="margin-top: 10px;">
<div class="btn-group col-xs-8 col-xs-offset-4">
<a class="btn btn-danger btn-lg" onclick="toggleModal()">
ReadMe
</a>
<button class="btn btn-lg btn-danger" onclick="runcode()">
Run Code
</button>
<button class="btn btn-lg btn-danger" id='reset' onclick="resetGame()">
Reset Level
</button>
<button class="btn btn-lg btn-danger" id='next' onclick="nextLevel()">
Next Level
</button>
</div>
</div>-->
</div>
<script>
var editor = ace.edit("editor");
$("#editor").css("display", "block");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
editor.setOptions({
fontFamily: "Fira Mono",
fontSize: "13pt"
});
</script>
<script>
function runcode() {
var extra =
`
m = 10;
setMass(m);
gravity = 1000;
function degreeToRadian(deg){
return deg*(Math.PI/180);
}
function radianToDegree(rad){
return rad*(180/Math.PI);
}
function sin(deg){
theta = degreeToRadian(deg);
return Math.sin(theta);
}
function cos(deg){
theta = degreeToRadian(deg);
return Math.sin(theta);
}
function tanInv (val) {
var rad = (Math.atan(val))
var deg = radianToDegree(rad)
return deg;
}
function squareRoot(no){
return Math.sqrt(no);
}
`;
var code = extra + editor.getValue();
// console.log(code);
eval(code);
}
function toggleModal() {
$("#readMeModal").modal("toggle");
}
</script>
</body>
</html>