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()
|
||||
}
|
||||
|
||||
console.log("Show end screen with data:", data)
|
||||
|
||||
this.add.image(250, 550, 'phaser-logo').setScale(0.5)
|
||||
this.add.image(550, 550, 'hs3-logo').setScale(0.5)
|
||||
|
||||
this.add.text(
|
||||
this.cameras.main.centerX,
|
||||
this.cameras.main.centerY - 100,
|
||||
110,
|
||||
"KONIEC GRY", {
|
||||
font: '64px Verdana',
|
||||
}).setOrigin(0.5, 0.5)
|
||||
|
||||
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("Poziom: " + lvl)
|
||||
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,
|
||||
{
|
||||
font: '32px Verdana',
|
||||
|
|
@ -53,5 +55,19 @@ export default class PlayScene extends Phaser.Scene {
|
|||
}).setOrigin(0.5, 0.5)
|
||||
|
||||
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[] = []
|
||||
backgroundId = 0
|
||||
startTimestamp: number = 0
|
||||
gameOverState = false
|
||||
|
||||
constructor() {
|
||||
super('play-scene')
|
||||
|
|
@ -60,8 +61,10 @@ export default class PlayScene extends Phaser.Scene {
|
|||
}
|
||||
|
||||
gameOver() {
|
||||
if (this.gameOverState) return
|
||||
|
||||
console.log("%cU ded", "color:red")
|
||||
console.log("points: ", this.difficulty!.getPoints())
|
||||
this.gameOverState = true
|
||||
this.scene.start('game-over-scene', {
|
||||
points: this.difficulty!.getPoints(),
|
||||
level: this.difficulty!.getLevel(),
|
||||
|
|
|
|||
|
|
@ -17,22 +17,31 @@ export default class StartScene extends Phaser.Scene {
|
|||
|
||||
this.add.text(
|
||||
this.cameras.main.centerX,
|
||||
this.cameras.main.centerY - 100,
|
||||
"SPACE SMASHER 9001!", {
|
||||
130,
|
||||
"SPACE SMASHER\n9001!", {
|
||||
font: '64px Verdana',
|
||||
align: "center"
|
||||
}).setOrigin(0.5, 0.5)
|
||||
|
||||
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",
|
||||
"albo graj jako gość (bez rankingu)"
|
||||
"Możesz też zagrać jako gość (bez rankingu)."
|
||||
], {
|
||||
font: '21px Verdana',
|
||||
align: 'center',
|
||||
color: 'cyan'
|
||||
}).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', () => {
|
||||
window.freezeGui()
|
||||
this.scene.start('play-scene');
|
||||
|
|
|
|||
|
|
@ -48,6 +48,19 @@ class Database {
|
|||
.sort((a, b) => a.record > b.record ? -1 : 1)
|
||||
.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
|
||||
|
|
|
|||
|
|
@ -78,9 +78,13 @@ app.post("/login", neededArguments(['key']), async (req, res) => {
|
|||
|
||||
app.post("/record", protect, neededArguments(['points', 'shoots', 'time']), jg, async (req, res) => {
|
||||
db.updateRecord(req.user.name, req.body.points)
|
||||
const rank = db.getRank(req.user.name)
|
||||
|
||||
console.log(req.user, rank)
|
||||
|
||||
res.json({
|
||||
status: "ok"
|
||||
status: "ok",
|
||||
rank: rank
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue