Networking
For my multiplayer Blackjack game, I built a lobby system in Godot that lets players either host or join a game over the network using a peer-to-peer model . Using Godot’s ENetMultiplayerPeer, the server handles player connections, keeps track of each player’s name and score, and synchronizes this information across all clients. When the game begins, the script loads the Blackjack scene for everyone at the same time, ensuring a smooth multiplayer experience. Remote Procedure Calls (RPCs) handle all the communication, making sure player info and game events stay perfectly in sync. This networking system is handled independently of the Blackjack logic, making it reusable for other multiplayer games.
Blackjack
The Blackjack script handles player setup, turn order, card dealing, and scoring. Each player (including the dealer) gets a hand represented as an array of card objects, and turns are tracked to know whose move it is. The deck is initialized as a standard 52-card set, shuffled, and synchronized across all players using remote procedure calls (RPCs), so everyone sees the same cards. When a player hits, the server deals a card and checks for busts. The dealer automatically plays according to Blackjack rules, drawing until reaching 17. At the end of each round, the script calculates scores, updates results (win, lose, or tie), and shows a “Play Again” option.
Challenges
One challenge I faced was figuring out how to send cards over the network. Godot doesn’t allow Node or object instances to be transmitted directly because they contain engine-specific state and references that can’t be serialized. To solve this, I converted each card’s information into a string format, sent that across the network, and then instantiated the corresponding card objects locally on each client. This approach ensured that all players saw the same cards while keeping the networking system reliable and consistent.
Gameplay