Feedback rank in game
This commit is contained in:
parent
4497d0fb44
commit
15cf78bf74
5 changed files with 57 additions and 12 deletions
|
|
@ -26,25 +26,27 @@ export default class PlayScene extends Phaser.Scene {
|
||||||
await window.updateTopList()
|
await window.updateTopList()
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Show end screen with data:", data)
|
|
||||||
|
|
||||||
this.add.image(250, 550, 'phaser-logo').setScale(0.5)
|
this.add.image(250, 550, 'phaser-logo').setScale(0.5)
|
||||||
this.add.image(550, 550, 'hs3-logo').setScale(0.5)
|
this.add.image(550, 550, 'hs3-logo').setScale(0.5)
|
||||||
|
|
||||||
this.add.text(
|
this.add.text(
|
||||||
this.cameras.main.centerX,
|
this.cameras.main.centerX,
|
||||||
this.cameras.main.centerY - 100,
|
110,
|
||||||
"KONIEC GRY", {
|
"KONIEC GRY", {
|
||||||
font: '64px Verdana',
|
font: '64px Verdana',
|
||||||
}).setOrigin(0.5, 0.5)
|
}).setOrigin(0.5, 0.5)
|
||||||
|
|
||||||
const lines: string[] = []
|
const lines: string[] = []
|
||||||
if (rank) { lines.push("Miejsce w rankingu: #" + rank) }
|
if (rank) {
|
||||||
|
lines.push("Aktualne miejsce w rankingu:")
|
||||||
|
lines.push("#" + rank)
|
||||||
|
lines.push("")
|
||||||
|
}
|
||||||
lines.push("Punkty: " + pts)
|
lines.push("Punkty: " + pts)
|
||||||
lines.push("Poziom: " + lvl)
|
lines.push("Poziom: " + lvl)
|
||||||
lines.push("Czas Gry: " + time + 's')
|
lines.push("Czas Gry: " + time + 's')
|
||||||
|
|
||||||
this.add.text(this.cameras.main.centerX, this.cameras.main.centerY,
|
this.add.text(this.cameras.main.centerX, 290,
|
||||||
lines,
|
lines,
|
||||||
{
|
{
|
||||||
font: '32px Verdana',
|
font: '32px Verdana',
|
||||||
|
|
@ -53,5 +55,19 @@ export default class PlayScene extends Phaser.Scene {
|
||||||
}).setOrigin(0.5, 0.5)
|
}).setOrigin(0.5, 0.5)
|
||||||
|
|
||||||
window.unfreezeGui()
|
window.unfreezeGui()
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.add.text(this.cameras.main.centerX, 450,
|
||||||
|
"Kliknij aby zacząć od nowa",
|
||||||
|
{
|
||||||
|
font: '32px Verdana',
|
||||||
|
align: 'center',
|
||||||
|
color: 'yellow'
|
||||||
|
}).setOrigin(0.5, 0.5)
|
||||||
|
|
||||||
|
this.input.on('pointerup', () => {
|
||||||
|
this.scene.start('start-scene');
|
||||||
|
});
|
||||||
|
}, 5000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ export default class PlayScene extends Phaser.Scene {
|
||||||
backgroundOrder: number[] = []
|
backgroundOrder: number[] = []
|
||||||
backgroundId = 0
|
backgroundId = 0
|
||||||
startTimestamp: number = 0
|
startTimestamp: number = 0
|
||||||
|
gameOverState = false
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('play-scene')
|
super('play-scene')
|
||||||
|
|
@ -60,8 +61,10 @@ export default class PlayScene extends Phaser.Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
gameOver() {
|
gameOver() {
|
||||||
|
if (this.gameOverState) return
|
||||||
|
|
||||||
console.log("%cU ded", "color:red")
|
console.log("%cU ded", "color:red")
|
||||||
console.log("points: ", this.difficulty!.getPoints())
|
this.gameOverState = true
|
||||||
this.scene.start('game-over-scene', {
|
this.scene.start('game-over-scene', {
|
||||||
points: this.difficulty!.getPoints(),
|
points: this.difficulty!.getPoints(),
|
||||||
level: this.difficulty!.getLevel(),
|
level: this.difficulty!.getLevel(),
|
||||||
|
|
|
||||||
|
|
@ -17,22 +17,31 @@ export default class StartScene extends Phaser.Scene {
|
||||||
|
|
||||||
this.add.text(
|
this.add.text(
|
||||||
this.cameras.main.centerX,
|
this.cameras.main.centerX,
|
||||||
this.cameras.main.centerY - 100,
|
130,
|
||||||
"SPACE SMASHER 9001!", {
|
"SPACE SMASHER\n9001!", {
|
||||||
font: '64px Verdana',
|
font: '64px Verdana',
|
||||||
|
align: "center"
|
||||||
}).setOrigin(0.5, 0.5)
|
}).setOrigin(0.5, 0.5)
|
||||||
|
|
||||||
this.add.text(this.cameras.main.centerX, this.cameras.main.centerY, [
|
this.add.text(this.cameras.main.centerX, this.cameras.main.centerY, [
|
||||||
"Naciśnij przycisk aby zacząć",
|
"Zaloguj się przed rozpoczęciem gry",
|
||||||
|
"za pomocą panelu na górze, aby zdobywać rekord.",
|
||||||
"",
|
"",
|
||||||
"Zaloguj się przed rozpoczęciem gry, aby zachować rekord",
|
"Możesz też zagrać jako gość (bez rankingu)."
|
||||||
"albo graj jako gość (bez rankingu)"
|
|
||||||
], {
|
], {
|
||||||
font: '21px Verdana',
|
font: '21px Verdana',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
color: 'cyan'
|
color: 'cyan'
|
||||||
}).setOrigin(0.5, 0.5)
|
}).setOrigin(0.5, 0.5)
|
||||||
|
|
||||||
|
this.add.text(this.cameras.main.centerX, 450,
|
||||||
|
"Kliknij aby zacząć grę",
|
||||||
|
{
|
||||||
|
font: '32px Verdana',
|
||||||
|
align: 'center',
|
||||||
|
color: 'yellow'
|
||||||
|
}).setOrigin(0.5, 0.5)
|
||||||
|
|
||||||
this.input.on('pointerup', () => {
|
this.input.on('pointerup', () => {
|
||||||
window.freezeGui()
|
window.freezeGui()
|
||||||
this.scene.start('play-scene');
|
this.scene.start('play-scene');
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,19 @@ class Database {
|
||||||
.sort((a, b) => a.record > b.record ? -1 : 1)
|
.sort((a, b) => a.record > b.record ? -1 : 1)
|
||||||
.slice(0, amount)
|
.slice(0, amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRank(username) {
|
||||||
|
const users = this.db.data.users
|
||||||
|
.filter(user => user.record)
|
||||||
|
.sort((a, b) => a.record > b.record ? -1 : 1)
|
||||||
|
|
||||||
|
for (let i = 0; i < users.length; ++i) {
|
||||||
|
if (users[i].name == username)
|
||||||
|
return i + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Database
|
export default new Database
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,13 @@ app.post("/login", neededArguments(['key']), async (req, res) => {
|
||||||
|
|
||||||
app.post("/record", protect, neededArguments(['points', 'shoots', 'time']), jg, async (req, res) => {
|
app.post("/record", protect, neededArguments(['points', 'shoots', 'time']), jg, async (req, res) => {
|
||||||
db.updateRecord(req.user.name, req.body.points)
|
db.updateRecord(req.user.name, req.body.points)
|
||||||
|
const rank = db.getRank(req.user.name)
|
||||||
|
|
||||||
|
console.log(req.user, rank)
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
status: "ok"
|
status: "ok",
|
||||||
|
rank: rank
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue