WIP version of the game
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ Cargo.lock
|
||||||
bin/
|
bin/
|
||||||
pkg/
|
pkg/
|
||||||
wasm-pack.log
|
wasm-pack.log
|
||||||
|
node_modules
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Hello wasm-pack!</title>
|
<title>Hopeanuoli</title>
|
||||||
|
<link rel="preload" as="font" href="assets/Kenney Bold.ttf" type="font/ttf" />
|
||||||
|
<link rel="stylesheet" href="fonts.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
BIN
public/assets/Kenney Bold.ttf
Normal file
BIN
public/assets/background01.png
Normal file
After Width: | Height: | Size: 2.9 MiB |
BIN
public/assets/background02.png
Normal file
After Width: | Height: | Size: 678 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
BIN
public/assets/card-shadow.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
BIN
public/assets/characters/ben_card.png
Normal file
After Width: | Height: | Size: 124 KiB |
BIN
public/assets/characters/cross_card.png
Normal file
After Width: | Height: | Size: 154 KiB |
BIN
public/assets/characters/gin_card.png
Normal file
After Width: | Height: | Size: 143 KiB |
BIN
public/assets/characters/hyena_card.png
Normal file
After Width: | Height: | Size: 130 KiB |
BIN
public/assets/characters/john_card.png
Normal file
After Width: | Height: | Size: 140 KiB |
BIN
public/assets/characters/madara_card.png
Normal file
After Width: | Height: | Size: 55 KiB |
BIN
public/assets/characters/mosa_card.png
Normal file
After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
BIN
public/assets/characters/smith_card.png
Normal file
After Width: | Height: | Size: 163 KiB |
BIN
public/assets/characters/sniper_card.png
Normal file
After Width: | Height: | Size: 133 KiB |
380
public/assets/data.json
Normal file
|
@ -0,0 +1,380 @@
|
||||||
|
{
|
||||||
|
"characters": [
|
||||||
|
{
|
||||||
|
"name": "Gin",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "5",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "5",
|
||||||
|
"total": "13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Riki",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "5",
|
||||||
|
"strength": "5",
|
||||||
|
"charisma": "5",
|
||||||
|
"total": "15"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ben",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "5",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "John",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "2",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Cross",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "2",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Smith",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Great",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hyena",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "1",
|
||||||
|
"strength": "2",
|
||||||
|
"charisma": "0",
|
||||||
|
"total": "3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Sniper",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "2",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Akatora",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Chuutora",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kurotora",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Moss",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "2",
|
||||||
|
"strength": "5",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Akame",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "5",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kurojaki",
|
||||||
|
"alliance": "Kougan shinobit",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Wilson",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Musashi",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Bill",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Benizakura",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "5",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kisaragi",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hazuki",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "2",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "2",
|
||||||
|
"total": "7"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Minazuki",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "2",
|
||||||
|
"strength": "1",
|
||||||
|
"charisma": "0",
|
||||||
|
"total": "3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Oliver",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "2",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Terry",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "2",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Bemu",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "2",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hakurou",
|
||||||
|
"alliance": "Ouun armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Akakabuto",
|
||||||
|
"alliance": "Karhu-armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "5",
|
||||||
|
"charisma": "5",
|
||||||
|
"total": "14"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Madara",
|
||||||
|
"alliance": "Karhu-armeija",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mosa",
|
||||||
|
"alliance": "Karhu-armeija",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "5",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Retsuga",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Fuuga",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hyouma",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mukonga",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "5",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hyakkiga",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "2",
|
||||||
|
"total": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Shuuga",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "2",
|
||||||
|
"total": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Raiga",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "2",
|
||||||
|
"total": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Suiga",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Noroi",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "5",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Reima",
|
||||||
|
"alliance": "Susien valtakunta",
|
||||||
|
"skill": "5",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "5",
|
||||||
|
"total": "14"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mugen",
|
||||||
|
"alliance": "Gaian imperiumi",
|
||||||
|
"skill": "",
|
||||||
|
"strength": "",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Thousand Dragon",
|
||||||
|
"alliance": "Gaian imperiumi",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Black-Snake",
|
||||||
|
"alliance": "Gaian imperiumi",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Goldeye",
|
||||||
|
"alliance": "Gaian imperiumi",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "3",
|
||||||
|
"total": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "White Tiger",
|
||||||
|
"alliance": "Gaian imperiumi",
|
||||||
|
"skill": "4",
|
||||||
|
"strength": "3",
|
||||||
|
"charisma": "2",
|
||||||
|
"total": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Big Horn",
|
||||||
|
"alliance": "Gaian imperiumi",
|
||||||
|
"skill": "3",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "2",
|
||||||
|
"total": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Juga",
|
||||||
|
"alliance": "Gaian imperiumi",
|
||||||
|
"skill": "5",
|
||||||
|
"strength": "4",
|
||||||
|
"charisma": "4",
|
||||||
|
"total": "13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gaia",
|
||||||
|
"alliance": "Gaian imperiumi",
|
||||||
|
"skill": "5",
|
||||||
|
"strength": "5",
|
||||||
|
"charisma": "5",
|
||||||
|
"total": "15"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
BIN
public/favicon.gif
Executable file
After Width: | Height: | Size: 309 B |
BIN
public/favicon.ico
Normal file
After Width: | Height: | Size: 646 B |
16
public/fonts.css
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
@font-face {
|
||||||
|
font-family: KenneyBold;
|
||||||
|
src: url('assets/Kenney\ Bold.ttf');
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#silver-fang-mini-game {
|
||||||
|
/*width: 1080px;
|
||||||
|
height: 1920px;*/
|
||||||
|
width: 540px;
|
||||||
|
height: 960px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
|
@ -1,16 +1,22 @@
|
||||||
// import * as MiniGame from "mini-game";
|
// import * as MiniGame from "mini-game";
|
||||||
import * as Phaser from "phaser";
|
import * as Phaser from "phaser";
|
||||||
import MainMenuScene from "./scenes/main-menu";
|
import MainMenuScene from "./scenes/main-menu";
|
||||||
|
import BootScene from "./scenes/boot";
|
||||||
|
import PreloaderScene from "./scenes/preloader";
|
||||||
|
|
||||||
const GameConfig: Phaser.Types.Core.GameConfig = {
|
const GameConfig: Phaser.Types.Core.GameConfig = {
|
||||||
title: 'ExampleGame',
|
title: 'SilverFangMiniGame',
|
||||||
version: '2.0',
|
version: '2.0',
|
||||||
width: 800,
|
width: 1080 / 2,
|
||||||
height: 600,
|
height: 1920 / 2,
|
||||||
type: Phaser.AUTO,
|
type: Phaser.AUTO,
|
||||||
parent: 'app',
|
parent: 'silver-fang-mini-game',
|
||||||
// `as as Phaser.Types.Scenes.SettingsConfig[]` is required until https://github.com/photonstorm/phaser/pull/6235
|
// `as as Phaser.Types.Scenes.SettingsConfig[]` is required until https://github.com/photonstorm/phaser/pull/6235
|
||||||
scene: [MainMenuScene] as Phaser.Types.Scenes.SettingsConfig[],
|
scene: [
|
||||||
|
BootScene,
|
||||||
|
PreloaderScene,
|
||||||
|
MainMenuScene,
|
||||||
|
] as Phaser.Types.Scenes.SettingsConfig[],
|
||||||
input: {
|
input: {
|
||||||
keyboard: true
|
keyboard: true
|
||||||
},
|
},
|
||||||
|
@ -20,8 +26,8 @@ const GameConfig: Phaser.Types.Core.GameConfig = {
|
||||||
debug: false
|
debug: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
backgroundColor: '#300000',
|
backgroundColor: '#AAA',
|
||||||
render: { pixelArt: false, antialias: false },
|
render: { pixelArt: false, antialias: true },
|
||||||
scale: {
|
scale: {
|
||||||
mode: Phaser.Scale.FIT,
|
mode: Phaser.Scale.FIT,
|
||||||
autoCenter: Phaser.Scale.CENTER_BOTH,
|
autoCenter: Phaser.Scale.CENTER_BOTH,
|
||||||
|
@ -33,25 +39,8 @@ const GameConfig: Phaser.Types.Core.GameConfig = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class Game extends Phaser.Game {
|
class Game extends Phaser.Game {
|
||||||
//parent: string = ''
|
|
||||||
//phaserGame: Phaser.Game | null = null
|
|
||||||
|
|
||||||
//constructor(parent: string) {
|
|
||||||
// this.parent = parent ?? 'game'
|
|
||||||
//}
|
|
||||||
|
|
||||||
/*start() {
|
|
||||||
this.phaserGame = new Phaser.Game({
|
|
||||||
type: Phaser.AUTO,
|
|
||||||
parent: this.parent,
|
|
||||||
width: 800,
|
|
||||||
height: 600,
|
|
||||||
backgroundColor: 'rgba(80, 80, 80, 0)',
|
|
||||||
scene: [MainMenuScene],
|
|
||||||
})
|
|
||||||
return this.phaserGame
|
|
||||||
}*/
|
|
||||||
constructor(config: Phaser.Types.Core.GameConfig) {
|
constructor(config: Phaser.Types.Core.GameConfig) {
|
||||||
|
|
||||||
super({ ...GameConfig, ...config });
|
super({ ...GameConfig, ...config });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
import Game from "./game-base";
|
import Game from "./game-base";
|
||||||
|
|
||||||
new Game({ parent: 'silver-fang-minigame' });
|
new Game({ parent: 'silver-fang-mini-game' });
|
|
@ -6,6 +6,7 @@ class GameButton {
|
||||||
constructor(scene: Phaser.Scene, x: number, y: number, text: string) {
|
constructor(scene: Phaser.Scene, x: number, y: number, text: string) {
|
||||||
const textObject = new Phaser.GameObjects.Text(scene, x, y, text, {
|
const textObject = new Phaser.GameObjects.Text(scene, x, y, text, {
|
||||||
color: 'black',
|
color: 'black',
|
||||||
|
fontFamily: 'KenneyBold',
|
||||||
})
|
})
|
||||||
|
|
||||||
textObject.setOrigin(.5, .5)
|
textObject.setOrigin(.5, .5)
|
||||||
|
|
94
src/objects/card.ts
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
import * as Phaser from "phaser";
|
||||||
|
|
||||||
|
class Card {
|
||||||
|
scene: Phaser.Scene | null = null;
|
||||||
|
group: Phaser.GameObjects.Group | null = null;
|
||||||
|
sprites = [];
|
||||||
|
isFaceUp: boolean = true;
|
||||||
|
characterName: string | null = null;
|
||||||
|
isFlipping: boolean = false;
|
||||||
|
|
||||||
|
constructor(scene: Phaser.Scene, x: number, y: number, characterName: string) {
|
||||||
|
this.scene = scene;
|
||||||
|
this.characterName = characterName;
|
||||||
|
|
||||||
|
const cardBackground: Phaser.GameObjects.Image = new Phaser.GameObjects.Image(scene, x, y, 'card-bg', 0)
|
||||||
|
const cardShadow: Phaser.GameObjects.Image = new Phaser.GameObjects.Image(scene, x, y, 'card-shadow', 0)
|
||||||
|
const character: Phaser.GameObjects.Image = new Phaser.GameObjects.Image(scene, x, y, 'character-' + characterName + '-card', 0)
|
||||||
|
|
||||||
|
const cardGroup: Phaser.GameObjects.Group = new Phaser.GameObjects.Group(scene)
|
||||||
|
|
||||||
|
cardGroup.add(cardShadow)
|
||||||
|
cardGroup.add(cardBackground)
|
||||||
|
cardGroup.add(character)
|
||||||
|
|
||||||
|
this.group = cardGroup
|
||||||
|
|
||||||
|
character.setInteractive();
|
||||||
|
scene.add.existing(cardShadow)
|
||||||
|
scene.add.existing(cardBackground)
|
||||||
|
scene.add.existing(character)
|
||||||
|
|
||||||
|
scene.add.existing(cardGroup)
|
||||||
|
|
||||||
|
this.sprites.push({ sprite: cardShadow, offsetX: -5, offsetY: -5 })
|
||||||
|
this.sprites.push({ sprite: cardBackground, offsetX: 0, offsetY: 0 })
|
||||||
|
this.sprites.push({ sprite: character, offsetX: 0, offsetY: 0 })
|
||||||
|
}
|
||||||
|
onEvent(eventName: any, fn: any) {
|
||||||
|
const sprite = this.sprites[this.sprites.length - 1].sprite
|
||||||
|
console.log(sprite, eventName, fn)
|
||||||
|
sprite.on(eventName, fn, this.scene)
|
||||||
|
}
|
||||||
|
flip() {
|
||||||
|
if (this.isFlipping) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.isFlipping = true;
|
||||||
|
|
||||||
|
const ease = 'Sine.easeIn'
|
||||||
|
const duration = 100
|
||||||
|
const tween = this.scene?.tweens.add({
|
||||||
|
targets: this.sprites.map(s => s.sprite),
|
||||||
|
props: {
|
||||||
|
scaleX: { value: 0, duration, yoyo: true },
|
||||||
|
},
|
||||||
|
ease,
|
||||||
|
onComplete: () => {
|
||||||
|
this.isFaceUp = !this.isFaceUp;
|
||||||
|
this.isFlipping = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.scene?.tweens.add({
|
||||||
|
targets: this.sprites[2].sprite,
|
||||||
|
props: {
|
||||||
|
texture: { value: this.isFaceUp ? 'card-bg' : 'character-' + this.characterName + '-card', duration: 0, delay: duration },
|
||||||
|
},
|
||||||
|
ease,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
moveTo(x: number, y: number) {
|
||||||
|
this.scene?.tweens.add({
|
||||||
|
targets: this.sprites.filter(s => s.offsetX === 0).map(s => s.sprite),
|
||||||
|
props: {
|
||||||
|
x: { value: x, duration: 1000 },
|
||||||
|
y: { value: y, duration: 1000 }
|
||||||
|
},
|
||||||
|
ease: 'Expo.out'
|
||||||
|
})
|
||||||
|
this.scene?.tweens.add({
|
||||||
|
targets: this.sprites.filter(s => s.offsetX != 0).map(s => s.sprite),
|
||||||
|
props: {
|
||||||
|
x: { value: x - 5, duration: 1000 },
|
||||||
|
y: { value: y + 5, duration: 1000 }
|
||||||
|
},
|
||||||
|
ease: 'Expo.out'
|
||||||
|
})
|
||||||
|
//this.group?.setXY(x, y)
|
||||||
|
}
|
||||||
|
scaleTo(x: number, y: number) {
|
||||||
|
this.group?.children.iterate((child) => child.setScale(x, y))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Card;
|
19
src/scenes/boot.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { Scene } from 'phaser';
|
||||||
|
|
||||||
|
class BootScene extends Scene {
|
||||||
|
constructor() {
|
||||||
|
super('Boot');
|
||||||
|
}
|
||||||
|
|
||||||
|
preload() {
|
||||||
|
// The Boot Scene is typically used to load in any assets you require for your Preloader, such as a game logo or background.
|
||||||
|
// The smaller the file size of the assets, the better, as the Boot Scene itself has no preloader.
|
||||||
|
this.load.image('background01', 'assets/background01.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
create() {
|
||||||
|
this.scene.start('Preloader');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BootScene;
|
|
@ -1,17 +1,54 @@
|
||||||
import * as Phaser from "phaser";
|
import * as Phaser from "phaser";
|
||||||
// import ButtonSprite from "../objects/button-sprite";
|
import Card from "../objects/card";
|
||||||
import GameButton from "../objects/button";
|
import GameButton from "../objects/button";
|
||||||
|
|
||||||
class MainMenuScene extends Phaser.Scene {
|
class MainMenuScene extends Phaser.Scene {
|
||||||
|
constructor() {
|
||||||
|
super('MainMenu')
|
||||||
|
}
|
||||||
|
|
||||||
preload() {
|
preload() {
|
||||||
// this.load.image('button-bg', 'assets/panel-000.png');
|
|
||||||
this.load.spritesheet('button-bg', 'assets/panel-000.png', { frameWidth: 16, frameHeight: 16 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
const button = new GameButton(this, 0, 0, 'A B C D E F G H I J');
|
const gameState = {
|
||||||
|
cards: [],
|
||||||
|
tablePositions: []
|
||||||
|
}
|
||||||
|
|
||||||
button.moveTo(130, 100)
|
const { centerX, centerY, width, height } = this.cameras.main;
|
||||||
|
const bg = this.add.image(centerX, centerY, 'background01');
|
||||||
|
const cardsPerRow = 4;
|
||||||
|
const numCards = cardsPerRow * cardsPerRow;
|
||||||
|
|
||||||
|
const characters = ['akakabuto', 'ben', 'cross', 'gin', 'hyena', 'john', 'madara', 'mosa', 'riki', 'smith', 'sniper']
|
||||||
|
|
||||||
|
for (let x = 0; x < cardsPerRow; x++) {
|
||||||
|
for (let y = 0; y < cardsPerRow; y++) {
|
||||||
|
const char = Math.floor(Math.random() * 100) % characters.length;
|
||||||
|
const card = new Card(this, 80, 80, characters[char]);
|
||||||
|
card.scaleTo(.4, .4)
|
||||||
|
card.flip();
|
||||||
|
card.onEvent('clicked', () => {
|
||||||
|
card.flip()
|
||||||
|
})
|
||||||
|
gameState.cards.push(card);
|
||||||
|
gameState.tablePositions.push({ x: x * 130 + 80, y: y * 130 + 160 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gameState.cards.forEach((card, idx) => {
|
||||||
|
const pos = gameState.tablePositions[idx]
|
||||||
|
card.moveTo(pos.x, pos.y)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.input.on('gameobjectup', function (pointer, gameObject) {
|
||||||
|
gameObject.emit('clicked', gameObject);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
//card.scaleTo(0.5, 0.5)
|
||||||
|
//card.moveTo(400, 150);
|
||||||
|
//card.flip()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
52
src/scenes/preloader.ts
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
import { Scene } from 'phaser';
|
||||||
|
|
||||||
|
export default class PreloaderScene extends Scene {
|
||||||
|
constructor() {
|
||||||
|
super('Preloader');
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
const { centerX, centerY, width, height } = this.cameras.main;
|
||||||
|
// We loaded this image in our Boot Scene, so we can display it here
|
||||||
|
const bg = this.add.image(centerX, centerY, 'background01');
|
||||||
|
bg.scale = 2;
|
||||||
|
// A simple progress bar. This is the outline of the bar.
|
||||||
|
this.add.rectangle(centerX, centerY, 468, 32).setStrokeStyle(2, 0x000000);
|
||||||
|
|
||||||
|
// This is the progress bar itself. It will increase in size from the left based on the % of progress.
|
||||||
|
const bar = this.add.rectangle(centerX - 230, centerY, 4, 28, 0xffffff);
|
||||||
|
|
||||||
|
const text = this.add.text(centerX, centerY, 'LADATAAN...', {
|
||||||
|
color: "black",
|
||||||
|
backgroundColor: "white",
|
||||||
|
stroke: "#AAA",
|
||||||
|
strokeThickness: 4,
|
||||||
|
fontFamily: "Kenney Bold",
|
||||||
|
});
|
||||||
|
text.setOrigin(0.5);
|
||||||
|
|
||||||
|
// Use the 'progress' event emitted by the LoaderPlugin to update the loading bar
|
||||||
|
this.load.on('progress', (progress: number) => {
|
||||||
|
// Update the progress bar (our bar is 464px wide, so 100% = 464px)
|
||||||
|
bar.width = 4 + (460 * progress);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
preload() {
|
||||||
|
this.load.setPath('assets');
|
||||||
|
|
||||||
|
this.load.spritesheet('button-bg', 'panel-000.png', { frameWidth: 16, frameHeight: 16 });
|
||||||
|
this.load.spritesheet('card-bg', 'card-bg.png', { frameWidth: 272, frameHeight: 272 });
|
||||||
|
this.load.spritesheet('card-shadow', 'card-shadow.png', { frameWidth: 272, frameHeight: 272 });
|
||||||
|
|
||||||
|
const characters = ['akakabuto', 'ben', 'cross', 'gin', 'hyena', 'john', 'madara', 'mosa', 'riki', 'smith', 'sniper']
|
||||||
|
|
||||||
|
characters.forEach(character => {
|
||||||
|
this.load.spritesheet('character-' + character + '-card', 'characters/' + character + '_card.png', { frameWidth: 256, frameHeight: 256 });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
create() {
|
||||||
|
this.scene.start('MainMenu');
|
||||||
|
}
|
||||||
|
}
|