Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
luanit96 committed Aug 20, 2020
1 parent 66298b3 commit 5c214ff
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 94 deletions.
Binary file added assets/fonts/bitmap/text_slot_machine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions assets/fonts/bitmap/text_slot_machine.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<font>
<info face="font" size="128" bold="0" italic="0" charset="" unicode="" stretchH="100" smooth="1" aa="1" padding="2,2,2,2" spacing="0,0" outline="0"/>
<common lineHeight="144" base="94" scaleW="1178" scaleH="512" pages="1" packed="0"/>
<pages>
<page id="0" file="font.png"/>
</pages>
<chars count="91">
<char id="97" x="2" y="2" width="64" height="72" xoffset="4" yoffset="25" xadvance="73" page="0" chnl="15"/>
<char id="98" x="2" y="76" width="64" height="96" xoffset="4" yoffset="1" xadvance="73" page="0" chnl="15"/>
<char id="99" x="2" y="174" width="64" height="72" xoffset="4" yoffset="25" xadvance="69" page="0" chnl="15"/>
<char id="100" x="2" y="248" width="64" height="96" xoffset="4" yoffset="1" xadvance="73" page="0" chnl="15"/>
<char id="101" x="2" y="346" width="68" height="72" xoffset="4" yoffset="25" xadvance="77" page="0" chnl="15"/>
<char id="102" x="68" y="2" width="60" height="96" xoffset="1" yoffset="1" xadvance="56" page="0" chnl="15"/>
<char id="103" x="68" y="100" width="68" height="100" xoffset="0" yoffset="25" xadvance="73" page="0" chnl="15"/>
<char id="104" x="130" y="2" width="64" height="96" xoffset="4" yoffset="1" xadvance="73" page="0" chnl="15"/>
<char id="105" x="68" y="202" width="23" height="96" xoffset="6" yoffset="1" xadvance="36" page="0" chnl="15"/>
<char id="106" x="72" y="300" width="48" height="124" xoffset="-5" yoffset="1" xadvance="48" page="0" chnl="15"/>
<char id="107" x="2" y="426" width="70" height="84" xoffset="4" yoffset="13" xadvance="75" page="0" chnl="15"/>
<char id="108" x="93" y="202" width="23" height="96" xoffset="6" yoffset="1" xadvance="36" page="0" chnl="15"/>
<char id="109" x="74" y="426" width="80" height="72" xoffset="4" yoffset="25" xadvance="89" page="0" chnl="15"/>
<char id="110" x="118" y="202" width="64" height="72" xoffset="4" yoffset="25" xadvance="73" page="0" chnl="15"/>
<char id="111" x="138" y="100" width="64" height="72" xoffset="4" yoffset="25" xadvance="73" page="0" chnl="15"/>
<char id="112" x="122" y="276" width="64" height="100" xoffset="4" yoffset="25" xadvance="73" page="0" chnl="15"/>
<char id="113" x="184" y="174" width="64" height="100" xoffset="4" yoffset="25" xadvance="73" page="0" chnl="15"/>
<char id="114" x="196" y="2" width="64" height="72" xoffset="4" yoffset="25" xadvance="64" page="0" chnl="15"/>
<char id="115" x="204" y="76" width="68" height="72" xoffset="4" yoffset="25" xadvance="75" page="0" chnl="15"/>
<char id="116" x="156" y="378" width="52" height="96" xoffset="4" yoffset="1" xadvance="57" page="0" chnl="15"/>
<char id="117" x="262" y="2" width="64" height="72" xoffset="4" yoffset="25" xadvance="73" page="0" chnl="15"/>
<char id="118" x="188" y="276" width="68" height="74" xoffset="0" yoffset="25" xadvance="69" page="0" chnl="15"/>
<char id="119" x="250" y="150" width="80" height="72" xoffset="4" yoffset="25" xadvance="89" page="0" chnl="15"/>
<char id="120" x="274" y="76" width="72" height="72" xoffset="3" yoffset="25" xadvance="78" page="0" chnl="15"/>
<char id="121" x="210" y="352" width="68" height="100" xoffset="0" yoffset="25" xadvance="69" page="0" chnl="15"/>
<char id="122" x="328" y="2" width="68" height="72" xoffset="2" yoffset="25" xadvance="71" page="0" chnl="15"/>
<char id="65" x="258" y="224" width="80" height="84" xoffset="0" yoffset="13" xadvance="85" page="0" chnl="15"/>
<char id="66" x="280" y="310" width="77" height="84" xoffset="4" yoffset="13" xadvance="83" page="0" chnl="15"/>
<char id="67" x="280" y="396" width="68" height="84" xoffset="4" yoffset="13" xadvance="73" page="0" chnl="15"/>
<char id="68" x="350" y="396" width="77" height="84" xoffset="4" yoffset="13" xadvance="83" page="0" chnl="15"/>
<char id="69" x="340" y="150" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="70" x="398" y="2" width="68" height="84" xoffset="4" yoffset="13" xadvance="73" page="0" chnl="15"/>
<char id="71" x="359" y="236" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="72" x="410" y="88" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="73" x="468" y="2" width="23" height="84" xoffset="6" yoffset="13" xadvance="36" page="0" chnl="15"/>
<char id="74" x="429" y="174" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="75" x="480" y="88" width="75" height="84" xoffset="4" yoffset="13" xadvance="80" page="0" chnl="15"/>
<char id="76" x="493" y="2" width="68" height="84" xoffset="4" yoffset="13" xadvance="73" page="0" chnl="15"/>
<char id="77" x="429" y="260" width="100" height="84" xoffset="4" yoffset="13" xadvance="109" page="0" chnl="15"/>
<char id="78" x="499" y="174" width="80" height="84" xoffset="4" yoffset="13" xadvance="89" page="0" chnl="15"/>
<char id="79" x="557" y="88" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="80" x="563" y="2" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="81" x="429" y="346" width="76" height="96" xoffset="4" yoffset="13" xadvance="81" page="0" chnl="15"/>
<char id="82" x="507" y="346" width="73" height="84" xoffset="4" yoffset="13" xadvance="78" page="0" chnl="15"/>
<char id="83" x="531" y="260" width="72" height="84" xoffset="3" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="84" x="581" y="174" width="76" height="84" xoffset="4" yoffset="13" xadvance="81" page="0" chnl="15"/>
<char id="85" x="627" y="88" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="86" x="633" y="2" width="80" height="84" xoffset="4" yoffset="13" xadvance="85" page="0" chnl="15"/>
<char id="87" x="582" y="346" width="100" height="84" xoffset="4" yoffset="13" xadvance="109" page="0" chnl="15"/>
<char id="88" x="605" y="260" width="80" height="84" xoffset="3" yoffset="13" xadvance="86" page="0" chnl="15"/>
<char id="89" x="659" y="174" width="87" height="84" xoffset="0" yoffset="13" xadvance="88" page="0" chnl="15"/>
<char id="90" x="697" y="88" width="72" height="84" xoffset="1" yoffset="13" xadvance="74" page="0" chnl="15"/>
<char id="33" x="715" y="2" width="23" height="84" xoffset="4" yoffset="13" xadvance="32" page="0" chnl="15"/>
<char id="8470" x="118" y="276" width="0" height="0" xoffset="0" yoffset="94" xadvance="79" page="0" chnl="15"/>
<char id="59" x="740" y="2" width="23" height="84" xoffset="6" yoffset="33" xadvance="36" page="0" chnl="15"/>
<char id="37" x="684" y="346" width="73" height="119" xoffset="4" yoffset="1" xadvance="82" page="0" chnl="15"/>
<char id="58" x="429" y="444" width="23" height="64" xoffset="6" yoffset="33" xadvance="36" page="0" chnl="15"/>
<char id="63" x="765" y="2" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="42" x="122" y="378" width="31" height="33" xoffset="4" yoffset="13" xadvance="40" page="0" chnl="15"/>
<char id="40" x="748" y="174" width="37" height="123" xoffset="4" yoffset="1" xadvance="46" page="0" chnl="15"/>
<char id="41" x="759" y="299" width="37" height="123" xoffset="4" yoffset="1" xadvance="46" page="0" chnl="15"/>
<char id="95" x="156" y="482" width="88" height="23" xoffset="0" yoffset="98" xadvance="89" page="0" chnl="15"/>
<char id="43" x="507" y="432" width="72" height="72" xoffset="4" yoffset="19" xadvance="81" page="0" chnl="15"/>
<char id="45" x="210" y="454" width="62" height="23" xoffset="4" yoffset="43" xadvance="71" page="0" chnl="15"/>
<char id="61" x="581" y="432" width="76" height="55" xoffset="5" yoffset="25" xadvance="87" page="0" chnl="15"/>
<char id="46" x="659" y="432" width="23" height="23" xoffset="4" yoffset="74" xadvance="32" page="0" chnl="15"/>
<char id="44" x="659" y="457" width="23" height="44" xoffset="4" yoffset="74" xadvance="32" page="0" chnl="15"/>
<char id="47" x="787" y="88" width="49" height="119" xoffset="6" yoffset="1" xadvance="59" page="0" chnl="15"/>
<char id="124" x="798" y="209" width="23" height="120" xoffset="4" yoffset="1" xadvance="32" page="0" chnl="15"/>
<char id="34" x="138" y="174" width="40" height="23" xoffset="4" yoffset="9" xadvance="48" page="0" chnl="15"/>
<char id="39" x="246" y="482" width="24" height="23" xoffset="4" yoffset="9" xadvance="32" page="0" chnl="15"/>
<char id="64" x="798" y="331" width="129" height="128" xoffset="4" yoffset="0" xadvance="138" page="0" chnl="15"/>
<char id="35" x="823" y="209" width="91" height="92" xoffset="4" yoffset="9" xadvance="100" page="0" chnl="15"/>
<char id="36" x="838" y="2" width="72" height="100" xoffset="4" yoffset="5" xadvance="81" page="0" chnl="15"/>
<char id="94" x="684" y="467" width="44" height="42" xoffset="4" yoffset="13" xadvance="53" page="0" chnl="15"/>
<char id="38" x="838" y="104" width="95" height="84" xoffset="4" yoffset="13" xadvance="104" page="0" chnl="15"/>
<char id="123" x="916" y="190" width="54" height="128" xoffset="4" yoffset="1" xadvance="63" page="0" chnl="15"/>
<char id="125" x="935" y="2" width="54" height="128" xoffset="4" yoffset="1" xadvance="63" page="0" chnl="15"/>
<char id="91" x="929" y="320" width="37" height="120" xoffset="4" yoffset="1" xadvance="46" page="0" chnl="15"/>
<char id="93" x="968" y="320" width="37" height="120" xoffset="4" yoffset="1" xadvance="46" page="0" chnl="15"/>
<char id="48" x="972" y="132" width="64" height="84" xoffset="4" yoffset="13" xadvance="73" page="0" chnl="15"/>
<char id="49" x="687" y="260" width="38" height="84" xoffset="3" yoffset="13" xadvance="46" page="0" chnl="15"/>
<char id="50" x="972" y="218" width="72" height="84" xoffset="4" yoffset="13" xadvance="81" page="0" chnl="15"/>
<char id="51" x="991" y="2" width="72" height="84" xoffset="0" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="52" x="1038" y="88" width="68" height="84" xoffset="1" yoffset="13" xadvance="74" page="0" chnl="15"/>
<char id="53" x="1065" y="2" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="54" x="1007" y="304" width="64" height="84" xoffset="4" yoffset="13" xadvance="73" page="0" chnl="15"/>
<char id="55" x="1007" y="390" width="68" height="84" xoffset="0" yoffset="13" xadvance="70" page="0" chnl="15"/>
<char id="56" x="1046" y="174" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="57" x="1108" y="88" width="68" height="84" xoffset="4" yoffset="13" xadvance="77" page="0" chnl="15"/>
<char id="92" x="1073" y="260" width="49" height="120" xoffset="0" yoffset="1" xadvance="51" page="0" chnl="15"/>
<char id="32" x="0" y="0" width="0" height="0" xoffset="0" yoffset="1" xadvance="77" page="0" chnl="15"/>
</chars>
</font>
Binary file added assets/jsons/audio/freespin.mp3
Binary file not shown.
6 changes: 3 additions & 3 deletions src/Scene/BootScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import Config from '../Config/config';

