Jump to content

  • Log In with Google      Sign In   
  • Create Account


A 2D online game design


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 PHMitrious   Members   -  Reputation: 127

Like
0Likes
Like

Posted 24 September 2012 - 07:25 PM

Well, I will try to make this question simple, if I don't make myself clear, please tell me and I shall edit this post.

I'm putting together a team and we are working on a online game, a sort of 2D RPG/ACTION thing, not too sophisticated at first, but we do have experience with doing this kind of stuff on offline gaming, so I'm familiar with AI, collision detection etc of a 2D game.

Well, I've been researching and reading on networking and client/server design, but have some questions on what's been on my mind (I've been discussing this with the rest of the guys as well) and I'd like some opinions on some stuff:

Maps: Well I'll have a graphical representation of this part of the game on the game client and all, but on the server I will only need a "physical" representation of this, right? Like I will only have to store what is relevant to collision detection, interaction, event activation and what not. And you guys think I should also keep the basic physical info on the client too, for example for avoiding that the player runs through a wall because of a delay on the packet delivery? What are your thoughts on these two maps representations server and client? (I already have a working graphical map engine, still needing some work, but working nonetheless)

Players: I will have to give info on the appearance of the player to the client and all so it can load everything, but that's not where I have more doubts. On the client side I'm thinking about the same kinda thing as for the map, just a physical representation of the player, where it is and all, and sending via packets it's moving vectors, it's actions codes and the results of actions, like damage just received and all, stuff like that, but I would really love some opinions on the design for the server side representation of the player. For the client side I will have the graphical representation and the animations stored, which shall be activated through the codes that come in the packets.

Well I think monsters and npcs design would come from What I have from the player, even tho for now I'd like to get a map with a player working before I advance on doing stuff. So I think that's my question for now, but anything you want to comment/ask is welcome.

Sponsor:

#2 TheDespite   Members   -  Reputation: 104

Like
0Likes
Like

Posted 24 September 2012 - 11:51 PM

Highly depends on the game.

If it is going to be a very competitive game (PvP), then you need to write a really strict server that holds collision and stuff like that (while ofc also calculating collision on client).
However if it is a bit more loose, then I suggest to not even bother creating collision for the server or you could do some really rough restricted areas (kick player, teleport player)

Edited by TheDespite, 24 September 2012 - 11:59 PM.


#3 Khatharr   Crossbones+   -  Reputation: 2819

Like
0Likes
Like

Posted 25 September 2012 - 06:27 AM

In my experience the simplest and most secure method is to have the server manage any 'important' state (anything that the player could potentially alter on their local machine in order to cheat). The client simply serves as a representation of the state communicated by the server and as a means of sending requests to act (please move me left, please swing my sword, etc) upon that state.

In other words, for each 'tick' of game time, the server processes or rejects any action requests received during that 'tick' from the players and updates the game state accordingly, then sends update packages to the players so that the clients can correctly represent the state.

In it's rudest form you could be sending out the full state of the client's current map each 'tick', but it's better to cut down on traffic by considering what the client actually needs in order to draw the scene, etc. As TheDespite mentioned, it really depends on your game, and some tinkering is certainly advised once it's up and running to help determine how much information the client should cache (if any) or how often it should request new data, have new data pushed to it, etc.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#4 hplus0603   Moderators   -  Reputation: 4960

Like
2Likes
Like

Posted 25 September 2012 - 11:32 AM

In a typical game, you load the same data on client and server sides, but you "stub out" the graphics-related subsystems on the server, so they don't actually load/keep the graphics data in memory, and the server doesn't actually spend time rendering. A good way of stubbing is to use dependency injection. In C++, this is done through pure abstract base classes; in Java, it's done through interfaces; etc.

I think you absolutely want to have the "physics" data on the clients, too, so that you can give proper UI cues when the client tries to give commands that would walk through a wall or whatever.

If the server generates "secret" data (like the hand of cards in poker) then that should not be sent to the clients until they are supposed to see the data. This may include things like the actual presence of randomly-spawned mobs, for example. However, the location of spawn points and percent chance of spawning ("map data") that may only be useful on the server, can be loaded on the client without ill effect, if it makes the data format and code simpler. It'll just do nothing on the client.

enum Bool { True, False, FileNotFound };

#5 PHMitrious   Members   -  Reputation: 127

Like
0Likes
Like

Posted 25 September 2012 - 04:09 PM

In a typical game, you load the same data on client and server sides, but you "stub out" the graphics-related subsystems on the server, so they don't actually load/keep the graphics data in memory, and the server doesn't actually spend time rendering. A good way of stubbing is to use dependency injection. In C++, this is done through pure abstract base classes; in Java, it's done through interfaces; etc.

I think you absolutely want to have the "physics" data on the clients, too, so that you can give proper UI cues when the client tries to give commands that would walk through a wall or whatever.

If the server generates "secret" data (like the hand of cards in poker) then that should not be sent to the clients until they are supposed to see the data. This may include things like the actual presence of randomly-spawned mobs, for example. However, the location of spawn points and percent chance of spawning ("map data") that may only be useful on the server, can be loaded on the client without ill effect, if it makes the data format and code simpler. It'll just do nothing on the client.


Before anything thanks to the three of you, I'm just quoting the most "complete" answer.
Well, I've trying to do something like what you said, for example I'm designing my maps in a way I will be able to ignore the graphics related part completely when I'm loading it on the server, and you guys pretty much helped with some stuff I was dubious about. And about the info about spawning stuff and all I'm designing it in a way that I won't have to worry about it on the client side, I will just have to worry about a monster when it's actually there, not before it.

#6 Eric Wu   Members   -  Reputation: 122

Like
1Likes
Like

Posted 25 September 2012 - 09:04 PM

For Map: Both Server side and client side should have the basic map info such as map size, camp and where can go or not. But server will not calculate how to find the path from A node to B node. Server side just checks if player can go directly from one node to another, if so player can go, if not the player is cheating. Client has to calculate the path and sends the path to server, like player want to move from A node to B node, client calculate the path is A->D->C->B, server side just checks every adjacent node can go directly without any block, but server side has to check the speed and time to avoid speed gear. About the dynamic object with which player can interact, such as flower which player can collect and make drugs as material, client does not have to load dynamic object, server side is responsible for notifying about adding/deleting.

For Player: The client has to receive the action commands including the player self and other players and executes them. Also client has to do some game logic to let the game to be more nature. Such as server side send two commands to client 1) playerB move from A node to C node. 2) player B at C node attack you with using magic skill 11. The reason why client receives these two command so close is because the bad networking sometimes. Client should have let playerB move faster then normal from A to C, then attack. You can see some actions more faster than before if the network is not so good.
About player move, client can move first, then if server denies, player will be pulled back. but about player skill, client cannot fire the skill until server confirms it. That's why we cannot use skill but can move in bad network situation. Before player use a skill, player has to do some actions like raise the ax, it is a good way in the period client waiting server confirm.

For NPC: very same as Player except the AI part. Server side has to use A star to find the NPC move path sometimes, most of the time the NPC move as the designed path back and forth.

#7 KnolanCross   Members   -  Reputation: 1163

Like
1Likes
Like

Posted 29 September 2012 - 03:23 PM

I have coded a multi client arena game (to college) and a client server project (hobby), it had a game basis, but i just wanted to make a very fast client-server network appplication.

In my experience, you should actully check on both sides things like colisions, there are two reasons for that:
1) Naturality: if the client try to move into a wall and has to wait for the server to tell him that he may not move there and the notification take sometime to come, it will feel really unnatural. As has being said many times, prevention is better than cure.
2) Performance: if the client detects that a movement is illegal, you can avoid sending a message to the server which is always good for performance.

Another important thing I learned the hard way: let the character move/act on the client as soon as the player press the button. If you try to command the character by packets sent by the server you will have unnatural movement.

Edited by KnolanCross, 29 September 2012 - 03:25 PM.

My blog on programming and games.
http://16bitsflag.blogspot.com.br/




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS