# Fish Game - An open reference game using Nakama for multiplayer

**URL:** https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279
**Category:** Game Design
**Created:** [January 14, 2021, 10:16am UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279 "2021-01-14T10:16:59Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/erlend_sh/32/335_2.png) [@erlend\_sh](https://forum.heroiclabs.com/u/erlend_sh)
#### Post date: [January 14, 2021, 10:16am UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/1 "2021-01-14T10:16:59Z")

</div>

Fish Game is an open game development project, sponsored by [Heroic Labs](https://heroiclabs.com/).

 ![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/1X/95e65799fa74fbc0f095549cfd070de2e20a3a47.png)

We are making this game because:

- **Nakama users** need better from-scratch examples of how to build multiplayer games with Nakama in the stack.

- **Nakama developers** need [dogfooding](https://en.wikipedia.org/wiki/Eating_your_own_dog_food) projects that are easy to sustain long-term.

- **Indie game developers** need more in-depth tutorials and reference implementations of networked multiplayer games.

- **The open game development ecosystem** needs standardized language & models for talking about network design.

## A “RealWorld” example for multiplayer games

In web development there’s a hugely popular ‘glue layer’ project called [RealWorld](https://github.com/gothinkster/realworld).

> See how _the exact same_ [Medium.com](http://Medium.com) clone (called [Conduit](https://demo.realworld.io)) is built using any of our supported [frontends](https://github.com/gothinkster/realworld#frontends) and [backends](https://github.com/gothinkster/realworld#backends). Yes, you can mix and match them, because **they all adhere to the same [API spec](https://github.com/gothinkster/realworld/blob/master/spec)** 😮😎
> 
> While most “todo” demos provide an excellent cursory glance at a framework’s capabilities, they typically don’t convey the knowledge & perspective required to actually build _real_ applications with it.
> 
> RealWorld solves this by allowing you to choose any frontend (React, Angular 2, & more) and any backend (Node, Django, & more) and see how they power a real world, beautifully designed fullstack app called “[Conduit](https://demo.realworld.io)”.
> 
> _Read the [full blog post announcing RealWorld on Medium.](https://medium.com/@ericsimons/introducing-realworld-6016654d36b5)_

So this is effectively what we’re setting out to do, in our own small way. Certainly we’re gonna have to go about it a bit differently because web app architecture doesn’t map 1:1 to games, but the fundamental concepts are largely the same. Games, just like web apps, can draw a pretty clear line between _backend_ and _frontend_.

Our minimal approach here is to start by making the same game in two different toolsets. There won’t be a strict API spec to follow yet; the two implementations will merely follow an identical [Fish Game - Game Design Document](https://www.notion.so/Fish-Game-1647ed74217e4e38a59bd28f4f5bc81a).

## Godot and Macroquad (Rust) as first examples

For our two initial game examples, one will be made in the [Godot Engine](https://godotengine.org/) and the other in [Rust-lang](https://www.rust-lang.org/) with [macroquad](https://github.com/not-fl3/macroquad). Both will use Nakama for their social multiplayer infrastructure ( i.e. authentication, matchmaking & leaderboards) as well as real-time multiplayer.

**Godot** is the most popular game engine among indie and open source game developers. It’s also very high level (if desired), letting users make games with its own GDscript.

**Rust** [for gamedev](https://arewegameyet.rs/) on the other hand is a fast-growing new trend. It’s pretty much as low-level as any gamedev gets (without the foot-guns 😻 ). The language has an official [Working Group dedicated to gamedev](https://www.rust-lang.org/governance/wgs/gamedev).

Both games will be full-stack implementations of loosely coupled back- and front-ends for the Fish Game concept.

> 💡 While it is entirely feasible to make a game with a _Rust backend_ and _Godot frontend_, we won’t be attempting that for now. Check out [godot-rust](https://github.com/godot-rust/godot-rust) for excellent guidance and examples on that front.

## The 🐟 Game(s)

What we are making is an open remake of the excellent [Duck Game](https://store.steampowered.com/app/312530/Duck_Game/).

> Blast your friends with Shotguns, Net Guns, Mind Control Rays, Saxophones, Magnet Guns, and much, much more. This is ~~DUCK~~ FISH GAME. Don’t blink.

#### Key Features

- 2 to 4 players in either Local Multiplayer or Online Play
- Easy to pick up, emphasizing strategy over twitch reaction
- Customize characters with hats, saved to your cross-platform profile (later)
- Create & explore user-made levels (later)

#### Why a remake of Duck Game

Duck Game is an excellent game. It deserves the 10/10 rating it can boast on Steam. But it is also a bit stuck in an older tech stack. A combination of tech debt and lacking cross-platform infrastructure makes it very PC-centric. It’s been ported to other platforms, albeit with a more limited experience (e.g. no online map sharing on consoles).

It is also a perfectly moddable game, enabling players to make and share custom maps, weapons and, most importantly, hats! 👒 This level of moddability lends itself exceptionally well to open source practices. Hence our belief that we can _level up_ what Duck Game currently is.

There’s ample opportunity for collaboration here: Fish Game should not be perceived as a threat, but rather as a tribute to Duck Game. We are not looking to co-opt the game; we wanna help make it better.

# Play & Inspect!

The games are currently at varying stages of development. None of them have yet incorporated our awesome art pack by [Pixel Frog](https://twitter.com/_PixelFrog). We’ll post more updates as we near completion in the coming weeks.

Please feel free to reply here with any first impressions or questions you may have.

### Godot version

> **[GitHub - heroiclabs/fishgame-godot: "Fish Game" for Godot is a 2-4 player online...](https://github.com/heroiclabs/fishgame-godot/)**
>
> "Fish Game" for Godot is a 2-4 player online multiplayer game created as a demo of Nakama; an open-source scalable game server, using the Godot game engine.

### Rust Version

> **[GitHub - heroiclabs/fishgame-macroquad: "Fish Game" for Macroquad is an online multiplayer...](https://github.com/heroiclabs/fishgame-macroquad/)**
>
> "Fish Game" for Macroquad is an online multiplayer game, created as a demonstration of Nakama, an open-source scalable game server, using Rust-lang and the Macroquad game engine.

### Unity Version

> **[GitHub - heroiclabs/fishgame-unity: "Fish Game" for Unity is a 2-4 player online...](https://github.com/heroiclabs/fishgame-unity/)**
>
> "Fish Game" for Unity is a 2-4 player online multiplayer game created as a demo of Nakama; an open-source scalable game server, using the Unity game engine.

---

<div class="post-metadata">

### Author: ![az00](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/az00/32/328_2.png) [@az00](https://forum.heroiclabs.com/u/az00)
#### Post date: [January 15, 2021, 6:45am UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/2 "2021-01-15T06:45:16Z")

</div>

Thanks! Adding multiplayer and social functions to my Godot game is one of my top priorities for the couple of month. But I’m hesitating to start with Nakama lacking tutorials and examples.  
This project is also not easy to pick up because the game is already rather complex and there are no comments in code or help for usage of Nakama functions. Created [an issue](https://github.com/heroiclabs/fishgame-godot/issues/1) for these questions.  
Hope this project will help a lot of Godot users to start making MP games.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/erlend_sh/32/335_2.png) [@erlend\_sh](https://forum.heroiclabs.com/u/erlend_sh)
#### Post date: [January 15, 2021, 11:14am UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/3 "2021-01-15T11:14:20Z")

</div>

Thanks for checking it out! I’ve replied on GitHub 🙂

---

<div class="post-metadata">

### Author: ![nolan](https://avatars.discourse-cdn.com/v4/letter/n/aeb1de/32.png) [@nolan](https://forum.heroiclabs.com/u/nolan)
#### Post date: [January 17, 2021, 9:33pm UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/4 "2021-01-17T21:33:22Z")

</div>

Chatted with you about this a bit on Discord, but following up here so maybe others can benefit. Here’s something I don’t get and would like clarity on.

Say I build my game in something like Bevy. I create my components, code up a number of systems to capture my game logic, etc.

I then want to make it networked. Obviously there’s more to making a network game than flipping a switch and deciding it’s networked, but never mind. 🙂 How do I achieve that with Nakama?

Unless I’m missing something, the way forward is to implement custom server code in Go/Lua. But does that mean I’m deconstructing my nice C#, Rust, etc. code into a series of Lua command handlers, and re-implementing my game logic in Lua or Go? Not that either are bad languages, I’m just not getting what the networking systems provide me. The authentication/matchmaking/leaderboard systems make sense, and maybe there’s some way to bridge these to existing server processes via GRPC calls so an existing server process in Rust might be told that connection ID X from IP Y is guaranteed to belong to account Z. But I don’t understand how a game like this is meant to work without essentially implementing significant game logic in more than one language.

Put more simply, I see what I assume is the Nakama client API in this example. Where is the server-side functionality? Is there a pile of missing Lua functions, or did I miss a page in the docs?

---

<div class="post-metadata">

### Author: ![Fedor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/fedor/32/468_2.png) [@Fedor](https://forum.heroiclabs.com/u/Fedor)
#### Post date: [January 18, 2021, 4:01pm UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/5 "2021-01-18T16:01:40Z")

</div>

In fishgame we are trying to avoid any server side logic and use relayed multiplayer instead.

Check fishgame-macroquad as a reference, especially this: [fishgame-macroquad/net\_syncronizer.rs at master · heroiclabs/fishgame-macroquad · GitHub](https://github.com/heroiclabs/fishgame-macroquad/blob/master/src/net_syncronizer.rs), its pretty much all the networking code involved in rust’s fishgame now.

---

<div class="post-metadata">

### Author: ![nolan](https://avatars.discourse-cdn.com/v4/letter/n/aeb1de/32.png) [@nolan](https://forum.heroiclabs.com/u/nolan)
#### Post date: [January 18, 2021, 5:25pm UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/6 "2021-01-18T17:25:42Z")

</div>

Hmm, there seems to be a lower-level networking API in wasm.rs for  
sending/receiving data. Is this what’s being used on Nakama’s end, and  
if so, is it documented anywhere? The readme mentions a networking API  
that isn’t supported on PC yet, but I’m not clear where this API is  
documented or which specific one it is, given that there isn’t mention  
of any platform restrictions in the docs I’ve read so far.

But assuming you did want an authoritative server, how would you bridge  
your game logic to Nakama without reimplementing significant portions in  
Lua/Go? I.e. say instead of a pingpong game as featured on  
[Authoritative Multiplayer - Nakama server](https://heroiclabs.com/docs/gameplay-multiplayer-server-multiplayer/), I  
wanted to take client messages and process them with existing Rust logic  
and return something to be processed by the clients. What would be the  
recommended pattern for handing that data into my non Go/Lua server, if  
in fact there is a way? Or should I be looking at a different subsystem?  
Maybe the Rust game server implements some sort of GRPC handler for  
consuming messages from the server, and the client Lua command handlers  
call those custom APIs in my server?

Sorry, I know that isn’t in scope for this specific project. But I’ve  
been wondering that for a while, and expected to find an answer in this  
project. I think that at least saying something like “Look into X and Y,  
documented at Z” would put folks on the right track.

Thanks!

---

<div class="post-metadata">

### Author: ![Fedor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/fedor/32/468_2.png) [@Fedor](https://forum.heroiclabs.com/u/Fedor)
#### Post date: [January 18, 2021, 5:58pm UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/7 "2021-01-18T17:58:27Z")

</div>

The nakama crate is heavily work in progress and is only (very)partially implemented for wasm at the moment.  
We do not use any authoritative multiplayer - fishgame use relayed multiplayer instead.

I do not have any advices for rust authoritative server. Right now server modules may be implemented only in Go, Lua or ([as of 3.0](https://heroiclabs.com/blog/announcements/nakama-3-0/)) TypeScript, and I do not know about any plans on general C API for server modules or rust modules support.

---

<div class="post-metadata">

### Author: ![attackgoat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/attackgoat/32/513_2.png) [@attackgoat](https://forum.heroiclabs.com/u/attackgoat)
#### Post date: [February 10, 2021, 5:28pm UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/8 "2021-02-10T17:28:40Z")

</div>

@nolan You might be interested in [this fork](https://github.com/attackgoat/nakama-fork/blob/c-module/include/nakama.h) where I’m adding C-language module support.

My plans are to enable C/C++/Rust **server-side** logic, using [this crate](https://crates.io/crates/nakama) to provide a “Rusty” API. This should get to the merge-review stage soon.

---

<div class="post-metadata">

### Author: ![nolan](https://avatars.discourse-cdn.com/v4/letter/n/aeb1de/32.png) [@nolan](https://forum.heroiclabs.com/u/nolan)
#### Post date: [February 10, 2021, 5:52pm UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/9 "2021-02-10T17:52:49Z")

</div>

Interesting. I’m mildly concerned about your nakama crate. Is it only  
for server-side logic, as indicated in its description? What about  
client-side code wanting to update a leaderboard? Hoping it’s just a  
matter of a quickly-written description.

Thanks for the pointers, I’ll be watching both repos.

---

<div class="post-metadata">

### Author: ![attackgoat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/attackgoat/32/513_2.png) [@attackgoat](https://forum.heroiclabs.com/u/attackgoat)
#### Post date: [February 11, 2021, 1:28am UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/10 "2021-02-11T01:28:10Z")

</div>

Hmm… Good point! That description needs to be tweaked. The stuff I mentioned will help writing a server, and the other stuff in this thread helps write a client.

Joining these two separate efforts is on-going work.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/erlend_sh/32/335_2.png) [@erlend\_sh](https://forum.heroiclabs.com/u/erlend_sh)
#### Post date: [April 7, 2021, 3:18pm UTC](https://forum.heroiclabs.com/t/fish-game-an-open-reference-game-using-nakama-for-multiplayer/1279/11 "2021-04-07T15:18:14Z")

</div>

The Unity version of Fish Game and its accompanying tutorial is now out! 👇

> [@Nakama in Unity - A 16-part video tutorial featuring Fish Game](https://forum.heroiclabs.com/t/nakama-in-unity-a-16-part-video-tutorial-featuring-fish-game/1539):
>
> [https://www.youtube.com/playlist?list=PLOAExZcDNj9tut2gSUlw46OKK4iB--uW1](https://www.youtube.com/playlist?list=PLOAExZcDNj9tut2gSUlw46OKK4iB--uW1) We’re thrilled to announce our newest YouTube tutorial series “Nakama In Unity,” which walks you through building an open-source game called Fish Game in Unity with Nakama. Full playlist: [https://www.youtube.com/playlist?list=PLOAExZcDNj9tut2gSUlw46OKK4iB--uW1](https://www.youtube.com/playlist?list=PLOAExZcDNj9tut2gSUlw46OKK4iB--uW1) Online demo: [https://fishgame-unity.codewithtom.com/](https://fishgame-unity.codewithtom.com/) Source code: [https://github.com/heroiclabs/fishgame-unity/](https://github.com/heroiclabs/fishgame-unity/) We collaborated with the wonderful Tom Glenn of [c…](https://codewithtom.com/)
