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 9175223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:52:40+00:00 2026-06-17T16:52:40+00:00

I am developing a multiplayer game in PHP using Canvas and MySQL database. Two

  • 0

I am developing a multiplayer game in PHP using Canvas and MySQL database.
Two players join the game and they first get opponent’s position(X,Y and Angle).

When they’re ready, game starts. Game Algorthim goes like this.
Every 50 millisec

  1. Calculate their own position (X,Y)
  2. Get opponent’s angle(AJAX) and calculate opponents pos (X2, Y2)
  3. Then draw on Canvas and update database.

    context.fillStyle = "green";
    context.fillRect(p1.x,p1.y, 5,5);
    addPoints(p1.x,p1.y);
    updateRoundJQ(p1.x,p1.y,p1.a);
    
    context.fillStyle = "red";
    context.fillRect(x2,y2, 5,5);
    addPoints(x2,y2);
    
    loopTimer = setTimeout('drawLine()', 50);
    

But unfortunately I get this result. There’s a great delay in receiving the data. Could anyone please help me how to get rid of this great error? It would be really thankful.

Player 1’s screen
Player 1 in one computer

Player 2’s screen
Player 2

  • 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-17T16:52:42+00:00Added an answer on June 17, 2026 at 4:52 pm

    Your script isn’t running every 50ms – as it is only setting the timeout once all the other functions have run. Depending on how updateRound works, this could add the time of a round trip to each interval.

    For example, consider the following timings:

    context.fillStyle = "green"; // 1ms
    context.fillRect(p1.x,p1.y, 5,5); // 1ms
    addPoints(p1.x,p1.y); // 1ms
    updateRoundJQ(p1.x,p1.y,p1.a); // web request? 300ms
    
    context.fillStyle = "red"; // 1ms
    context.fillRect(x2,y2, 5,5); // 1ms
    addPoints(x2,y2); // 1ms
    
    loopTimer = setTimeout('drawLine()', 50); // wait 50ms from now
    

    So, with these example timings, your loop will only run after ~306ms.

    It may be worth considering pushing the data to your client using websockets, rather than pulling it with AJAX.

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

Sidebar

Related Questions

Ok, so I am developing a multiplayer game using: Node.js, Sockets.io & Redis Anyway
I am developing a simple fast-paced 2 dimensional real-time multiplayer game in Flash. Players
I am developing a multiplayer game with more than 2 players. I would like
we are developing a database backend for a multiplayer game. The server is written
we are developing a database backend for a multiplayer game. The server is written
Since I'm developing a multiplayer card game for Facebook using Flex as client side
We're developing a silverlight multiplayer game using TCP connections. We have all of our
I am looking at developing my first multiplayer RTS game and I'm naturally going
I'm having the following problem: i'm developing a multiplayer game using GameKit. I'm testing
I'm developing a 3d (first/third person) game and I'm trying to make it multiplayer

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.