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 / Multiplayer - Client/Server

Author
Message
SamVickery
14
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 21st Nov 2011 17:38
Hey Guys

I have the movement of the game working well I am now working on the multiplayer aspect of the game

I have downloaded the multisync plug in and its working well.

I was wandering it may sound stupid but I want the person hosting the game(server) to also act as a client for the game.

So basically I want the person to host a game and then to join his own game, this is because I dont have a server that I can host this on.

Is there anyway I can get around not having to use another computer to host the game if you want to play.

Sorry if this doesnt make any sense

I have never done any networking in my programming before

Thanks Sam Vickery
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st Nov 2011 20:05
Well you do have the possibility of making a separate program, which is shell executed by the client. This way you have a server and a client running on the same computer, and the client is able to join the server with the IP 127.0.0.1

TheComet

Jambo B
16
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 21st Nov 2011 20:08
I accomplished this with DarkNET. I highly recommend it - might be worth a look?
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 22nd Nov 2011 02:32
Oo This is a funny post... as I am about to ask people on the forums if they. want to test their multiplayer capabilities by linking onto my server... I will also be hosting the demo DN server so users of the client can hop on and see it working from outside of their local network...

But yeah get Dark Net... it is amazing...

SamVickery
14
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 24th Nov 2011 15:27
Thanks for the help guys

For now I will stick with opening the .exe of the server

I have a problem though

If I run the server manually it works but im trying to open the server from the normal client .exe if they want to host the game

The problem is that it doesnt open the server file

EXECUTE FILE "Server.exe", "", "./"

That is what I am using to open the server

Any help would be great with this


Thanks Sam
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Nov 2011 21:31 Edited at: 24th Nov 2011 21:33
Isn't it execute file "Server.exe","","../"?

TheComet

SamVickery
14
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 24th Nov 2011 22:27
Right I have got it to work from typing in the location like this

GLOBAL ServerLocation$ = "C:\Users\sam\Documents\Nebula Wars\Server"

EXECUTE FILE "Server.exe", "", ServerLocation$

This works but I cant get it to load a .exe from the same folder which is odd

At the moment I have the server in another folder to the game although I have copied in the .exe of the server code to the same folder.

I dont really waant to have to have to specify the location of the game otherwise I will have to read from a txt file that the user can change when they want to play the game.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 24th Nov 2011 22:54
I thought... (btw not by my pc to test this). that it was simply

ECECUTE "Server.exe"

As its in the same folder...

SamVickery
14
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 25th Nov 2011 11:06
I tried that but it didnt work

I would also think that it would be simple to load a file in the same folder

If anyone knows how to do this please let me know

Thanks

Sam
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 25th Nov 2011 11:58
You could try to find the current folder location... I think STYX has this functionality... and then apply it to a string$ and place the string in the folder section of execute... I will check this later this after noon... will set a reminder now... I am sure I did this once when playing around with something... it will be useful for me so... fingers crossed

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 25th Nov 2011 15:01 Edited at: 25th Nov 2011 15:16
Urm this is confusing... if I double posted sorry... its not easy with moderation users...

Anyway I HAVE DONE IT!!!



Now you can also use commands I think also from STYX inside your server console/application to make it start silent or minimi(s/z)ed (darn it... pick one and carry on reading ) I found this to be the best way rather than using the commandline as I am struggling to find a proper command for it...
and then again... you can always try



At the start of your server application... I put the rest in to show you how to use the related commands. This command "HIDE WINDOW" I blieve is built into default DBPro so you do not need STYX for it...

Eitherway... I also tried this...



Which also worked...

Looks like you had the dots in the wrong places...

Hope this helped and the commenting I added made sense and helped any readers.

EDIT

Quote: "MADE SOME CORRECTIONS AND SLIGHT GRAMMAR CORRECTIONS... nevermind, nobody is good at their language anyway lol."


EDIT

