linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Multiplayer game
@ 2010-02-23 17:50 iliali16
  2010-02-23 18:11 ` Khalifa Rouis
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: iliali16 @ 2010-02-23 17:50 UTC (permalink / raw)
  To: linux-c-programming


Hi Guys I am currently developing a multiplayer game for my assignment now I
have problem since I am not a good C programmer and I am trying to develop a
game which has to be multiplayer and each player should be able to access a
map and move around on it and be able to see the other players moving as
well. But how would I make them connect to the server since it will be
remote and I can't make use of sockets (these are the requirments).Also how
can I make the movements of each player atomic since I don't want the system
to interupt one of the player and when it allocates the CPU back to it the
other players have already been moved when the first player had to move
before them. Thanks for any ideas since I want to do my proper design then
implement. Thanks 
-- 
View this message in context: http://old.nabble.com/Multiplayer-game-tp27707442p27707442.html
Sent from the linux-c-programming mailing list archive at Nabble.com.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiplayer game
  2010-02-23 17:50 Multiplayer game iliali16
@ 2010-02-23 18:11 ` Khalifa Rouis
  2010-02-23 20:33 ` ern0
  2010-02-23 22:58 ` iliali16
  2 siblings, 0 replies; 4+ messages in thread
From: Khalifa Rouis @ 2010-02-23 18:11 UTC (permalink / raw)
  To: iliali16; +Cc: linux-c-programming

Hi,

This is a taught situation you have here ...

Well, IMHO, you'll need sockets no matter what design/implementation
you think of. So you probably misunderstood the requirements. (they
probably prohibit the use of a certain type of sockets or protocols,
...)
About the atomic movements, one way would be considering critical
sections in your code and using some synchronization algorithms
(dining philosophers problem).

Hope this will help and good luck with your assignment

On 23 February 2010 18:50, iliali16 <iliali16@gmail.com> wrote:
>
> Hi Guys I am currently developing a multiplayer game for my assignment now I
> have problem since I am not a good C programmer and I am trying to develop a
> game which has to be multiplayer and each player should be able to access a
> map and move around on it and be able to see the other players moving as
> well. But how would I make them connect to the server since it will be
> remote and I can't make use of sockets (these are the requirments).Also how
> can I make the movements of each player atomic since I don't want the system
> to interupt one of the player and when it allocates the CPU back to it the
> other players have already been moved when the first player had to move
> before them. Thanks for any ideas since I want to do my proper design then
> implement. Thanks
> --
> View this message in context: http://old.nabble.com/Multiplayer-game-tp27707442p27707442.html
> Sent from the linux-c-programming mailing list archive at Nabble.com.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
Khalifa ROUIS
rouis.khalifa@gmail.com
http://pagesperso.univ-brest.fr/~e20603429/
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiplayer game
  2010-02-23 17:50 Multiplayer game iliali16
  2010-02-23 18:11 ` Khalifa Rouis
@ 2010-02-23 20:33 ` ern0
  2010-02-23 22:58 ` iliali16
  2 siblings, 0 replies; 4+ messages in thread
From: ern0 @ 2010-02-23 20:33 UTC (permalink / raw)
  Cc: linux-c-programming

> since I am not a good C programmer 

1. It's the smallest problem, wheter you're familiar with C programming 
or not.

A multiplayer game has several property, which are hard to implement 
each, and even harder to implement together. They are:
- managing a common scene wich is controlled by asynchronous user events;
- setting up communication infrastructure between a server and at least 
two clients;
- everything must be pretty quick.

2. Sockets: if the game is designed for LAN, socket is OK. But if your 
players are using internet, HTTP is a better choice - you can't sure 
that your players' firewall will enable using UDP, but HTTP is always 
enabled. It has overhead, and a bit harder to implement.

3. Sync

> Also how
> can I make the movements of each player atomic since I don't want the system
> to interupt one of the player and when it allocates the CPU back to it the
> other players have already been moved when the first player had to move
> before them. 

Yep, you're right, you've found it: it's the most important problem of 
the multi-user worlds. The solution is not trivial, but it's not rocket 
science, and I assume there're lot of good documentations on the net in 
this topic.

The problem is, that say, two players are pressing fire button at the 
very same moment, but both of them can see that the other player was 
launching the rocket a bit later than other player. That leads to chaos.

The solution is:
- time sync and
- message queuing.

Time sync: the server and each client (player) as well must have a 
clock, which are syncronized. It will be quite useful, see below.

Message queuing:
- When a player takes any action, it musn't be handled by the client 
immediatelly: the event just has to sent to the server.
- The server receives and queues the events arriving from clients. The 
most important: the server assigns a time stamp for each event. The 
value of the timestamp is some millisecs ahead (it must be enough for 
sending the message back to the client).
- The server sends the appropiate (soon upcoming, useful for the 
receiver client etc.) events to the clients (even ones which are 
generated by the same client, they just get back their events with 
timestamp).
- The client receives events, and performs the appropiate action, but 
not immediatelly, they're firing the action at the moment, which is 
described in the event's timestamp.
- If the time is synced between server and clients, all actions will be 
performed on each client at the very same moment. Because all clients 
are running the same code, and all clients has the same data (position 
of players etc.), every client will do the very same.
- It a client can't perform the event in-time, it must be download the 
actual scene state from the server.

And it's just the top of the iceberg.
-- 
ern0.scene.plus4.amiga.code.muzak
Haben Sie Fragen?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiplayer game
  2010-02-23 17:50 Multiplayer game iliali16
  2010-02-23 18:11 ` Khalifa Rouis
  2010-02-23 20:33 ` ern0
@ 2010-02-23 22:58 ` iliali16
  2 siblings, 0 replies; 4+ messages in thread
From: iliali16 @ 2010-02-23 22:58 UTC (permalink / raw)
  To: linux-c-programming


Well I am sure I cannot use sockets it is stated. It is assumed that the game
is run on a unix/linux server and the users make use of their machines as
terminals so evryone controls his player in the game but can also see the
others beauce all players aim is to reach at some position in the map. who
reaches first wins the control is done by the arrows up/down/left/right. I
think using putty as terminal is the best so people would be able run the
game and if there is an open session of the game before they opened it it
will give them option to join or not so if they join they will be put in a
random free position and they will see the other players aiming at the goal
so they will be able to start playing imigitly. This is the way it should
work. About atomic functionality I was thinking about semaphores. Do you
think that is the way to go about it. I haven't got much time to finish my
design because it is high time start coding since I am not that good at C.
Thanks for all suggestions till now and for any future of these.10x agian

iliali16 wrote:
> 
> Hi Guys I am currently developing a multiplayer game for my assignment now
> I have problem since I am not a good C programmer and I am trying to
> develop a game which has to be multiplayer and each player should be able
> to access a map and move around on it and be able to see the other players
> moving as well. But how would I make them connect to the server since it
> will be remote and I can't make use of sockets (these are the
> requirments).Also how can I make the movements of each player atomic since
> I don't want the system to interupt one of the player and when it
> allocates the CPU back to it the other players have already been moved
> when the first player had to move before them. Thanks for any ideas since
> I want to do my proper design then implement. Thanks 
> 

-- 
View this message in context: http://old.nabble.com/Multiplayer-game-tp27707442p27712027.html
Sent from the linux-c-programming mailing list archive at Nabble.com.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-02-23 22:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-23 17:50 Multiplayer game iliali16
2010-02-23 18:11 ` Khalifa Rouis
2010-02-23 20:33 ` ern0
2010-02-23 22:58 ` iliali16

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).