Skip to content

Multiplayer, real-time, and cross platform racing game powered by PubNub

Notifications You must be signed in to change notification settings

chandler767/Space-Race

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Space Race

Multiplayer racing game powered by PubNub.

Multiplayer Gaming Revenue 2016

Playing a game alone is not nearly as fun as playing with your friends and that's one reason why massively multiplayer online games (MMOs) are a huge revenue stream that continues to grow rapidly every year. In June 2018 consumers spent an estimated $9.1 billion digitally across all platforms [on MMOs], compared to $7.9 billion last June.

The design of online games can range from simple text-based environments to incredibly complex virtual worlds. A few other examples of popular online multiplayer games types include first-person shooters (FPS), real-time strategy games (RTS), and multiplayer online battle arena games (MOBA).

This project is intended to show how PubNub can be used to create a real-time multiplayer game. PubNub is perfect for powering multiplayer games because it makes it easier to build a fast and scalable multiplayer game. In this game PubNub is used to manage the players in the game lobby and to transmit game data. The game is built in Go using the PubNub Go SDK and is cross platform. You can learn more about how this game was built from the blog post.

PubNub usage in Space Race

Getting Started

Quick Start

The fastest way to get started is to download and run the appropriate binary for your OS. You don't need to install Go or any dependencies to run the game. See the 'How To Play' section below to get racing.

Space Race Demo

Building From Source

  • Want to learn more about this project or build a clone from scratch? Check out the blog post.
PubNub Blog PubNub Signup
  1. Install the latest version of Go and setup your $GOPATH.

  2. Download the dependencies.

go get github.com/pubnub/go
go get github.com/gosuri/uiprogress
go get github.com/nsf/termbox-go
  1. Clone the Repo.
git clone https://github.com/chandler767/Space-Race
  1. Get your unique PubNub keys from the PubNub Developer Portal. If you don't have a PubNub account, you can sign up for a PubNub account for free.

  2. Enable the channel presence feature for your keys. Presence can be enabled per key in your account dashboard.

  3. Open main.go and replace "pub-key" and "sub-key" with your keys.

  4. Build and run the game.

make run

OR

make build
./space-race

Space Race Game

How To Play

  1. The first player to enter a lobby becomes the host. The second player to enter becomes the guest.

  2. Both players need to enter the same lobby name.

  3. When both players have joined a lobby the game will start after a 3 second delay (get your fingers ready).

  4. After the game starts, alternate pressing SPACE and the RIGHT ARROW KEY to advance your progress bar.

  5. The first player to 100% wins the game.

  6. You can leave the game while playing by pressing ESC. If you leave the game then the other player wins automatically.

Space Race Game

Limitations

  • If the terminal window is too small, or if the font is too big, the progress bars won't render correctly. Make the window bigger and then press command+k to refresh.

  • The lobby is kept simple by design so it can be used as a seed project. The lobby may not always be able to start a game in some edge cases. If you have problems starting a game try restarting the game for both players and use a new lobby name.

Have suggestions or questions about this project? Reach out at [email protected].