forked from jonashw/Veggie-Knight
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
119 lines (119 loc) · 4.08 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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="src/SwipeEvents.js"></script>
<script type="text/javascript" src="src/Controls.js"></script>
<script type="text/javascript" src="src/Convert.js"></script>
<script type="text/javascript" src="src/GameLoop.js"></script>
<script type="text/javascript" src="src/Stage.js"></script>
<script type="text/javascript" src="src/Veggie.js"></script>
<script type="text/javascript" src="src/VeggieFactory.js"></script>
<script type="text/javascript" src="src/VeggieLauncher.js"></script>
<script type="text/javascript" src="src/ComboNotice.js"></script>
<script type="text/javascript" src="src/ScoreBoard.js"></script>
<script type="text/javascript" src="src/PauseScreen.js"></script>
<script type="text/javascript" src="src/Random.js"></script>
<script type="text/javascript" src="src/Mode.js"></script>
<script type="text/javascript" src="src/NormalMode.js"></script>
<script type="text/javascript" src="src/FrenzyMode.js"></script>
<script type="text/javascript" src="lib/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" href="bootstrap.yeti.min.css" />
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>Typing Knight</title>
<script>
window.onload = function(){
var canvas = document.getElementById('canvas');
var bgImg = {
green: document.getElementById('rays-green'),
blue: document.getElementById('rays-blue')
};
var stage = new Stage(
canvas,
document.getElementById('img'),
800,500,
bgImg.green);
var gameLoop = new GameLoop(stage);
var veggieLauncher = new VeggieLauncher(stage);
var controls = new Controls(canvas,stage,gameLoop,veggieLauncher);
var scoreBoard = new ScoreBoard(controls,stage);
var pauseScreen = new PauseScreen(canvas,scoreBoard,gameLoop);
stage.init();
controls.init();
scoreBoard.init();
stage.draw();
pauseScreen.init();
controls.on('combo',function(comboSize,x,y){
stage.notices.push(new ComboNotice(comboSize,x,y));
});
var normalMode = new NormalMode(gameLoop,veggieLauncher,bgImg.green);
var frenzyMode = new FrenzyMode(gameLoop,veggieLauncher,2000,bgImg.blue);
var currentMode = normalMode;
function toMode(mode){
currentMode.stop();
currentMode = mode;
stage.bgImg = currentMode.bgImg;
currentMode.start();
}
function toggleMode(){
var nextMode = currentMode == normalMode
? frenzyMode
: normalMode;
toMode(nextMode);
}
gameLoop.on('stop',function(){
currentMode.stop();
});
gameLoop.on('start',function(){
currentMode.start();
});
$('#playPause').on('touch click',function(){
gameLoop.playPause();
});
$('#fullscreen').on('touch click',function(){
requestFullscreen(canvas);
});
$('#toggleMode').on('touch click',function(){
toggleMode();
});
gameLoop.playPause();
};
function requestFullscreen(elem){
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
elem.webkitRequestFullscreen();
}
}
</script>
</head>
<body>
<img src="img/pinwheel-green-1200.png" id="rays-green" style="display:none;">
<img src="img/pinwheel-blue-1200.png" id="rays-blue" style="display:none;">
<div class="container text-center">
<!-- <img src="img/VeggieKnight.png" class="img-responsive" style="margin:0 auto;"> -->
<hr>
<p class="lead">It's like <a href="http://jonashw.github.io/Veggie-Knight">Veggie Knight</a> but with Typing</p>
<hr>
<img id="img" src="img/veggies.png" style="display:none;"/>
<button id="playPause">Play/Pause</button>
<button id="fullscreen">Full Screen</button>
<br>
<br>
<canvas id="canvas"></canvas>
<br>
<br>
<kbd>Space</kbd> Play/Pause
<span style="padding:0 1em;" class="text-muted">•</span>
<kbd>Type</kbd> Slice veggies
<br>
<br>
<br>
<a href="https://github.com/juzley/Typing-Knight/">View project on GitHub</a>
</div>
</body>
</html>