export default class BootScene extends Phaser.Scene {
constructor() {
super({ key : 'BootScene' });
super({ key: 'BootScene' });
}

create() {
//add music audio
this.musicBackgroundDefault = this.sound.add('backgroundDefault', {
loop : true,
volume : 2.5
loop: true,
volume: 1.5
});
this.musicBackgroundDefault.play();
const bgloading = new Sprite(this, Config.width / 2, Config.height / 2, 'bgPreload', 'bg_menu.png');
Expand Down
97 changes: 68 additions & 29 deletions src/Scene/GameScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,26 @@ export default class GameScene extends Phaser.Scene {
super({ key: 'GameScene' });
}

preload() {
this.load.path = '../../assets/fonts/bitmap/';
this.load.bitmapFont('txt_bitmap', 'text_slot_machine.png', 'text_slot_machine.xml');
}

create() {
//add audio
this.audioReels = this.sound.add('reels');
this.audioReelStop = this.sound.add('reelStop');
this.audioWin = this.sound.add('win', { loop : true });
this.audioButton = this.sound.add('button');
this.audioLose = this.sound.add('lose', { volume: 2.5 });
this.audioBigWin = this.sound.add('bigwin', { loop : true });
this.audioBigWin = this.sound.add('bigwin', { loop : true, volume : 2.5 });
this.freeSpin = this.sound.add('freeSpin', { volume: 2.5 });
this.musicDefault = this.sound.add('backgroundDefault', {
loop: true,
volume: 2
});
// bitmap
Options.hsv = Phaser.Display.Color.HSVColorWheel();
//add bg image
const bg = new Sprite(this,Config.width / 2, Config.height / 2, 'background', 'bg.jpg');
//container
Expand Down Expand Up @@ -62,7 +74,8 @@ export default class GameScene extends Phaser.Scene {
if(!Options.checkClick) {
if(this.audioMusicName === 'btn_music.png') {
this.audioMusicName = 'btn_music_off.png';
//audio play
//audio stop
this.musicDefault.stop();
this.audioReels.stop();
this.audioReelStop.stop();
this.audioWin.stop();
Expand All @@ -74,6 +87,8 @@ export default class GameScene extends Phaser.Scene {
if(this.audioSoundName === 'btn_sound.png') {
this.audioButton.play();
}
//audio play
this.musicDefault.play();
}
//save localstorage
if(localStorage.getItem('musics')) {
Expand Down Expand Up @@ -103,10 +118,14 @@ export default class GameScene extends Phaser.Scene {
this.btnSound.setTexture('sound', this.audioSoundName);
}
});
//audio default
if(this.audioMusicName === 'btn_music.png') {
this.musicDefault.play();
}
//add image buttons
this.bgMaxBet();
this.bgCoin();
this.bgLine();
this.bgMaxBet();
//class info
this.info = new Info(this, Config.width - 1020, Config.height - 50, 'bgButtons', 'btn-info.png');
this.spin();
Expand Down Expand Up @@ -314,35 +333,14 @@ export default class GameScene extends Phaser.Scene {
spin() {
this.bgSpin = new Sprite(this, Config.width - 275, Config.height - 50, 'bgButtons', 'btn-spin.png');
//text spin
this.txtSpin = this.add.text(Config.width - 310, Config.height - 70, Options.txtSpin, Style.styleButton);
}

bgMaxBet() {
this.maxBet = new Sprite(this, Config.width - 477, Config.height - 50, 'bgButtons', 'btn-maxbet.png');
this.txtMaxBet = this.add.text(Config.width - 550, Config.height - 70, Options.txtMaxBet, Style.styleButton);
this.txtCountMaxBet = this.add.text(Config.width - 550, Config.height - 140, 'BET: ' + Options.bet, Style.styleButton);
//pointer down
this.maxBet.on('pointerdown', () => {
if (!Options.checkClick) {
this.maxBet.setScale(0.9);
if(this.audioSoundName === 'btn_sound.png') {
//audio play
this.audioButton.play();
}
Options.line = 10;
this.txtCountLine.setText(Options.line);
Options.coin = 50;
this.txtCountCoin.setText(Options.coin);
this.txtCountMaxBet.setText('BET: ' + Options.line * Options.coin);
}
});
//pointer up
this.maxBet.on('pointerup', () => this.maxBet.setScale(1));
this.txtSpin = this.add.dynamicBitmapText(Config.width - 315, Config.height - 70, 'txt_bitmap', Options.txtSpin, Style.fontSize);
this.txtSpin.setDisplayCallback(this.textCallback);
}

bgCoin() {
this.coin = new Sprite(this, Config.width - 678, Config.height - 50, 'bgButtons', 'btn-coin.png');
this.txtCoin = this.add.text(Config.width - 720, Config.height - 70, Options.txtCoin, Style.styleButton);
this.txtCoin = this.txtSpin = this.add.dynamicBitmapText(Config.width - 720, Config.height - 70, 'txt_bitmap', Options.txtCoin, Style.fontSize);
this.txtCoin.setDisplayCallback(this.textCallback);
this.txtCountCoin = this.add.text(Config.width - 700, Config.height - 140, Options.coin, Style.styleButton);
//pointer down
this.coin.on('pointerdown', () => {
Expand All @@ -369,7 +367,8 @@ export default class GameScene extends Phaser.Scene {

bgLine() {
this.btnLine = new Sprite(this, Config.width - 865, Config.height - 50, 'bgButtons', 'btn-line.png');
this.txtLine = this.add.text(Config.width - 915, Config.height - 70, Options.txtLine, Style.styleButton);
this.txtLine = this.txtCoin = this.txtSpin = this.add.dynamicBitmapText(Config.width - 915, Config.height - 70, 'txt_bitmap', Options.txtLine, Style.fontSize);
this.txtLine.setDisplayCallback(this.textCallback);
this.txtCountLine = this.add.text(Config.width - 880, Config.height - 140, Options.line, Style.styleButton);
//pointer down
this.btnLine.on('pointerdown', () => {
Expand All @@ -394,5 +393,45 @@ export default class GameScene extends Phaser.Scene {
this.btnLine.on('pointerup', () => this.btnLine.setScale(1));
}

bgMaxBet() {
this.maxBet = new Sprite(this, Config.width - 477, Config.height - 50, 'bgButtons', 'btn-maxbet.png');
this.txtMaxBet = this.add.dynamicBitmapText(Config.width - 550, Config.height - 70, 'txt_bitmap', Options.txtMaxBet, Style.fontSize);
this.txtMaxBet.setDisplayCallback(this.textCallback);
this.txtCountMaxBet = this.add.text(Config.width - 550, Config.height - 140, 'BET: ' + Options.coin * Options.line, Style.styleButton);
//pointer down
this.maxBet.on('pointerdown', () => {
if (!Options.checkClick) {
this.maxBet.setScale(0.9);
if(this.audioSoundName === 'btn_sound.png') {
//audio play
this.audioButton.play();
}
Options.line = 10;
this.txtCountLine.setText(Options.line);
Options.coin = 50;
this.txtCountCoin.setText(Options.coin);
this.txtCountMaxBet.setText('BET: ' + Options.line * Options.coin);
}
});
//pointer up
this.maxBet.on('pointerup', () => this.maxBet.setScale(1));
}

textCallback(data) {
data.tint.topLeft = Options.hsv[Math.floor(Options.i)].color;
data.tint.topRight = Options.hsv[359 - Math.floor(Options.i)].color;
data.tint.bottomLeft = Options.hsv[359 - Math.floor(Options.i)].color;
data.tint.bottomRight = Options.hsv[Math.floor(Options.i)].color;

Options.i += 0.05;

if (Options.i >= Options.hsv.length)
{
Options.i = 0;
}

return data;
}

update() { }
}
1 change: 1 addition & 0 deletions src/Scene/PreloadScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default class PreloadScene extends Phaser.Scene {
this.load.audio('button', 'audio/button.mp3');
this.load.audio('lose', 'audio/lose.mp3');
this.load.audio('bigwin', 'audio/big_win.mp3');
this.load.audio('freeSpin', 'audio/freespin.mp3');

this.progressBar = this.add.graphics();
this.progressBox = this.add.graphics();
Expand Down
Loading

0 comments on commit 5c214ff

Please sign in to comment.