Browse all series

Real Time Games With Laravel

I want to build a game. No, I'm not talking about some intricate RPG; just a nice simple game of Tic-Tac-Toe. But my version of the game will be online, with real-time moves, using websockets, Reverb and Echo. Why don't you come along with me as we put all these pieces together to craft the ultimate version of noughts and crosses!

Progress

Series Info

Episodes
7
Run Time
1h 23m
Difficulty
Intermediate
Last Updated
Aug 13, 2024
Version
Latest

Series Episodes

  1. Matchmaking (2)
    1. Basic Matchmaking

      Let's get our game off the ground with some simple setup. We'll need models, migrations and controllers that will allow players to create and join games they want to play.
    2. Joining a Game

      Now that we can create games, we should display those games and allow other players to join them from the dashboard. Seen as we're making use of Reverb, why don't we also make the game index remove games as they're joined in real-time?
  2. Building the Game Board (2)
    1. Board Basics

      We can't play tic-tac-toe without a board! Let's now turn our attention to the frontend and start building it out in Vue. We'll need to consider how to track the current state of the game, how to switch between the two players and how to display game state in a nice grid.
    2. Calculating Victory

      So, we can fill out a board with noughts and crosses, but victory is still calculated manually - not so great when you're aiming for an interactive online game. We can solve this with a bit of basic maths and a few for loops, so let's put that in place to take our game to the next level.
  3. Adding a Second Player (3)
    1. Player 2 Has Joined the Game

      While two players can currently join a game, there's no indication that it has actually happened. Let's get comfortable with the PresenceChannel, which Laravel provides to solve exactly this use-case.
    2. Let's Take Turns

      Let the games begin! It's time to put all the pieces together in order to allow 2 players to truly play a game together. We'll make use of Events, Reverb, Echo, Websockets, Queues and Databases to make this dream a reality. No biggie.
    3. Quiet as a Whisper

      Whilst it is super cool to have real-time turn-by-turn tic-tac-toe working, it is a little long-winded at the moment. As such, there is a measurable delay between a player making a move and the opponent seeing it on their screen. Whispers to the rescue!

Continue Learning