Welcome to OGeek Q&A 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...