Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

javascript - How to handle players movement and animations in 2d canvas MMORPG?

I'm working currently on 2d MMORPG in canvas. I introduced many features and finally test performance. I'm a little bit worried, because it doesn't look so good to be called mmo. It's tile based game with tile size 32x32. Actually server sending data over socket.io to players every 40ms. When player run to animate him server is modifying his coordinates by 2px in interval till the coordinates reach next tile coords. It's one of thing which has big performance impact. What's the other possibility to animate running player smoothly without interval?

I tried to only send information to client that his character is moving and calculate animation on client side, but it was even worse. I know about window.requestAnimationFrame, but i don't know how to use it in this case. How to synchronize client and server?

I think the player animation should be separated from player coordinates and only after move by a tile coords should be compared between client and server.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...