DEV Community

Cover image for Building a realtime multiplayer browser game in less than a day - Part 4/4

Building a realtime multiplayer browser game in less than a day - Part 4/4

Srushtika Neelakantam on June 12, 2020

Hello, and welcome to the final part of this article series where we are looking at the step-by-step implementation of a realtime multiplayer game ...
Collapse
 
vmx profile image
Mohsen Tabatabaie

ive got error while trying to run the server - at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
at Module._load (node:internal/modules/cjs/loader:1074:27)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1339:12)
at require (node:internal/modules/helpers:126:16)
at Object. (C:\Users\mosit\Desktop\multiplayer live game\public\server.js:1:19)
at Module._compile (node:internal/modules/cjs/loader:1546:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
at Module.load (node:internal/modules/cjs/loader:1317:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\Users\mosit\Desktop\multiplayer live game\public\server.js'
]

Collapse
 
vmx profile image
Mohsen Tabatabaie

(C:\Users\mosit\Desktop\multiplayer live game\public*server.js:1:19)*

Collapse
 
vmx profile image
Mohsen Tabatabaie

where is dotenv ?

Collapse
 
arttukuikka profile image
Arttu Kuikka

Hello i am getting this error(imgur.com/a/jLGwZwg even thought i have added the ably key

Collapse
 
srushtika profile image
Srushtika Neelakantam

Hi, it's expecting an authUrl, not a direct API key. If you'd like to use the API key directly instead to authenticate (which is not recommended btw for the frontend clients) - you'll need to replace the key authUrl with key in the init method. Here's an example: ably.com/documentation/core-featur....

If you are still facing issues, please feel free to open a support ticket at ably.com/contact and the team can help out.

Collapse
 
awesomepants profile image
Awesomepants • Edited

Hi!
I'm a little confused on how to do this step: "Hit the base URL of your server from all the three windows."
How do I find the url of the local file? (Thanks in advance!)
Edit: I figured this out, and I'll leave this here for reference, in case anyone else doesn't know how to do this. (I am relatively new to web development)
It's fairly simple. You just need to open your browser and type in localhost:5000 (make sure your server is running first!)
For some reason I thought I had to input the file path.

Collapse
 
brickfoe profile image
BrickFoe

Can I add my own assets/animations to make the game more unique?

Collapse
 
srushtika profile image
Srushtika Neelakantam

Yes, of course! Just replace the ones in the project. Do you have any specific questions on that?

Collapse
 
brickfoe profile image
BrickFoe

You use cdn links for the assets. Can i just add my own png images all willy nilly or do i have to do something else

Thread Thread
 
srushtika profile image
Srushtika Neelakantam

Replacing the links should do it!

Collapse
 
anibalardid profile image
Anibal

Hi ! Amazing !! Do you have a demo url ?

Collapse
 
srushtika profile image
Srushtika Neelakantam

Hey! I've temporarily hosted the demo at go.ably.io/play-space :)

Collapse
 
mdx77 profile image
Nicolas

Hello, thanks for sharing your work. I have a server hosting all the files. How can I code to have server.js run?

Collapse
 
alankritjoshi profile image
Alankrit Joshi

This is great. I was working on building a mutliplayer game with Phaser and my Go server. I will have to figure out an alternative for P2.js or patch it in somehow.

Collapse
 
angel17 profile image
Angel Superstore

I enjoy reading your post. This is so informative! ornamental iron works

Collapse
 
vmx profile image
Mohsen Tabatabaie

very bad instruction
what you mean by " go to ably dashbord and add this code to script.js !!! "