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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
<?php
if ($request == 'tutorial')
htmlHeader(array('tutorial'), 'Pathery Tutorial', 'How to play Pathery', array('scores') );
else
htmlHeader(array('tutorial'), 'Pathery', 'Compete to create the longest maze possible. 4 New maps every day at 9 PM Pacific', array('scores') );
?>
<body>
<?php
topbar($Links);
//TODO: Turn this into a function?
if ($accepted) {
include_once ('./includes/sqlEmbedded.php');
$userID = $_SESSION['userID'];
$sql = "
SELECT
userData.wallColor,
userData.wallEmblem
FROM `userData`
WHERE userID = '$userID' ";
$result = mysql_query($sql);
if ($result)
list($wallColor, $wallEmblem) = mysql_fetch_row($result);
}
?>
<script type="text/javascript">
playerWallColor = '<?PHP echo isset($wallColor) ? $wallColor : ''; ?>';
playerWallEmblem = '<?PHP echo isset($wallEmblem) ? $wallEmblem : ''; ?>';
</script>
<script src="sounds/script/soundmanager.js"></script>
<script>
isChallenge = true;
isTutorial = true;
challengeID = 1;
function challengeLoad() {}
challenge1 = new Object();
challenge2 = new Object();
challenge3 = new Object();
challenge4 = new Object();
challenge5 = new Object();
challenge1.start = "The objective in this game is to create the longest <i>path</i> between the start and the finish.<br>Below is a demonstration.<br>Press <b>Go!</b>";
challenge1.complete = "Now that you see what is going on, let's move on to some puzzles.<br/>Press <b>Next</b>";
challenge2.start = "Let's start off simple.<br>Start by pressing <b>Go!</b> first.";
challenge2.wallstext = "Excellent; those wall placements look good!<br>Press <b>Go!</b> and see the path you\'ve made.";
challenge2.complete = "Splendid!<br>Shall we move on to the next puzzle?<br/>Press <b>Next</b>";
challenge2.help = "Click on the board to place two walls to make the path longer.<br>You can click on a placed wall to remove it.";
challenge3.start = "The goal for this map is 64 moves<br>Press <b>Go!</b> first again.";
challenge3.complete = "Impressive!<br/>Press <b>Next</b>";
challenge3.help = "Note that the path can travel over the <i>Start</i> and <i>End</i> tiles.";
challenge4.start = "Teleports are traps you can use to your advantage. See if you can use the teleport to reach 33 moves!<br>Press <b>Go!</b>";
challenge4.complete = "Well done!<br>Teleports add extra intrigue to the game.";
challenge4.help = "Let's use that teleport to block the way to the <i>A</i>!<br>We can make the path take longer to get to <i>A</i> in the process.";
challenge5.start = "Now for a difficult one. The goal for this one is 75 moves.<br>Press <b>Go!</b> to check your path.";
challenge5.complete = "Look at you, so pro.<br><a href='home'>Go play the game!</a>";
challenge5.help = "Try placing the walls as highlighted.";
function challengeGo(mapid) {
var moves = mapjson[mapid].path[0].moves;
var tiles;
switch (mapid) {
case '1':
tv.unlock(2);
updateDsp(1, 'instructions', challenge1.complete);
break;
case '2':
if (moves >= 18) {
updateDsp(1, 'instructions', challenge2.complete);
tv.unlock(3);
} else {
updateDsp(1, 'instructions', challenge2.help);
tiles = ["2,3,5","2,4,6"];
markTiles(tiles);
}
break;
case '3':
if (moves >= 64) {
updateDsp(1, 'instructions', challenge3.complete);
tv.unlock(4);
} else {
updateDsp(1, 'instructions', challenge3.help);
tiles = ["3,3,6","3,4,7","3,3,2","3,2,1"];
markTiles(tiles);
}
break;
case '4':
if (moves >= 33) {
updateDsp(1, 'instructions', challenge4.complete);
tv.unlock(5);
} else {
updateDsp(1, 'instructions', challenge4.help);
tiles = ["4,1,5","4,2,6","4,3,7","4,4,9"];
markTiles(tiles);
}
break;
case '5':
if (moves >= 75) {
updateDsp(1, 'instructions', challenge5.complete);
//Unlock next button.
} else {
updateDsp(1, 'instructions', challenge5.help);
tiles = ["5,1,5","5,2,6","5,3,3","5,4,2","5,3,1"];
markTiles(tiles);
}
break;
}
}
function markTiles(tiles) {
for(var i in tiles) {
var tmp = tiles[i];
setTimeout('document.getElementById("'+tiles[i]+'").style.backgroundColor = "#ccccdd"', i*150 + 900);
}
}
//TODO:
function challengeWall(mapid) {
//Required walls:
var reqwall = new Array();
reqwall[0] = "3,5.";
reqwall[1] = "4,6.";
for(var i in reqwall) {
if (solution[mapid].indexOf(reqwall[i]) == -1) {
//Failed
return;
}
}
updateDsp(1, 'instructions', challenge2.wallstext)
}
function highlightElement(Eid) {
}
function startChallenge(mapid) {
//console.log("start challenge", mapid);
switch (mapid) {
case 1:
updateDsp(1, 'instructions', challenge1.start);
var goBtn = document.getElementById('1,btn');
var interval1 = setInterval(function() {
goBtn.className += ' flash';
}, 1200),
interval2;
setTimeout(function() {
interval2 = setInterval(function() {
goBtn.className = goBtn.className.replace(' flash', '');
}, 1200);
}, 600);
var prevHandler = goBtn.onclick;
goBtn.onclick = function() {
clearInterval(interval1);
clearInterval(interval2);
goBtn.className = goBtn.className.replace(' flash', '');
prevHandler.apply(this, arguments);
}
break;
case 2:
updateDsp(1, 'instructions', challenge2.start);
break;
case 3:
updateDsp(1, 'instructions', challenge3.start);
break;
case 4:
updateDsp(1, 'instructions', challenge4.start);
break;
case 5:
updateDsp(1, 'instructions', challenge5.start);
break;
}
}
function TutorialView(low, high) {
this.low = low;
this.high = high;
this.cur = low;
//Lock them all.
this.locked = low;
//Override hack to unlock all the levels.
//this.locked = high;
this.nextbtn = document.getElementById('nextbtn');
this.prevbtn = document.getElementById('prevbtn');
this.interval1 = this.interval2 = null;
mixpanel.track('tutorial', {'step': this.cur});
}
TutorialView.prototype.showTutorial = function(num) {
for (var i = this.low; i <= this.high; i++) {
var elem = document.getElementById("tut-" + i);
if (elem.className.indexOf('hidden') < 0)
elem.className += 'hidden';
}
elem = document.getElementById("tut-" + num);
elem.className = elem.className.replace('hidden', '');
//Is the map after this disabled?
this.nextbtn.className = this.nextbtn.className.replace(' disabled', '');
if (this.locked <= this.cur)
this.nextbtn.className += ' disabled';
startChallenge(num);
tv.nextbtn.className = tv.nextbtn.className.replace(' flash', '');
}
TutorialView.prototype.next = function() {
clearInterval(this.interval1);
clearInterval(this.interval2);
if (this.nextbtn.className.indexOf(' disabled') > -1)
return;
this.showTutorial(++this.cur);
if (this.cur == this.high) {
if (this.nextbtn.className.indexOf('hidden') < 0)
this.nextbtn.className += ' hidden';
} else {
this.nextbtn.className = this.nextbtn.className.replace(' hidden', '');
//this.nextbtn.className += ' disabled';
}
this.prevbtn.className = this.prevbtn.className.replace(' hidden', '');
mixpanel.track('tutorial', {'step': this.cur});
}
TutorialView.prototype.prev = function() {
this.showTutorial(--this.cur);
if (this.cur == this.low) {
if (this.prevbtn.className.indexOf('hidden') < 0)
this.prevbtn.className += ' hidden';
} else
this.prevbtn.className = this.prevbtn.className.replace(' hidden', '');
this.nextbtn.className = this.nextbtn.className.replace(' hidden', '');
}
TutorialView.prototype.unlock = function(n) {
if (n > this.locked) {
this.locked = n;
if (this.locked >= this.cur) {
this.nextbtn.className = this.nextbtn.className.replace(' disabled', '');
this.interval1 = setInterval(function() {
this.nextbtn.className += ' flash';
}, 1200);
setTimeout(function() {
tv.interval2 = setInterval(function() {
tv.nextbtn.className = tv.nextbtn.className.replace(' flash', '');
}, 1200);
}, 600);
}
}
}
</script>
<?php
include('./includes/maps.php');
//include('./includes/datas.php');
//Page Load;
//STAGE 1:
//Intro and Instructions; press go!
//Lightup; Go-button.
//Go is done animating and GOAL is unachieved.
//STAGE 2:
//Show where walls go, and/or encourage them.
//Lightup; Wall Spots
//All walls have been placed correctly.
//STAGE 3:
//'That looks good, try pressing Go!'
//Lightup; Go-Button
//Go is done animating, and goal is achieved:
//STAGE 4:
//Horray! Move on to next - highlight 'Next'
//Lightup; Next-Button
?>
<a href='home' style='padding-left:7px;'>Skip Tutorial</a>
<div id="tut-wrapper">
<div style='height:80px;' id='1,instructions'>
<p>The objective in this game is to create the longest <i>path</i> between the start and the finish.<br>Below is a demonstration.<br>Press <b>Go!</b></p>;
</div>
<?
//Prepare maps.
$example1[] = "sraoorooof";
$example1[] = "sorooroorf";
$example1[] = "soorooorof";
$example1[] = "sooorrroof";
$example1[] = "soooooooof";
$myparams['teleports'] = 0;
$myparams['walls'] = 0;
$map1 = GenerateShapedMap($example1, $myparams);
$challenge2[] = "sooraooof";
$challenge2[] = "sooorooof";
$challenge2[] = "sooooooof";
$challenge2[] = "sooooooof";
$challenge2[] = "sooooooof";
$myparams['checkpoints'] = 1;
$myparams['teleports'] = 0;
$myparams['walls'] = 2;
$map2 = GenerateShapedMap($challenge2, $myparams);
$challenge3[] = "soooraoof";
$challenge3[] = "sooooroof";
$challenge3[] = "sooooooof";
$challenge3[] = "sooroooof";
$challenge3[] = "soobrooof";
$myparams['checkpoints'] = 2;
$myparams['teleports'] = 0;
$myparams['walls'] = 4;
$map3 = GenerateShapedMap($challenge3, $myparams);
$challenge4[] = "suooooaooof";
$challenge4[] = "sooooooooof";
$challenge4[] = "sooooooooof";
$challenge4[] = "sooooooorof";
$challenge4[] = "soooooootof";
$myparams['checkpoints'] = 1;
$myparams['teleports'] = 1;
$myparams['walls'] = 4;
$map4 = GenerateShapedMap($challenge4, $myparams);
$challenge5[] = "soooaobtorf";
$challenge5[] = "soocrooooof";
$challenge5[] = "souooooooof";
$challenge5[] = "sooooooooof";
$challenge5[] = "sooooooooof";
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['walls'] = 5;
$map5 = GenerateShapedMap($challenge5, $myparams);
//Display maps.
echo '<div id="tut-1" class="hidden">';
echo DisplayMap($map1, 1, 'puzzle');
echo '</div><div id="tut-2" class="hidden">';
echo DisplayMap($map2, 2, 'puzzle');
echo '</div><div id="tut-3" class="hidden">';
echo DisplayMap($map3, 3, 'puzzle');
echo '</div><div id="tut-4" class="hidden">';
echo DisplayMap($map4, 4, 'puzzle');
echo '</div><div id="tut-5" class="hidden">';
echo DisplayMap($map5, 5, 'puzzle');
echo '</div>';
?>
<div class="wrapper">
<a href="javascript:tv.next()" id="nextbtn" class="next disabled">Next</a>
<a href="javascript:tv.prev()" id="prevbtn" class="next hidden">Previous</a>
</div>
</div>
<script>
var tv = new TutorialView(1, 5);
tv.showTutorial(1);
soundManagerInit();
</script>
<br />
<br />
<br />
<br />
<br />
<br />
<?php
htmlFooter(array('tutorial'));
?>
|