GPWiki.org
GPWiki.org
It is currently Sat May 25, 2013 10:57 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Jan 25, 2010 9:49 pm 
Hi everyone :yeah ;

I am writing a 2d multiplayer football game. There are two clients in the game. I send the clients information of which keys to press. For Example; VbKeyLeft,VbKeyUp etc. (I dont use server. Because, this method is very slow.Firstly i tried this method. I sent all the information to server and simulated the game. after i sent the coordinates to the clients. I gave up this method. )

My problem is that one of the clients works 50 fps and the other works 75 fps. Therefore, in the first computer the footballer moves 50*footballer_speed per second, in the second computer the footballer moves 75*footballer_speed per second.

I fix the fps to 50. But this doesnt work, because fps sometimes drops to 30~40 then up to 50 again. And at this moment, one of the footballers remains behind the other.

How can i solve this synchronisation problem between two players?

I hope i could tell my problem. :rolleyes please help me.

PS: I use winsock.ocx, vb6, directx7, bltfast.

Thanks


Top
  
 
 Post subject:
PostPosted: Mon Jan 25, 2010 10:08 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
You need to use time-based updates, not frame rate-based.

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 26, 2010 12:34 am 
Octogenarian

Joined: Mon Oct 25, 2004 11:21 pm
Posts: 89
Here is a tutiorial on how to do time based modeling in VB

http://www.rookscape.com/vbgaming/tutAQ.php


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 26, 2010 9:12 pm 
I tried this method.
Dim mlngTimer as Long
Dim mlngElapsed as Long
Dim mlngFrameTimer as Long
Dim mintFPSCounter as Integer
Dim mintFPS as Integer

Private Sub Timer()

mlngElapsed = GetTickCount() - mlngTimer
mlngTimer = GetTickCount()
If GetTickCount() - mlngFrameTimer >= 1000 Then
mlngFrameTimer = GetTickCount()
mintFPS = mintFPSCounter
mintFPSCounter = 0
Else
mintFPSCounter = mintFPSCounter + 1
End If

End Sub

msngMarioX = msngMarioX + mlngElapsed * msngMarioSpeed


but it didnt work. the players on two clients moved difrently.

can you give me a multiplayer game link with a source code which is written with this method.

thanks.


Top
  
 
 Post subject:
PostPosted: Tue Jan 26, 2010 9:14 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
famsoft wrote:
can you give me a multiplayer game link with a source code which is written with this method.

I doubt anyone is just going to give you the source for a complete game. Try doing some research.

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 27, 2010 7:15 am 
I didnt say complete game. I want to only example. For example, two shape may be the only move in clients.


Top
  
 
 Post subject:
PostPosted: Wed Jan 27, 2010 3:36 pm 
Funky Monkey

Joined: Mon Aug 16, 2004 2:48 pm
Posts: 1604
Location: Minneapolis, MN USA
With a multi-player realtime game, you either need one of the player's machines to be considered the "server" (or you need an actual central server that all players connect to).

This server machine will be the master copy of all values about where the important in-game objects are located, how they are moving, etc.

So, while you may have some immediate client-side calculations/estimations going on in order to make the game feel more smooth and responsive, you will want the server to provide the information to all clients on all of the object locations.

You might want to try some of the multiplayer code examples from Almar's site: http://www.persistentrealities.com/vbarchive

-Bryk

_________________
www.mwgames.com ... Dicey Curves, Space Mission, Jump Gate, Gem Raider, DareBase, Castle Danger, Keeps & Moats Chess


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group