-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
67 lines (61 loc) · 1.62 KB
/
main.js
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
import bridge from '@vkontakte/vk-bridge'
import Phaser from 'phaser'
import { GameOverScene } from './game/scenes/gameOverScene'
import { PreloadGameScene } from './game/scenes/gamePreloadScene'
import { GameScene } from './game/scenes/gameScene'
import { GameUIScene } from './game/scenes/gameUIScene'
import { MenuScene } from './game/scenes/menuScene'
import { ShopScene } from './game/scenes/shopScene'
window.seed = [...Array(5)].map(() => Math.floor(Math.random() * 16).toString(16)).join('')
async function getVkInfo() {
const vkUser = await bridge.send('VKWebAppGetUserInfo')
// setVkUser(vkUser)
return vkUser
// bridge
// .send('VKWebAppStorageGet', {
// keys: ['address'],
// })
// .then((data) => {
// if (data.keys) {
// console.log('walletAddress successfully restored')
// setUser({ ...user, walletAddress: data.keys[0].value.toString() })
// }
// })
// .catch((error) => {
// // Ошибка
// console.log('walletAddress unsuccessfully unrestored')
// })
}
bridge.send('VKWebAppInit')
var config = {
type: Phaser.AUTO,
parent: 'phaser',
dom: {
createContainer: true,
},
width: 800,
height: 600,
physics: {
default: 'arcade',
arcade: {
// debug: true,
// gravity: { y: 800 },
},
},
max: {
width: 1920,
height: 1080,
},
scale: {
mode: Phaser.Scale.ScaleModes.AUTO,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
pixelArt: true, //remove
scene: [MenuScene, PreloadGameScene, GameScene, GameUIScene, ShopScene, GameOverScene],
}
var game = new Phaser.Game(config)
console.log('game', game)
getVkInfo().then((v) => {
console.log('vk', v)
game.registry.set('vkData', v)
})