Skip to content

Commit ae3d581

Browse files
committed
feat(game/mp/slime): support bots
1 parent 7f49e20 commit ae3d581

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

‎docs/pages/game/slime.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Slime Volleyball Multiplayer
33
date: "2017-05-09 22:33:05 -0600"
4-
mdate: 2025-12-30 19:00:00 -0700
4+
mdate: 2025-12-30 20:00:00 -0700
55
entry: app_game_mp_slime
66
---
77
{% import 'game.html' as game %}

‎docs/pages/game/slime_rules.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Slime Volleyball Multiplayer Rules
33
date: "2025-12-27 20:00:00 -0700"
4-
mdate: 2025-12-30 11:00:00 -0700
4+
mdate: 2025-12-30 20:00:00 -0700
55
---
66
{% import 'game.html' as game %}
77
{{ game.tab(page_url, 'slime') }}
@@ -17,8 +17,8 @@ <h1>Future features</h1>
1717
<p>
1818
This project is still under development. These features are planned:
1919
<ul>
20-
<li>Bots
21-
<li>Client-side Prediction (Extrapolation, and possibly interpolation)
20+
<li>Smarter bots
21+
<li>Client-side Prediction (extrapolation)
2222
</ul>
2323
</p>
2424

‎scripts/game/mp/slime/SlimeGame.svelte.ts‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ export class SlimeGame extends RealTimeGame<SlimeClient> {
177177
}
178178

179179
protected override processRoundInfo (m: ByteReader): void {
180-
if (this.roundPlayers.length === 2) {
180+
if (this.roundPlayers.length) {
181181
const flags = m.get()
182-
if (flags & 4) {
182+
if (this.roundPlayers.length > 1 && (flags & 4)) {
183183
[this.roundPlayers[0], this.roundPlayers[1]] = [this.roundPlayers[1], this.roundPlayers[0]]
184184
}
185185
this.status = flags & 3
@@ -231,11 +231,11 @@ export class SlimeGame extends RealTimeGame<SlimeClient> {
231231

232232
protected processRoundWin (p1Won: boolean): void {
233233
(p1Won ? this.p1 : this.p2).score++
234-
this.roundPlayers[p1Won ? 0 : 1].addWin()
235-
this.roundPlayers[p1Won ? 1 : 0].addLoss()
234+
this.roundPlayers[p1Won ? 0 : 1]?.addWin()
235+
this.roundPlayers[p1Won ? 1 : 0]?.addLoss()
236236
this.updatePlayers()
237237

238-
this.status = p1Won !== (this.roundPlayers[1] === this.localClient) ? GameStatus.WIN : GameStatus.LOSS
238+
this.status = p1Won === (this.roundPlayers[0] === this.localClient) ? GameStatus.WIN : GameStatus.LOSS
239239
}
240240

241241
protected processRoundStart0 (_m: ByteReader): void {
@@ -285,7 +285,7 @@ export class SlimeGame extends RealTimeGame<SlimeClient> {
285285

286286
override updateGameState (dt: number): void {
287287
// update network
288-
if (this.room && this.roundPlayers.length === 2 && this.localClient.active) {
288+
if (this.room && this.localClient.active) {
289289
const keyFlags = this.getKeyFlags()
290290
if (this.lastKeySent !== keyFlags) {
291291
this.sendMove(this.lastKeySent = keyFlags)
@@ -417,6 +417,7 @@ export class GameDrawer {
417417
this.drawPing(ctx, W, H, c2.ping, flip)
418418
} else {
419419
this.drawSlimer(ctx, W, H, p2.x + p2.xe, p2.y + p2.ye, c1.colorInv, '<bot>', flip, true)
420+
this.drawPing(ctx, W, H, 0, flip)
420421
}
421422
}
422423

@@ -435,9 +436,7 @@ export class GameDrawer {
435436
} else if (!this.game.localClient.active) {
436437
status = !this.game.status
437438
? 'Spectating'
438-
: `${this.game.status === GameStatus.WIN ? 'Left' : 'Right'} wins the round!`
439-
} else if (this.game.roundPlayers.length < 2) {
440-
status = 'Waiting for opponent'
439+
: `${this.game.status === GameStatus.WIN !== this.game.flipP1 ? 'Left' : 'Right'} wins the round!`
441440
} else if (this.game.status === GameStatus.WIN) {
442441
status = 'You won the round!'
443442
} else if (this.game.status === GameStatus.LOSS) {

0 commit comments

Comments
 (0)