Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (756)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Drawing Tiles & Player speed  (Read 1578 times)
0 Members and 1 Guest are viewing this topic.
Offline osmarjunior

Junior Newbie





« Posted 2014-02-17 19:14:01 »

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:
1  
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!
Offline trollwarrior1
« Reply #1 - Posted 2014-02-17 19:31:37 »

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;
Offline osmarjunior

Junior Newbie





« Reply #2 - Posted 2014-02-17 20:11:07 »

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..
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #3 - Posted 2014-02-17 20:51:52 »

Hi. Let me take a look at those 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...

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:
1  
graphics.drawImage(obj.getGfx()[frame], this.x, this.y, 0, 0, 32, 32, 32 * scale, 32 * scale);

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?

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.

Pages: [1]
  ignore  |  Print  
 
 

 
DesertCoockie (52 views)
2018-05-13 18:23:11

nelsongames (83 views)
2018-04-24 18:15:36

nelsongames (74 views)
2018-04-24 18:14:32

ivj94 (759 views)
2018-03-24 14:47:39

ivj94 (87 views)
2018-03-24 14:46:31

ivj94 (643 views)
2018-03-24 14:43:53

Solater (102 views)
2018-03-17 05:04:08

nelsongames (184 views)
2018-03-05 17:56:34

Gornova (426 views)
2018-03-02 22:15:33

buddyBro (1086 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!