summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@entelect.co.za>2014-05-28 15:20:25 +0200
committerJustin Worthe <justin.worthe@entelect.co.za>2014-05-28 15:20:25 +0200
commit7dfbd52a082b7a33c5f81b26da859830675223ba (patch)
treeb25ed92dbe6ce33e47e219d51e5d3485680c1878
parentf58ea140ae6d6f0038e429ee47319ad3c9a74de1 (diff)
Added cleanup and drawing of game result
-rw-r--r--assets/fonts/scorefont.fnt208
-rw-r--r--assets/fonts/scorefont.pngbin9126 -> 42710 bytes
-rw-r--r--game/states/play.js69
-rw-r--r--game/states/preload.js3
-rw-r--r--package.json11
5 files changed, 250 insertions, 41 deletions
diff --git a/assets/fonts/scorefont.fnt b/assets/fonts/scorefont.fnt
index e51d04b..c669a79 100644
--- a/assets/fonts/scorefont.fnt
+++ b/assets/fonts/scorefont.fnt
@@ -1,23 +1,199 @@
<font>
- <info face="Arial" size="100" bold="0" italic="0" charset="" unicode="" stretchH="100" smooth="1" aa="1" padding="2,2,2,2" spacing="0,0" outline="0"/>
- <common lineHeight="115" base="91" scaleW="113" scaleH="485" pages="1" packed="0"/>
+ <info face="Arial" size="72" bold="0" italic="0" charset="" unicode="" stretchH="100" smooth="1" aa="1" padding="2,2,2,2" spacing="0,0" outline="0"/>
+ <common lineHeight="83" base="65" scaleW="458" scaleH="512" pages="1" packed="0"/>
<pages>
<page id="0" file="font.png"/>
</pages>
- <chars count="10">
- <char id="48" x="2" y="2" width="53" height="79" xoffset="1" yoffset="0" xadvance="56" page="0" chnl="15"/>
- <char id="49" x="2" y="83" width="33" height="78" xoffset="8" yoffset="0" xadvance="56" page="0" chnl="15"/>
- <char id="50" x="2" y="163" width="54" height="78" xoffset="0" yoffset="0" xadvance="56" page="0" chnl="15"/>
- <char id="51" x="57" y="2" width="53" height="79" xoffset="1" yoffset="0" xadvance="56" page="0" chnl="15"/>
- <char id="52" x="37" y="83" width="56" height="78" xoffset="-2" yoffset="0" xadvance="56" page="0" chnl="15"/>
- <char id="53" x="2" y="243" width="54" height="78" xoffset="1" yoffset="1" xadvance="56" page="0" chnl="15"/>
- <char id="54" x="2" y="323" width="54" height="79" xoffset="1" yoffset="0" xadvance="56" page="0" chnl="15"/>
- <char id="55" x="2" y="404" width="53" height="77" xoffset="2" yoffset="1" xadvance="56" page="0" chnl="15"/>
- <char id="56" x="57" y="404" width="54" height="79" xoffset="1" yoffset="0" xadvance="56" page="0" chnl="15"/>
- <char id="57" x="58" y="163" width="53" height="79" xoffset="1" yoffset="0" xadvance="56" page="0" chnl="15"/>
- <char id="32" x="0" y="0" width="0" height="0" xoffset="1" yoffset="0" xadvance="28" page="0" chnl="15"/>
+ <chars count="90">
+ <char id="97" x="2" y="2" width="39" height="43" xoffset="1" yoffset="18" xadvance="40" page="0" chnl="15"/>
+ <char id="98" x="2" y="47" width="37" height="57" xoffset="3" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="99" x="2" y="106" width="37" height="43" xoffset="1" yoffset="18" xadvance="36" page="0" chnl="15"/>
+ <char id="100" x="2" y="151" width="37" height="57" xoffset="0" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="101" x="2" y="210" width="39" height="43" xoffset="1" yoffset="18" xadvance="40" page="0" chnl="15"/>
+ <char id="102" x="41" y="47" width="26" height="57" xoffset="-1" yoffset="4" xadvance="20" page="0" chnl="15"/>
+ <char id="103" x="41" y="106" width="37" height="58" xoffset="0" yoffset="18" xadvance="40" page="0" chnl="15"/>
+ <char id="104" x="69" y="2" width="35" height="56" xoffset="3" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="105" x="2" y="255" width="11" height="56" xoffset="3" yoffset="5" xadvance="16" page="0" chnl="15"/>
+ <char id="106" x="2" y="313" width="20" height="71" xoffset="-6" yoffset="5" xadvance="16" page="0" chnl="15"/>
+ <char id="107" x="15" y="255" width="36" height="56" xoffset="3" yoffset="5" xadvance="36" page="0" chnl="15"/>
+ <char id="108" x="43" y="166" width="11" height="56" xoffset="3" yoffset="5" xadvance="16" page="0" chnl="15"/>
+ <char id="109" x="69" y="60" width="55" height="43" xoffset="3" yoffset="18" xadvance="60" page="0" chnl="15"/>
+ <char id="110" x="106" y="2" width="35" height="43" xoffset="3" yoffset="18" xadvance="40" page="0" chnl="15"/>
+ <char id="111" x="2" y="386" width="39" height="43" xoffset="0" yoffset="18" xadvance="40" page="0" chnl="15"/>
+ <char id="112" x="24" y="313" width="37" height="57" xoffset="3" yoffset="18" xadvance="40" page="0" chnl="15"/>
+ <char id="113" x="2" y="431" width="37" height="57" xoffset="1" yoffset="18" xadvance="40" page="0" chnl="15"/>
+ <char id="114" x="41" y="431" width="25" height="43" xoffset="3" yoffset="18" xadvance="24" page="0" chnl="15"/>
+ <char id="115" x="43" y="372" width="35" height="43" xoffset="0" yoffset="18" xadvance="36" page="0" chnl="15"/>
+ <char id="116" x="53" y="224" width="23" height="55" xoffset="-1" yoffset="6" xadvance="20" page="0" chnl="15"/>
+ <char id="117" x="56" y="166" width="35" height="43" xoffset="3" yoffset="19" xadvance="40" page="0" chnl="15"/>
+ <char id="118" x="80" y="105" width="40" height="42" xoffset="-2" yoffset="19" xadvance="36" page="0" chnl="15"/>
+ <char id="119" x="63" y="281" width="57" height="42" xoffset="-3" yoffset="19" xadvance="52" page="0" chnl="15"/>
+ <char id="120" x="63" y="325" width="41" height="42" xoffset="-2" yoffset="19" xadvance="36" page="0" chnl="15"/>
+ <char id="121" x="78" y="211" width="40" height="57" xoffset="-2" yoffset="19" xadvance="36" page="0" chnl="15"/>
+ <char id="122" x="93" y="149" width="37" height="42" xoffset="-1" yoffset="19" xadvance="36" page="0" chnl="15"/>
+ <char id="65" x="120" y="193" width="54" height="56" xoffset="-3" yoffset="5" xadvance="48" page="0" chnl="15"/>
+ <char id="66" x="68" y="417" width="43" height="56" xoffset="3" yoffset="5" xadvance="48" page="0" chnl="15"/>
+ <char id="67" x="106" y="325" width="50" height="58" xoffset="2" yoffset="4" xadvance="52" page="0" chnl="15"/>
+ <char id="68" x="122" y="251" width="47" height="56" xoffset="4" yoffset="5" xadvance="52" page="0" chnl="15"/>
+ <char id="69" x="126" y="47" width="43" height="56" xoffset="4" yoffset="5" xadvance="48" page="0" chnl="15"/>
+ <char id="70" x="132" y="105" width="39" height="56" xoffset="4" yoffset="5" xadvance="44" page="0" chnl="15"/>
+ <char id="71" x="171" y="2" width="52" height="58" xoffset="2" yoffset="4" xadvance="56" page="0" chnl="15"/>
+ <char id="72" x="113" y="385" width="45" height="56" xoffset="4" yoffset="5" xadvance="52" page="0" chnl="15"/>
+ <char id="73" x="113" y="443" width="11" height="56" xoffset="5" yoffset="5" xadvance="20" page="0" chnl="15"/>
+ <char id="74" x="126" y="443" width="33" height="57" xoffset="0" yoffset="5" xadvance="36" page="0" chnl="15"/>
+ <char id="75" x="158" y="309" width="47" height="56" xoffset="3" yoffset="5" xadvance="48" page="0" chnl="15"/>
+ <char id="76" x="171" y="251" width="37" height="56" xoffset="3" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="77" x="160" y="367" width="54" height="56" xoffset="3" yoffset="5" xadvance="60" page="0" chnl="15"/>
+ <char id="78" x="207" y="309" width="45" height="56" xoffset="3" yoffset="5" xadvance="52" page="0" chnl="15"/>
+ <char id="79" x="161" y="425" width="54" height="58" xoffset="1" yoffset="4" xadvance="56" page="0" chnl="15"/>
+ <char id="80" x="216" y="367" width="44" height="56" xoffset="4" yoffset="5" xadvance="48" page="0" chnl="15"/>
+ <char id="81" x="217" y="425" width="55" height="61" xoffset="1" yoffset="4" xadvance="56" page="0" chnl="15"/>
+ <char id="82" x="173" y="62" width="50" height="56" xoffset="4" yoffset="5" xadvance="52" page="0" chnl="15"/>
+ <char id="83" x="173" y="120" width="45" height="58" xoffset="1" yoffset="4" xadvance="48" page="0" chnl="15"/>
+ <char id="84" x="176" y="180" width="45" height="56" xoffset="0" yoffset="5" xadvance="44" page="0" chnl="15"/>
+ <char id="85" x="220" y="120" width="45" height="57" xoffset="4" yoffset="5" xadvance="52" page="0" chnl="15"/>
+ <char id="86" x="210" y="238" width="53" height="56" xoffset="-3" yoffset="5" xadvance="48" page="0" chnl="15"/>
+ <char id="87" x="223" y="179" width="72" height="56" xoffset="-2" yoffset="5" xadvance="68" page="0" chnl="15"/>
+ <char id="88" x="254" y="296" width="53" height="56" xoffset="-3" yoffset="5" xadvance="48" page="0" chnl="15"/>
+ <char id="89" x="265" y="237" width="53" height="56" xoffset="-3" yoffset="5" xadvance="48" page="0" chnl="15"/>
+ <char id="90" x="262" y="354" width="45" height="56" xoffset="-1" yoffset="5" xadvance="44" page="0" chnl="15"/>
+ <char id="33" x="274" y="412" width="12" height="56" xoffset="4" yoffset="5" xadvance="20" page="0" chnl="15"/>
+ <char id="8470" x="288" y="412" width="73" height="56" xoffset="4" yoffset="5" xadvance="77" page="0" chnl="15"/>
+ <char id="59" x="309" y="295" width="12" height="52" xoffset="4" yoffset="19" xadvance="20" page="0" chnl="15"/>
+ <char id="37" x="309" y="349" width="60" height="59" xoffset="2" yoffset="4" xadvance="64" page="0" chnl="15"/>
+ <char id="58" x="43" y="2" width="12" height="42" xoffset="5" yoffset="19" xadvance="20" page="0" chnl="15"/>
+ <char id="63" x="363" y="410" width="38" height="57" xoffset="1" yoffset="4" xadvance="40" page="0" chnl="15"/>
+ <char id="42" x="80" y="385" width="29" height="26" xoffset="-1" yoffset="4" xadvance="28" page="0" chnl="15"/>
+ <char id="40" x="225" y="2" width="22" height="72" xoffset="2" yoffset="4" xadvance="24" page="0" chnl="15"/>
+ <char id="41" x="249" y="2" width="22" height="72" xoffset="1" yoffset="4" xadvance="24" page="0" chnl="15"/>
+ <char id="95" x="2" y="501" width="46" height="9" xoffset="-3" yoffset="66" xadvance="40" page="0" chnl="15"/>
+ <char id="43" x="274" y="470" width="38" height="38" xoffset="2" yoffset="14" xadvance="42" page="0" chnl="15"/>
+ <char id="45" x="80" y="369" width="24" height="11" xoffset="0" yoffset="34" xadvance="24" page="0" chnl="15"/>
+ <char id="61" x="132" y="163" width="38" height="26" xoffset="2" yoffset="20" xadvance="42" page="0" chnl="15"/>
+ <char id="46" x="24" y="372" width="12" height="12" xoffset="5" yoffset="49" xadvance="20" page="0" chnl="15"/>
+ <char id="44" x="161" y="488" width="12" height="22" xoffset="4" yoffset="49" xadvance="20" page="0" chnl="15"/>
+ <char id="47" x="267" y="76" width="26" height="58" xoffset="-3" yoffset="4" xadvance="20" page="0" chnl="15"/>
+ <char id="124" x="273" y="2" width="10" height="72" xoffset="5" yoffset="4" xadvance="19" page="0" chnl="15"/>
+ <char id="34" x="41" y="476" width="23" height="23" xoffset="1" yoffset="5" xadvance="26" page="0" chnl="15"/>
+ <char id="39" x="175" y="485" width="12" height="23" xoffset="1" yoffset="5" xadvance="14" page="0" chnl="15"/>
+ <char id="64" x="285" y="2" width="71" height="72" xoffset="2" yoffset="4" xadvance="73" page="0" chnl="15"/>
+ <char id="35" x="295" y="76" width="43" height="58" xoffset="-1" yoffset="4" xadvance="40" page="0" chnl="15"/>
+ <char id="36" x="297" y="136" width="38" height="68" xoffset="1" yoffset="0" xadvance="40" page="0" chnl="15"/>
+ <char id="94" x="66" y="476" width="36" height="33" xoffset="-1" yoffset="4" xadvance="34" page="0" chnl="15"/>
+ <char id="38" x="320" y="206" width="48" height="58" xoffset="1" yoffset="4" xadvance="48" page="0" chnl="15"/>
+ <char id="123" x="323" y="266" width="25" height="72" xoffset="0" yoffset="4" xadvance="24" page="0" chnl="15"/>
+ <char id="125" x="350" y="266" width="25" height="72" xoffset="0" yoffset="4" xadvance="24" page="0" chnl="15"/>
+ <char id="91" x="340" y="76" width="18" height="70" xoffset="3" yoffset="5" xadvance="20" page="0" chnl="15"/>
+ <char id="93" x="358" y="2" width="18" height="70" xoffset="-1" yoffset="5" xadvance="20" page="0" chnl="15"/>
+ <char id="48" x="371" y="340" width="38" height="57" xoffset="1" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="49" x="337" y="148" width="23" height="56" xoffset="6" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="50" x="360" y="74" width="38" height="56" xoffset="0" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="51" x="378" y="2" width="38" height="57" xoffset="1" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="52" x="362" y="132" width="40" height="56" xoffset="-1" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="53" x="400" y="61" width="39" height="56" xoffset="1" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="54" x="418" y="2" width="38" height="57" xoffset="1" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="55" x="370" y="190" width="38" height="55" xoffset="1" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="56" x="404" y="119" width="38" height="57" xoffset="1" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="57" x="377" y="247" width="38" height="57" xoffset="1" yoffset="5" xadvance="40" page="0" chnl="15"/>
+ <char id="32" x="0" y="0" width="0" height="0" xoffset="1" yoffset="5" xadvance="20" page="0" chnl="15"/>
</chars>
- <kernings count="1">
- <kerning first="49" second="49" amount="-7"/>
+ <kernings count="97">
+ <kerning first="32" second="65" amount="-4"/>
+ <kerning first="32" second="84" amount="-1"/>
+ <kerning first="32" second="89" amount="-1"/>
+ <kerning first="49" second="49" amount="-5"/>
+ <kerning first="65" second="32" amount="-4"/>
+ <kerning first="65" second="84" amount="-5"/>
+ <kerning first="65" second="86" amount="-5"/>
+ <kerning first="65" second="87" amount="-3"/>
+ <kerning first="65" second="89" amount="-5"/>
+ <kerning first="65" second="118" amount="-1"/>
+ <kerning first="65" second="119" amount="-1"/>
+ <kerning first="65" second="121" amount="-1"/>
+ <kerning first="70" second="44" amount="-8"/>
+ <kerning first="70" second="46" amount="-8"/>
+ <kerning first="70" second="65" amount="-4"/>
+ <kerning first="76" second="32" amount="-3"/>
+ <kerning first="76" second="84" amount="-5"/>
+ <kerning first="76" second="86" amount="-5"/>
+ <kerning first="76" second="87" amount="-5"/>
+ <kerning first="76" second="89" amount="-5"/>
+ <kerning first="76" second="121" amount="-3"/>
+ <kerning first="80" second="32" amount="-1"/>
+ <kerning first="80" second="44" amount="-9"/>
+ <kerning first="80" second="46" amount="-9"/>
+ <kerning first="80" second="65" amount="-5"/>
+ <kerning first="82" second="84" amount="-1"/>
+ <kerning first="82" second="86" amount="-1"/>
+ <kerning first="82" second="87" amount="-1"/>
+ <kerning first="82" second="89" amount="-1"/>
+ <kerning first="84" second="32" amount="-1"/>
+ <kerning first="84" second="44" amount="-8"/>
+ <kerning first="84" second="45" amount="-4"/>
+ <kerning first="84" second="46" amount="-8"/>
+ <kerning first="84" second="58" amount="-8"/>
+ <kerning first="84" second="59" amount="-8"/>
+ <kerning first="84" second="65" amount="-5"/>
+ <kerning first="84" second="79" amount="-1"/>
+ <kerning first="84" second="97" amount="-8"/>
+ <kerning first="84" second="99" amount="-8"/>
+ <kerning first="84" second="101" amount="-8"/>
+ <kerning first="84" second="105" amount="-3"/>
+ <kerning first="84" second="111" amount="-8"/>
+ <kerning first="84" second="114" amount="-3"/>
+ <kerning first="84" second="115" amount="-8"/>
+ <kerning first="84" second="117" amount="-3"/>
+ <kerning first="84" second="119" amount="-4"/>
+ <kerning first="84" second="121" amount="-4"/>
+ <kerning first="86" second="44" amount="-7"/>
+ <kerning first="86" second="45" amount="-4"/>
+ <kerning first="86" second="46" amount="-7"/>
+ <kerning first="86" second="58" amount="-3"/>
+ <kerning first="86" second="59" amount="-3"/>
+ <kerning first="86" second="65" amount="-5"/>
+ <kerning first="86" second="97" amount="-5"/>
+ <kerning first="86" second="101" amount="-4"/>
+ <kerning first="86" second="105" amount="-1"/>
+ <kerning first="86" second="111" amount="-4"/>
+ <kerning first="86" second="114" amount="-3"/>
+ <kerning first="86" second="117" amount="-3"/>
+ <kerning first="86" second="121" amount="-3"/>
+ <kerning first="87" second="44" amount="-4"/>
+ <kerning first="87" second="45" amount="-1"/>
+ <kerning first="87" second="46" amount="-4"/>
+ <kerning first="87" second="58" amount="-1"/>
+ <kerning first="87" second="59" amount="-1"/>
+ <kerning first="87" second="65" amount="-3"/>
+ <kerning first="87" second="97" amount="-3"/>
+ <kerning first="87" second="101" amount="-1"/>
+ <kerning first="87" second="105" amount="0"/>
+ <kerning first="87" second="111" amount="-1"/>
+ <kerning first="87" second="114" amount="-1"/>
+ <kerning first="87" second="117" amount="-1"/>
+ <kerning first="87" second="121" amount="-1"/>
+ <kerning first="89" second="32" amount="-1"/>
+ <kerning first="89" second="44" amount="-9"/>
+ <kerning first="89" second="45" amount="-7"/>
+ <kerning first="89" second="46" amount="-9"/>
+ <kerning first="89" second="58" amount="-4"/>
+ <kerning first="89" second="59" amount="-5"/>
+ <kerning first="89" second="65" amount="-5"/>
+ <kerning first="89" second="97" amount="-5"/>
+ <kerning first="89" second="101" amount="-7"/>
+ <kerning first="89" second="105" amount="-3"/>
+ <kerning first="89" second="111" amount="-7"/>
+ <kerning first="89" second="112" amount="-5"/>
+ <kerning first="89" second="113" amount="-7"/>
+ <kerning first="89" second="117" amount="-4"/>
+ <kerning first="89" second="118" amount="-4"/>
+ <kerning first="102" second="102" amount="-1"/>
+ <kerning first="114" second="44" amount="-4"/>
+ <kerning first="114" second="46" amount="-4"/>
+ <kerning first="118" second="44" amount="-5"/>
+ <kerning first="118" second="46" amount="-5"/>
+ <kerning first="119" second="44" amount="-4"/>
+ <kerning first="119" second="46" amount="-4"/>
+ <kerning first="121" second="44" amount="-5"/>
+ <kerning first="121" second="46" amount="-5"/>
</kernings>
</font> \ No newline at end of file
diff --git a/assets/fonts/scorefont.png b/assets/fonts/scorefont.png
index 96e4a82..0b34395 100644
--- a/assets/fonts/scorefont.png
+++ b/assets/fonts/scorefont.png
Binary files differ
diff --git a/game/states/play.js b/game/states/play.js
index 96188e5..a68b068 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -44,24 +44,32 @@ Play.prototype = {
this.game.physics.startSystem(Phaser.Physics.ARCADE);
- this.playerAScoreText = this.game.add.bitmapText(-0.1, -0.4, 'scorefont','0',1);
- this.playerBScoreText = this.game.add.bitmapText(this.world.width/100 - 2.1, -0.4, 'scorefont','0',1);
+ this.playerAScoreText = this.game.add.bitmapText(-0.1, -0.4, 'spaced-scorefont','0',1);
+ this.playerBScoreText = this.game.add.bitmapText(this.world.width/this.world.scale.x - 2.1, -0.4, 'spaced-scorefont','0',1);
+
+ this.victoryText = this.game.add.bitmapText(this.world.width/2/this.world.scale.x, 2, 'scorefont', '', 1);
+
+ this.gameWon = false;
},
update: function() {
this.game.physics.arcade.overlap(this.players, this.pills, this.playerPillCollision, null, this);
- if (this.pills.total === 0) {
-
+ if (!this.gameWon && this.pills.total === 0) {
+ this.gameWon = true;
if (this.playerA.score > this.playerB.score) {
- console.log("PLAYER A WINS!");
+ this.setVictoryText("PLAYER A WINS");
}
else if (this.playerA.score < this.playerB.score) {
- console.log("PLAYER B WINS!");
+ this.setVictoryText("PLAYER B WINS");
}
else {
- console.log("THIS GAME WAS A DRAW!")
+ this.setVictoryText("DRAW");
}
- this.game.state.start('play');
+
+ var self = this;
+ setTimeout(function() {
+ self.game.state.start('play');
+ }, 5000);
}
},
createWalls: function() {
@@ -139,13 +147,13 @@ Play.prototype = {
this.updatePlayerTurn(0);
},
addPlayerControls: function() {
- var playerAControls = {
+ this.playerAControls = {
up: Phaser.Keyboard.W,
left: Phaser.Keyboard.A,
down: Phaser.Keyboard.S,
right: Phaser.Keyboard.D
}
- var playerBControls = {
+ this.playerBControls = {
up: Phaser.Keyboard.UP,
left: Phaser.Keyboard.LEFT,
down: Phaser.Keyboard.DOWN,
@@ -155,22 +163,22 @@ Play.prototype = {
function addKeyCaptures(controls, keyboard) {
for (var index in controls) {
if (controls.hasOwnProperty(index)) {
- keyboard.addKeyCapture(playerAControls[index]);
+ keyboard.addKeyCapture(controls[index]);
}
}
}
- addKeyCaptures(playerAControls, this.game.input.keyboard);
- addKeyCaptures(playerBControls, this.game.input.keyboard);
-
- this.game.input.keyboard.addKey(playerAControls.up).onDown.add(this.movePlayer.bind(this, this.playerA, 0, -1), this);
- this.game.input.keyboard.addKey(playerAControls.down).onDown.add(this.movePlayer.bind(this, this.playerA, 0, 1), this);
- this.game.input.keyboard.addKey(playerAControls.left).onDown.add(this.movePlayer.bind(this, this.playerA, -1, 0), this);
- this.game.input.keyboard.addKey(playerAControls.right).onDown.add(this.movePlayer.bind(this, this.playerA, 1, 0), this);
-
- this.game.input.keyboard.addKey(playerBControls.up).onDown.add(this.movePlayer.bind(this, this.playerB, 0, -1), this);
- this.game.input.keyboard.addKey(playerBControls.down).onDown.add(this.movePlayer.bind(this, this.playerB, 0, 1), this);
- this.game.input.keyboard.addKey(playerBControls.left).onDown.add(this.movePlayer.bind(this, this.playerB, -1, 0), this);
- this.game.input.keyboard.addKey(playerBControls.right).onDown.add(this.movePlayer.bind(this, this.playerB, 1, 0), this);
+ addKeyCaptures(this.playerAControls, this.game.input.keyboard);
+ addKeyCaptures(this.playerBControls, this.game.input.keyboard);
+
+ this.game.input.keyboard.addKey(this.playerAControls.up).onDown.add(this.movePlayer.bind(this, this.playerA, 0, -1), this);
+ this.game.input.keyboard.addKey(this.playerAControls.down).onDown.add(this.movePlayer.bind(this, this.playerA, 0, 1), this);
+ this.game.input.keyboard.addKey(this.playerAControls.left).onDown.add(this.movePlayer.bind(this, this.playerA, -1, 0), this);
+ this.game.input.keyboard.addKey(this.playerAControls.right).onDown.add(this.movePlayer.bind(this, this.playerA, 1, 0), this);
+
+ this.game.input.keyboard.addKey(this.playerBControls.up).onDown.add(this.movePlayer.bind(this, this.playerB, 0, -1), this);
+ this.game.input.keyboard.addKey(this.playerBControls.down).onDown.add(this.movePlayer.bind(this, this.playerB, 0, 1), this);
+ this.game.input.keyboard.addKey(this.playerBControls.left).onDown.add(this.movePlayer.bind(this, this.playerB, -1, 0), this);
+ this.game.input.keyboard.addKey(this.playerBControls.right).onDown.add(this.movePlayer.bind(this, this.playerB, 1, 0), this);
},
movePlayer: function(player, deltaX, deltaY) {
var newX = player.x + deltaX;
@@ -197,6 +205,21 @@ Play.prototype = {
this.players.children[i].isMyTurn = (i === this.playerTurn);
}
console.log("Player " + this.playerTurn + "'s turn");
+ },
+ setVictoryText: function(newText) {
+ this.victoryText.setText(newText);
+ this.victoryText.position.x = this.world.width/2/this.world.scale.x - this.victoryText.textWidth/2 - 0.5;
+ },
+ shutdown: function() {
+ this.game.input.keyboard.removeKey(this.playerAControls.up);
+ this.game.input.keyboard.removeKey(this.playerAControls.down);
+ this.game.input.keyboard.removeKey(this.playerAControls.left);
+ this.game.input.keyboard.removeKey(this.playerAControls.right);
+
+ this.game.input.keyboard.removeKey(this.playerBControls.up);
+ this.game.input.keyboard.removeKey(this.playerBControls.down);
+ this.game.input.keyboard.removeKey(this.playerBControls.left);
+ this.game.input.keyboard.removeKey(this.playerBControls.right);
}
};
diff --git a/game/states/preload.js b/game/states/preload.js
index 28420f7..c24174a 100644
--- a/game/states/preload.js
+++ b/game/states/preload.js
@@ -17,7 +17,8 @@ Preload.prototype = {
this.load.image('player-b', 'assets/images/player-b.svg');
this.load.image('pill', 'assets/images/pill.svg');
- this.load.bitmapFont('scorefont', 'assets/fonts/scorefont.png', 'assets/fonts/scorefont.fnt', undefined, 10);
+ this.load.bitmapFont('spaced-scorefont', 'assets/fonts/scorefont.png', 'assets/fonts/scorefont.fnt', undefined, 10);
+ this.load.bitmapFont('scorefont', 'assets/fonts/scorefont.png', 'assets/fonts/scorefont.fnt');
},
create: function() {
this.asset.cropEnabled = false;
diff --git a/package.json b/package.json
index 6ae9b8d..cd6c109 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
- "name": "interactive-pacbot",
+ "name": "interactive-pacbot",
"private": true,
"devDependencies": {
"grunt": "~0.4.1",
@@ -18,5 +18,14 @@
},
"engines": {
"node": ">=0.8.0"
+ },
+ "main": "dist/index.html",
+ "window": {
+ "title": "Interactive Pacbot",
+ "toolbar": false,
+ "frame": true,
+ "width": 820,
+ "height": 620,
+ "position": "center"
}
} \ No newline at end of file