html
html
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
<title>Canvas Animation Template</title>
</head>
<body>
<canvas id="c"></canvas>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
body {
margin: 0px;
}
Enter to Rename, Shift+Enter to Preview
js
js
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
// Backend
var _reqFrame_ = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function(callback){
window.setTimeout(callback, 1000 / 60);
};
})();
function _now_() {
return window.performance && performance.now() || Date.now();
}
var _stopped_ = false;
var _prevTime_;
function _update_() {
var now = _now_();
update(now - _prevTime_);
if (!_stopped_) {
_prevTime_ = now;
_reqFrame_(_update_);
}
}
function stopGame() {
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run