Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8954381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:18:23+00:00 2026-06-15T14:18:23+00:00

I am writing a javascript web game that has a 3 x 3 viewport

  • 0

I am writing a javascript web game that has a 3 x 3 viewport similar to the one Urban Dead uses. The “world map” is stored as a 100 x 100 2D array server-side (nodejs), each pair of coordinate defines a “room”. So, the 3 x 3 viewport shows the name and content of 9 of the rooms.

User’s location are stored server-side as coordinates. E.g. Bob = { x : 2, y : 3 }. So Bob’s x-coordinate is Bob.x. The client (browser) can retrieve this and work out the coordinates of the other 8 rooms, and asks the server for the content of those rooms. These are then displayed in the viewport. This is suppose to look like the viewport in Urban Dead (top left corner).

Question

How should I think about making the viewport “refresh” or update? I am thinking of doing it this way…

1) When the player moves from coordinates (2,3) to (1,3). The client asks the server about the content of the 9 rooms again and re-draw/display everything.

2) When the content of one of the room changes, the server (nodejs) runs a client-side function that tells it to ask the server for the content of the 9 rooms and re-draw/display everything.

Being new to programming, I wonder if this implementation would be too naive or inefficient?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:18:25+00:00Added an answer on June 15, 2026 at 2:18 pm

    The former option would be the best imo, purely for the reason that as your map expands it will be easier for you to set-up trigger regions that cause your client to load specific areas of the map. You could even only load the rooms that they can see or have access to.

    This would also be of benefit, for example, if you were to have multiple characters. Imagine you have your main character in one location, and a secondary character elsewhere. It would be far better for client to know where they are and to understand what each character can see and only request this information from the server. This is a much more expandable solution than having the server just constant broadcast all room information to whoever is listening.

    With regards to changes in room content, this could be flagged as an event from the server to all clients – but based purely on room co-ordinates and minimal data. If this event covers one of the rooms the client can currently see, a request by that client for the room information can occur. So in part this involves something of your option two, but shouldn’t broadcast much.

    As an analogy, this is more akin to having clients/users requesting only the resources they want from a website at the time they want them and possibily signing up to mail alerts about content that’s interesting to them. Rather than having the user sign-up to an RSS feed and being notified when anything changes on the site. The former is more optimal and can be controlled in specific ways, the latter is better if your user is interested in overviewing the whole content of the site (which is not the case usually in games — unless you’re designing bots that have to cheat).

    Overall, after talking it through implementing part of both approaches would be useful. But if it’s a choice the first one will give you more control.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a small JavaScript program that makes web calls to pull up weather
We're writing a web app that relies on Javascript/jQuery. It involves users filling out
Has anyone had any experience writing a web control (in either ASP.net, or javascript/HTML/CSS),
So I'm writing a Javascript library that takes x,y coordinates and uses them to
I'm writing a web-based game that involves clicking links on various sites on the
It seems that experienced web developers frown upon using document.write() in JavaScript when writing
I am writing a web application that has a static outer shell and a
I'm writing a web application platform that serves JavaScript applications to a browser. Needless
I am very new to Web development, and have been writing some javascript that
A web app I am writing in JavaScript using node.js. I use Foreman, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.