Skip to content

Commit 87af235

Browse files
authored
Merge pull request #160 from left23/master
intro text, hobbits plate continued, emcradio module and styles
2 parents f8190f6 + 0f3659c commit 87af235

12 files changed

Lines changed: 560 additions & 183 deletions

File tree

components/com_battle/views/phaser/tmpl/highhero_diagonal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@
677677
"meta": {
678678
"app": "http://www.codeandweb.com/texturepacker",
679679
"version": "1.0",
680-
"image": "hero_diagonal.png",
680+
"image": "highhero_diagonal.png",
681681
"format": "RGBA8888",
682682
"size": {
683683
"w": 793,

components/com_battle/views/phaser/tmpl/playstate00.js

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,45 @@ var d = new Date(),
2828
m = (d.getMinutes()<10?'0':'') + d.getMinutes();
2929
var printedTime = h + ':' + m;
3030

31+
introDateTime = [
32+
" ",
33+
printedTime + ", July 23rd, 2053",
34+
"Somewhere outside of Pyramid City, Europa"
35+
];
36+
3137
content = [
3238
" ",
3339
"In the beginning, there were no beginnings.",
3440
"There were no need for them.",
3541
"But somewhere between then and now,",
3642
"people started wondering...",
43+
" ",
3744
"Who am I?",
3845
"Where do I come from?",
39-
"Where am I going? ",
40-
"",
41-
printedTime + ", July 23rd, 2053",
42-
"Somewhere outside of Pyramid City, Europa",
46+
"Where am I going? "
4347
];
48+
49+
4450
getConspiracy();
51+
4552
function getConspiracy() {
4653
jQuery.getJSON("http://emcradio.com/api/paragraph/conspiracy?_format=api_json", function (conspiracyObj) {
47-
//conspiracyToPrint = conspiracyObj.data[0].attributes.field_conspiracy[0].value;
54+
conspiracyToPrint = conspiracyObj.data[0].attributes.field_conspiracy[0].value;
4855
});
4956
}
5057

51-
var text2;
58+
var dateTime;
5259
var index = 0;
5360
var line = '';
61+
62+
var introText;
63+
var line2 = [];
64+
var wordIndex = 0;
65+
var lineIndex = 0;
66+
var wordDelay = 140;
67+
var lineDelay = 1400;
5468
var grd;
69+
var timeoutID;
5570

5671
// The Google WebFont Loader will look for this object, so create it before loading the script.
5772
WebFontConfig = {
@@ -72,7 +87,9 @@ WebFontConfig = {
7287
playState[0] = {
7388

7489
preload: function() {
75-
game.load.image('arrow', '/images/thisway.png');// Load the Google WebFont Loader script
90+
game.load.image('arrow', '/images/thisway.png');
91+
92+
// Load the Google WebFont Loader script
7693
game.load.script('webfont', '//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js');
7794
},
7895
create: function() {
@@ -89,28 +106,37 @@ playState[0] = {
89106
cursors = game.input.keyboard.createCursorKeys();
90107

91108

92-
text2 = game.add.text();
109+
dateTime = game.add.text();
110+
dateTime.backgroundColor = 'black';
111+
dateTime.font = 'Roboto';
112+
dateTime.fontSize = 14;
113+
dateTime.fontWeight = 400;
114+
dateTime.fill = '#FFDD07';
115+
dateTime.align = 'left';
116+
93117

94-
text2.font = 'Roboto';
95-
text2.fontSize = 32;
96-
text2.fontWeight = 700;
118+
nextLine();
119+
introText = game.add.text();
120+
introText.font = 'Roboto';
121+
introText.fontSize = 32;
122+
introText.fontWeight = 700;
97123

98124
// x0, y0 - x1, y1
99-
grd = text2.context.createLinearGradient(0, 0, 0, 100);
125+
grd = introText.context.createLinearGradient(0, 0, 0, 500);
100126
grd.addColorStop(0, '#099');
101-
grd.addColorStop(1, '#000');
102-
text2.fill = grd;
127+
grd.addColorStop(1, '#fff');
128+
introText.fill = grd;
103129

104-
text2.align = 'center';
105-
text2.stroke = '#111';
106-
text2.strokeThickness = 1;
107-
text2.setShadow(2, 2, 'rgba(0,0,0,0.3)', 2);
130+
introText.align = 'left';
131+
introText.stroke = '#111';
132+
introText.strokeThickness = 1;
133+
introText.setShadow(2, 2, 'rgba(0,0,0,0.3)', 2);
108134

109135

110-
nextLine();
136+
timeoutID = window.setTimeout(slowIntroText, 10000);
111137

112-
}
113138

139+
}
114140
};
115141

116142

components/com_battle/views/phaser/tmpl/playstate03.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,6 @@ function place_portals(){
445445
// portal[3] = game.add.sprite(x3[grid], y3[grid], 'portal00003');
446446
// game.physics.enable(portal[3], Phaser.Physics.ARCADE);
447447
portal[3]['grid']=portal_dest_3[grid];
448-
449-
450448
}
451449

452450
function place_player() {

components/com_battle/views/phaser/tmpl/script.js

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,17 @@ else {
521521
}
522522
}
523523

524+
525+
526+
527+
528+
524529
function updateLine() {
525-
if (line.length < content[index].length) {
526-
line = content[index].substr(0, line.length + 1);
530+
console.log(introDateTime);
531+
if (line.length < introDateTime[index].length) {
532+
line = introDateTime[index].substr(0, line.length + 1);
527533
// text.text = line;
528-
text2.setText(line);
534+
dateTime.setText(line);
529535
}
530536
else {
531537
// Wait 2 seconds then start a new line
@@ -535,9 +541,70 @@ else {
535541

536542
function nextLine() {
537543
index++;
538-
if (index < content.length) {
544+
if (index < introDateTime.length) {
539545
line = '';
540-
game.time.events.repeat(80, content[index].length + 1, updateLine, this);
546+
game.time.events.repeat(80, introDateTime[index].length + 1, updateLine, this);
547+
}
548+
}
549+
550+
551+
552+
553+
554+
function nextLine2() {
555+
if (lineIndex === content.length) {
556+
// We're finished
557+
return;
558+
}
559+
// Split the current line on spaces, so one word per array element
560+
line2 = content[lineIndex].split(' ');
561+
// Reset the word index to zero (the first word in the line)
562+
wordIndex = 0;
563+
// Call the 'nextWord' function once for each word in the line (line.length)
564+
game.time.events.repeat(wordDelay, line2.length, nextWord, this);
565+
// Advance to the next line
566+
lineIndex++;
567+
}
568+
569+
function nextWord() {
570+
// Add the next word onto the text string, followed by a space
571+
introText.text = introText.text.concat(line2[wordIndex] + " ");
572+
// Advance the word index to the next word in the line
573+
wordIndex++;
574+
// Last word?
575+
if (wordIndex === line2.length) {
576+
// Add a carriage return
577+
introText.text = introText.text.concat("\n");
578+
// Get the next line after the lineDelay amount of ms has elapsed
579+
game.time.events.add(lineDelay, nextLine2, this);
541580
}
581+
582+
}
583+
584+
585+
586+
function slowIntroText() {
587+
nextLine2();
542588
}
589+
590+
function clearAlert() {
591+
window.clearTimeout(timeoutID);
592+
}
593+
594+
595+
596+
597+
598+
599+
600+
601+
602+
603+
604+
605+
606+
607+
608+
609+
543610
}
82.7 KB
Loading
15.4 KB
Loading
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
<<html>
2-
<head>
3-
<!-- Phaser -->
4-
<script src="/components/com_battle/includes/phaser.js"></script>
5-
<style>
6-
body {
7-
margin: 0;
8-
}
9-
</style>
10-
</head>
11-
<body>
12-
<div id="world">
13-
</div>
14-
<script src='state001.js'></script>
15-
<script src='script.js'></script>
16-
</body>
1+
<html>
2+
<head>
3+
<!-- Phaser -->
4+
<script src="/components/com_battle/includes/phaser.js"></script>
5+
<style>
6+
body {
7+
margin: 0;
8+
}
9+
</style>
10+
</head>
11+
<body>
12+
13+
<div id="world">
14+
</div>
15+
16+
<script src='script.js'></script>
17+
<script src='state001.js'></script>
18+
</body>
1719
</html>

0 commit comments

Comments
 (0)