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

  • Home
  • SEARCH
  • 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 8009717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:31:36+00:00 2026-06-04T18:31:36+00:00

I am building a website/app using node.js, express and nowjs. Once user log into

  • 0

I am building a website/app using node.js, express and nowjs. Once user log into my website, they can move a sprite around using the arrow keys (in addition to other services). The position of the i-th user’s sprite is kept server side.

user[i] = { x : 0; y : 0 } 

Arrow keypresses are sent to the server to update the sprite position.

E.g. user[5].x += 5.

I do not want two users to share the same position (“collision”). So, when the server receive a keypress, a server-side function checks if the resulting coordinates is equal to some coordinates in the “user” array, and ignore the move if it does.

Question: How do I handle the case when two users choose to move onto the coordinates at exactly the same time? If I understand correctly, the server-side function will be called at the same time, and both users will end up on the same coordinates because at the time of checking, no one has that sets of coordinates yet?

Or, am I safe because if 2 clients call a server-side function (e.g. using nowjs) at the same time, one function will be processed after another always?

  • 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-04T18:31:38+00:00Added an answer on June 4, 2026 at 6:31 pm

    The javascript code in node.js is executed on a single thread so you should be safe. If you were using an asynchronous library to calculate collisions on a separate thread, you would be at risk, but it doesn’t sound like that’s going on.

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

Sidebar

Related Questions

I'm building a website where I hook people up so that they can anonymously
I am building a website using App Engine and weird thing just happened. There
I'm building a flash game website using Google App Engine. I'm going to put
I am building a website in Eclipse Helios using Google App Engine and want
I'm building my new website using app-engine with python and webapp2 I'm having hard
I am building a news app for my website. I want to use a
I'm building a website that will require user registration and logon. I would like
I'm building a website with text box containing log messages. the log is getting
I am building a website that is loaded into a frameset by other sites
i'm currently building a small music quiz running node.js 0.4.12 and the express framework

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.