Skip to content

Commit 4f253d3

Browse files
committed
multiplayer character synchronised
1 parent 392e76d commit 4f253d3

16 files changed

Lines changed: 736 additions & 32 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ The goal was simple yet audacious: **build a complete, enjoyable multiplayer gam
1818

1919
<div align="center">
2020

21-
### Initial Character selection idea
22-
![Latest 0.0.21](/www/images/Character-selection-birds-rain-puddle.png)
23-
*Initial charcter selection design idea also featuring birds, rain and puddles system*
21+
### Multi Character selection
22+
![Latest 0.0.25](screenshots/multi-character-selection.png)
23+
*New multi character selection with multiplayer synchronisation*
2424

2525
</div>
2626

docs/SCREENSHOTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ SOme screenshots are older the idea is to start adding them based on their versi
22

33
<div align="center">
44

5+
### Multi Character selection
6+
![Latest 0.0.25](../screenshots/multi-character-selection.png)
7+
*New multi character selection with multiplayer synchronisation*
8+
59
### Initial Character selection idea
610
![Latest 0.0.21](../www/images/Character-selection-birds-rain-puddle.png)
711
*Initial charcter selection design idea allowing player to select different characters*
353 KB
Loading

specs/TEST_CHARACTER_SYNC.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Character Sprite Synchronization Test
2+
3+
## What Was Fixed
4+
5+
1. **PlayerConfig Persistence**: Character selection is now saved to PlayerConfig (woodlanders.json) so it persists across game sessions
6+
2. **Initial Connection**: When a new player joins, they now receive PlayerJoinMessages for all existing players with their correct character sprites
7+
3. **Character Updates**: When a player changes their character and saves, the update is broadcast to all other players
8+
4. **Remote Player Updates**: RemotePlayers are now properly updated (disposed and recreated) when character sprites change
9+
5. **World State Sync**: After sending world state, server sends individual character sprite updates for all existing players
10+
11+
## Test Scenarios
12+
13+
### Scenario 1: Both Players Join Fresh
14+
1. Player A selects "girl_walnut_start.png" in character selection
15+
2. Player A starts/joins server
16+
3. Player B selects "boy_green_start.png" in character selection
17+
4. Player B joins server
18+
5. **Expected**: Player A sees Player B as green boy, Player B sees Player A as walnut girl
19+
20+
### Scenario 2: Player Joins Existing Game
21+
1. Player A (walnut girl) is already in game
22+
2. Player B (green boy) joins
23+
3. **Expected**: Both players see each other with correct sprites
24+
25+
### Scenario 3: Player Changes Character Mid-Game
26+
1. Both players in game
27+
2. Player A opens menu → Player Profile → Choose Character
28+
3. Player A selects "girl_red_start.png"
29+
4. Player A clicks "Save Player"
30+
5. **Expected**:
31+
- Player A sees their own sprite change to red girl
32+
- Player B sees Player A change to red girl
33+
34+
## Debug Output to Look For
35+
36+
When testing, check console for these messages:
37+
38+
**On Client Connect:**
39+
```
40+
[CLIENT] My selected character sprite: girl_walnut_start.png
41+
[CLIENT] Sent player info to server: Player_abc123, sprite: girl_walnut_start.png
42+
```
43+
44+
**On Server:**
45+
```
46+
[SERVER] Updated character sprite for abc123: girl_walnut_start.png
47+
[SERVER] Broadcasting character update to other clients: girl_walnut_start.png
48+
[SERVER] Sending character sprite to new client: Player_xyz789 -> boy_green_start.png
49+
```
50+
51+
**On Other Clients:**
52+
```
53+
[CLIENT] Creating new remote player: Player_abc123 with sprite: girl_walnut_start.png
54+
[CLIENT] Updating character sprite for Player_abc123 to girl_walnut_start.png
55+
```
56+
57+
## Troubleshooting
58+
59+
If sprites still show as navy:
60+
61+
1. **Check PlayerConfig**: Make sure character selection is being saved
62+
- Look for `woodlanders.json` in config directory
63+
- Should contain: `"selectedCharacter": "girl_walnut_start.png"`
64+
65+
2. **Check Console Output**: Look for the debug messages above
66+
- If you don't see "[CLIENT] My selected character sprite:", the character isn't being loaded from config
67+
- If you don't see "[SERVER] Updated character sprite:", the server isn't receiving the message
68+
69+
3. **Check Sprite Files**: Verify the sprite files exist:
70+
- `assets/sprites/player/girl_walnut_start.png`
71+
- `assets/sprites/player/boy_green_start.png`
72+
- etc.
73+
74+
4. **Timing Issue**: If sprites are wrong initially but correct after character change:
75+
- This is expected - the initial world state uses defaults
76+
- The PlayerInfoMessage updates should arrive within 1 second
77+
- If they don't, there may be a network delay issue

0 commit comments

Comments
 (0)