Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Countdown to game start with Multisync

Author
Message
FireIndy
19
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 23rd Feb 2010 04:44 Edited at: 23rd Feb 2010 04:45
I'm just trying to think through this a little. I'm trying to make a countdown to a match start. I was planning on doing something like this:

1) Host clicks start button, which sends request to server

2) Server gets request, starts countdown and sends first number to client

3) Client gets current number from server, updates its current time, and sends request back to server, go to step 1

Is that sound ok? I mean, having the server do it means a more consistent time than sending one pulse out and the timer running on the client side right?


Want to work on Desolation? Click my sig!!!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Feb 2010 10:54
To make every computer accurate, you need to have one computer count and send it's current time, and every other computer sync to that. In this case, that computer will be the server. You also need to program it, so the server controls the speed of the main loop, so some computers aren't faster than others.

If you get that done, then every client and host can perform their own calculations without sharing much, because the main loops will be running at the same speed everywhere anyway.

TheComet

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 23rd Feb 2010 16:40
You don't actually have to control the loop speed for each computer if you make EVERYTHING reference time. If the speed of an object moving on the screen is set to move per-frame-per-second, then on each computer, no matter how fast the frames go by, each computer will have that object at the same location.
i.e.

As I said in the code, I'm not sure which time/clock command it is(I'm not at my home pc right now). Regardless, this will work for moving objects even you players, if EVERYTHING is governed by that principle. This way the faster computers can get better frame rate and the slower ones will still be able to keep up because everyone is moving through time not frames.

The fastest code is the code never written.
FireIndy
19
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 23rd Feb 2010 22:19 Edited at: 23rd Feb 2010 22:20
So, I really just need to get a count from the server and control the speed of the game loop/everything in the clients. Then I can do client-based timers for the countdown? Because they're all running at the same speed? I was planning to implement timer-based movement, so I guess this would be the time >.<

Edit: I have an article on getting a consistent game speed throughout different computers, so I should be good.


Want to work on Desolation? Click my sig!!!
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 24th Feb 2010 01:44
if i'm interpreting you right, that's not very efficient getting all the computers to go the same speed just for the countdown...

basically what TheComet said, the way I would do it is simply have a timer running on the server, and every time the information is sent from the server include the timer variable. that way, people with 700 fps can have the same fps as people with 30 fps, without relying on any client timers which would be inaccurate.

FireIndy
19
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 24th Feb 2010 04:44
Yeah that's basically what I said in my first post. The server sends the ticks out to the clients. I just wanted to see if this was the most accurate way of doing this.


Want to work on Desolation? Click my sig!!!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 24th Feb 2010 16:01
Your server does need to send update info to each client, but if you use timebetweenframes as a factor for everything that moves on each computer, then everything will be in the same place at the same time on each computer.... Of course, over time it WILL break down; that's why you have to send update info from the server every so often. Once every second is more than enough for objects out of the control of the players such as arrows from archers and fireballs from mages. The player-controled objects, like the characters themselves, need updates more frequently because the player can change direction on-the-fly; so you need to the client to send the server info about the character whenever the action changes and, once again, every so often.

The fastest code is the code never written.
FireIndy
19
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 25th Feb 2010 04:56
Well thanks guys, I got the countdown to work with all clients =] I got a drop in fps for some reason, but I'm going to look that over tomorrow. Probably have some network stuff running when i don't need it to. But thanks for the input


Want to work on Desolation? Click my sig!!!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 25th Feb 2010 15:08
You will have a drop in fps the more info you send over the network. Limit the amount and frequency of transmissions to a bare minimum and you will suffer less.

Make your packets small: Only put those things that need to go in the packet-- You don't have to send the player's name except when the player enters the game (as an example).
Compress your data: Instead of sending a float for small numbers, multiply it by 1000 and put it into a WORD... Then on the other end put the WORD into a float and divide by 1000.0....

There are other things I'm sure you can think of, but the bottom line is MINIMIZE EVERYTHING!!

The fastest code is the code never written.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Feb 2010 17:16
Quote: "You don't have to send the player's name except when the player enters the game (as an example)."


You don't have to send any names at all. Use perform checklist for net players and checklist string$() to retrieve all names of players (will be the same on every computer).

TheComet

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 25th Feb 2010 17:26
Just an example..... There are several things that can be culled from data packs-- if you haven't already.

The fastest code is the code never written.
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 26th Feb 2010 02:29 Edited at: 26th Feb 2010 02:29
hey, just curious, have you gotten it to work over the internet, or just lan?

FireIndy
19
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 26th Feb 2010 02:39 Edited at: 26th Feb 2010 02:52
Over the internet =] I test builds with my partner ever once and awhile, but the last build was successful.


Want to work on Desolation? Click my sig!!!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 26th Feb 2010 04:40
I've never tried to do network over the internet. Is it complicated? What are the differences in the program vs lan?

The fastest code is the code never written.
FireIndy
19
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 26th Feb 2010 04:47 Edited at: 26th Feb 2010 04:48
Well with Multisync things are really nice. They are much more easier to understand that native DB commands. You just have to understand some things about sending information over the internet. Granted, I am nowhere near knowing a lot about it. But, programming this all the time really helps me learn.

The only problem I have encountered is networks using a router. Well, my setup here is all crazy anyway, so its probably my router and modem being dumb. LAN is nice because you dont have to worry about external ips and such when you just can use the internal ip's assigned by the router.

But in developing a multiplayer game, I think it's smart to build it with that capability first alongside the game, not build a singleplayer game first, then add in multiplayer. But enough ranting. It's just hard writing all this logic and code by myself and my friend supplying models and things. It's basically our hobby project to just work on forever.




Want to work on Desolation? Click my sig!!!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 26th Feb 2010 04:52
I've done lan stuff before, but never over the internet. Not in DBP either.... Just VC++/DX

The fastest code is the code never written.
FireIndy
19
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 26th Feb 2010 04:54
Well I enjoy writing in DB actually because its easy to write in and just making a multiplayer game is fun xD It's more of a challenge to see what I can do. And learn new things.


Want to work on Desolation? Click my sig!!!

Login to post a reply

Server time is: 2026-07-27 07:33:30
Your offset time is: 2026-07-27 07:33:30