Also pay attention to the ` mark hope you already know about this mark its also for commenting out sections of code / lines, It works like REM.

Its located normally left of 1 across the top of your keyboard below the function F1 F2 F3... keys and possibly directly below the ESC key... just press it no need to press CTRL, SHIFT or ALT keys.

EdzUp
23
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 25th Nov 2011 16:03
Yeah was gonna say "./" is linux and mac . is windows and MS-DOS

-EdzUp
Graveyard Dogs
SamVickery
14
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 25th Nov 2011 23:32
Hey guys thanks for the help I have used the

EXECUTE FILE "Server.exe","","."

For now but i may look into STYX

I dont know why I didnt think of just "."

The people in this forum are amazing

Thanks again
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 25th Nov 2011 23:49
You are welcome

SamVickery
14
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 26th Nov 2011 23:26
I have run into anothe problem

This time the 2 space ships are going out of sync with each other

With advice from a network specialist they advised me to send over the keystates of each player rather than the co-ordinates. This will reduce the amount of data being sent.

This is because with lets just say up to 500 lasers on the screen at one time this is alot of information needed as you would have top send the angle the x and y and also the type of laser it is. This can easily be over 2000 bits of data being sent every loop.

This is why I was advised to just send over the keystates of what the player has pressed and deal with the processing of what they have done on the local machine.

I dont understand why they are going out of sync just wandering if anyone has had this problem before.

Shall I send over all the information of the player every loop and the key states of the attacks.

Or shall I send over the keystates and then every 1 or so seconds send over all the information of the spaceship.

Sorry if this doesnt make any sense

Any help would be good as im out of ideas
TamBam
14
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 29th Nov 2011 20:19
any darknet clear tutorials out there ??? only for BarkBasic Pro thanks .
TamBam
14
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 30th Nov 2011 00:49
I buy DarkNet But I con't get the proper document to use it for DarkBasic Pro ...

can any 1 told me where to get or any website ??
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 30th Nov 2011 02:37
This new user thing is confusing...

Regarding the question on DarkNet... Try the thread?

bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 2nd Dec 2011 14:44 Edited at: 2nd Dec 2011 14:45
Yes, you should send the keystates rather than the positions.

However, because of the slow speed of network communication, a client getting a new key will process the new command up to 200ms later (or more or less, depending).

This adds up very fast. It's important to send the positional data every so often to get everything back in sync. It is also important to calculate the latency (time for commands to get from and to a location) and move the simulation back to account for the lost time.

For example, if it takes on average 100ms for a command to get from a to b, what you'd do is take a's command on b, run the simulation back 100ms and re-apply the update. Then move it forward. You'll have to account for any race conditions. Race conditions in this case would be where two commands or events conflict with eachother.

For example, if one person fires on another, and the other fires on the first and each of them see it as if they fired first before the other could get a shot off, which one survives?

Network games are hard.


TamBam
14
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 2nd Dec 2011 17:57
Any DarkNet Tutorials available ?? for use in DarkBasicPro ? thanks ..
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Dec 2011 18:18
Not at my pc... But the official tool is called mikenet... Try looking for it.. If I can I will post the link when I can... On phone atm... Sorry

TamBam
14
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 4th Dec 2011 10:18
YES I GOT ALL DOCUMENTS AND COMMANDS ..
IN DBP EDITOR I TYPE \\\"MN START SERVER\\\" AND PRESS F1 AND I GET All
TamBam
14
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 4th Dec 2011 10:19
yes i got all documents and commends ..
SamVickery
14
Years of Service
User Offline
Joined: 13th Oct 2011
Location:
Posted: 11th Dec 2011 13:03
Sorry for the late reply guys

Thanks for thehelp yes I am using key states and sending over the co-ordinates 3 times a second to keep everything in sync

I did look into the interpolation but because my game is only going to be a lan game the latency is very low.

I am finding that darkbasic is very slow for networking though

Im now rewriting the server to act as the master copy of the game because I send over the health sometimes the health goes up on one screen, this is because of the delay with the shots that some times a laser hit a ship on one screen but missed on the other.

This is becoming a bigger task than I ever imagined, but in my opnion it was easier than writing suitable AI. I may be wrong in that opinion though

Its all good experience for when hopefully I start a career in games programming

When the game is complete I will be hosting the .exe on a server that I have. Anyone would be welcome to test it and also please leave comments of any improvements. The only problem is that it is only a LAN game there will be a single player tutorial but that is it.

Thanks for all your help so far

Sam

Login to post a reply

Server time is: 2026-07-09 21:19:45
Your offset time is: 2026-07-09 21:19:45