-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
238 lines (208 loc) · 8.62 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
226
227
228
229
230
231
232
233
234
235
236
237
238
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>jquery-box-game by pstrinkle</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" media="screen">
<!-- above the fold, it is render-blocking deliberately. -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- optional -->
<script src="assets/js.cookie-2.1.2.min.js"></script>
<script src="assets/jquery-levelup/1.0.2/jquery.levelup.min.js"></script>
<!-- required -->
<script src="assets/jquery-paintbox/0.1.1/jquery.paintbox.min.js"></script>
<script src="src/box-game.js"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</head>
<body>
<section class="page-header">
<h1 class="project-name">jquery-box-game</h1>
<h2 class="project-tagline">jQuery plugin that provides a simple box drawing puzzle game.</h2>
<a href="https://github.com/pstrinkle/jquery-box-game" class="btn">View on GitHub</a>
<a href="https://github.com/pstrinkle/jquery-box-game/zipball/master" class="btn">Download .zip</a>
<a href="https://github.com/pstrinkle/jquery-box-game/tarball/master" class="btn">Download .tar.gz</a>
</section>
<section class="main-content">
<h3><a id="basics" class="anchor" href="#basics" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>The Basics</h3>
<p>
The game is simple, you are given an empty game board, which you fill in
by placing randomly colored blocks down. When the blocks create a
rectangle of the same color, the blocks inside the rectangle and the
rectangle itself are cleared from the board earning you points.
However, every 1 second the computer randomly clears a block.
</p>
<p>
The game is a little buggy at present, and I'm still open to taking it
different directions, such as making the game board slowly erode away
or drop down every few clicks so it's a race against time.
</p>
<select id='debugoption'>
<option selected>Off</option>
<option>On</option>
</select>
<span id='points'>0</span> points - <span id='over'></span><br />
<button id='start'>Start game</button>
<br />
<div id='currentColor' style='width:20px;height:20px;'></div>
<hr>
<div id='container' style='background-color:black;border:5px solid black;display:table-cell;'></div>
<script>
$(function() {
var $p = $('#points');
$p.levelup({'start' : 0});
var $c = $('#container');
$('#start').on('click', function(event) {
event.preventDefault();
$('#log').empty();
$p.levelup('reset');
$('#over').text('');
var debugmode = $('#debugoption option:selected').text();
if (debugmode === 'Off') {
debugmode = false;
} else {
debugmode = true;
}
$c.empty();
$c.boxGame({rows: 20, cols: 20, offColor: 'white', debug : debugmode});
$c.on('color-change', function(event, color) {
$('#currentColor').css('background-color', color);
});
$c.on('points-earned', function(event, points) {
$p.levelup('increment', points);
});
$c.boxGame('start');
});
});
</script>
<h4>Demo setup:</h4>
<pre class="prettyprint lang-js">
$(function() {
var $p = $('#points');
$p.levelup({'start' : 0});
var $c = $('#container');
$('#start').on('click', function(event) {
event.preventDefault();
$('#log').empty();
$p.levelup('reset');
$('#over').text('');
var debugmode = $('#debugoption option:selected').text();
if (debugmode === 'Off') {
debugmode = false;
} else {
debugmode = true;
}
$c.empty();
$c.boxGame({rows: 20, cols: 20, offColor: 'white', debug : debugmode});
$c.on('color-change', function(event, color) {
$('#currentColor').css('background-color', color);
});
$c.on('points-earned', function(event, points) {
$p.levelup('increment', points);
});
$c.boxGame('start');
});
});</pre>
<h3>Installation</h3>
<p>Basically just include the file.</p>
<pre class="prettyprint lang-html">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="/libs/jquery-box-game/jquery.box-game.js"></script>
<div id='container'></span>
<script>
$('#container').boxGame({rows: 20, cols: 20});
</script>
</pre>
<h3>Usage</h3>
<div>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>rows</td>
<td>integer</td>
<td><code>50</code></td>
<td>Number of rows.</td>
</tr>
<tr>
<td>cols</td>
<td>integer</td>
<td><code>50</code></td>
<td>Number of columns.</td>
</tr>
<tr>
<td>offColor</td>
<td>css color string</td>
<td><code>white</code></td>
<td>Background color for the board.</td>
</tr>
<tr>
<td>colors</td>
<td>array of css color strings</td>
<td><code>['black', 'green', 'lightgreen', 'lightblue', 'blue', 'red']</code></td>
<td>Colors for the blocks</td>
</tr>
</tbody>
</table>
</div>
<br />
<table class="table">
<thead>
<tr>
<th>method</th>
<th>param</th>
<th>type</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>'start'</code></td>
<td></td>
<td></td>
<td>start the game (or reset the game)</td>
</tr>
</tbody>
</table>
<h3>Events</h3>
<table class="table">
<thead>
<tr>
<th>Event</th>
<th>Handler</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>color-change</code></td>
<td><code>function(event, color)</code>: <br>- <code>event</code> - jQuery event<br>- <code>color</code> - next block color</td>
</tr>
<tr>
<td><code>points-earned</code></td>
<td><code>function(event, points)</code>: <br>- <code>event</code> - jQuery event <br>- <code>function(event, points)</code> - points earned</td>
</tr>
</tbody>
</table>
<h3>License</h3>
<p><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a></p>
<footer class="site-footer">
<!-- <span class="site-footer-owner"><a href="https://github.com/pstrinkle/jquery-levelup">Jquery-levelup</a> is maintained by <a href="https://github.com/pstrinkle">pstrinkle</a>.</span> -->
<a href="https://twitter.com/YammyCozonac" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @YammyCozonac</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<a class="github-button" href="https://github.com/pstrinkle" data-style="mega" aria-label="Follow @pstrinkle on GitHub">Follow @pstrinkle</a>
<!-- <span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span> -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</footer>
</section>
</body>
</html>