Drawing Tiles & Player speed

Hi people,

I have two questions:

1- I’m trying to develop a game like Tibia, and I need some example how to implement the movement effect that we have in Tibia, where the player is always in the center of the map and the map moves, may some one help me? Some details: each player has a speed, and the game is online, the server confirms the movement and send the next parts of the map…

2- What is the best way to draw the images of the map? I don’t have an sprite sheet, but each image (32x32) is loaded separately… Currently I’m drawing like this:

graphics.drawImage(obj.getGfx()[frame], this.x, this.y, 0, 0, 32, 32, 32 * scale, 32 * scale);

(I’m using Slick2D) Is it the best way?

Thanks!

First of all, you don’t know how to render stuff and you’re making online game? Just don’t do that…

To move the map, render everything at certain offset, which could be something like -player.x, - player.y;

Hehe yes, but I did, the player can walk a tile in the server and client, but without the movement effect, I need to know how to calculate the offset in each frame, any way, thanks for reply…

Hi. Let me take a look at those questions…

Okay, for keeping players in the center of the map at all times, you have to offset the map no questions asked. However, I think you are asking a deeper question.

How do you keep the character in the center of the map when dealing with a server?

The short answer is, you have to make an educated guess. There are many things that can go wrong when the server is communicating with the client. Frame rate drops, packet drops, and disconnects can all cause the client to get behavior that is not intended.

The way that you control guessing the movement of the client is through “client interpolation”. Basically, you always trust that the server has the right information. If packets end up dropping along the way, you just “lie” to the client until you get updated information and “jump” to the server values. Depending on the amount of packets sent, the interpolation will not be visible. Worst case, is that you’ll see a lag jump to the server position.

A little research goes a long way here, but here is a topic that slightly deals with it…
Server Game Loop and Synchronization

[quote]2- What is the best way to draw the images of the map? I don’t have an sprite sheet, but each image (32x32) is loaded separately… Currently I’m drawing like this:

graphics.drawImage(obj.getGfx()[frame], this.x, this.y, 0, 0, 32, 32, 32 * scale, 32 * scale);

[/quote]
The best way to draw images using Slick? Well, just use the tools that are created for you in Slick2D. It totally depends on the game and the tools you need for your images, like if transparency is important to you or not. The current implementation looks fine.

[quote](I’m using Slick2D) Is it the best way?
[/quote]
Slick2D is sufficient. If you are comfortable with it then I suggest to just keep using it.

Final Thoughts

How you draw images or what library you use has nothing to do with how well you’ll synchronize the server information. Libraries and Images are client side problems, and the interpolation is a server side issue. The best thing you can do is to research how to perform server interpolation. No matter what library you use, server problems are always the same.