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 / "Create net game" statement not working :'(

Author
Message
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 1st Oct 2011 02:42
Basically, my problem is thus:
I am trying to create a DarkBASIC game that I have some pretty big plans for, but right now it isn't beyond 400 lines of code, I've only just started on it. While I think the usual precedure is to make a singleplayer game, then add multiplayer functionality when you intend the finished version to have both, I decided to start off with multiplayer. This is the first time I have ever used the Networking statements in DBPro. I had a stab at it, and after a couple of failed attempts, got everthing as it should be. Here is a snippet from the code:

Quote: "set net connection 3, ipaddress$
wait 500
create net game gamename$, playername$, 30, 1
wait 400
if net game exists() = 1
print "Multiplayer game successfully started!"
wait 1800
else
print "I'm really sorry, something (I don't know what) went wrong. No multiplayer! "
wait 1800
end
endif"


Of course, the gamename$ and playername$ are defined earlier on in the code. When this code runs, it seems to work first time. Sometimes it works second time. But very soon after, it won't work at all, with no changes from me! The program jams and won't respond when it hits the 'create net game' statement. Everything should be working, this is a very annoying bug in DarkBASIC. Anyone have any ideas/suggestions/similar experiences?
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 1st Oct 2011 05:00
First off bud, it's NEVER a good idea to wait in your loop like that in a multiplayer setting, because you could easily miss incoming packets.

I wrote a tutorial/code on it a little while ago. A simple PONG game, with more details and tips: http://forum.thegamecreators.com/?m=forum_view&t=189726&b=6

Hope it helps! Don't hesitate to ask if you have any more questions.
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 1st Oct 2011 22:33
Thanks! A pity though, it still aint working
I copied your code into DarkBASIC, ran it, and the same thing happened. I choose to host the game, it freezes up on "create net game"! This probably means the problem is with my computer. They are the worst problems, because they are often hard or impossible to fix. You can't even have the satisfaction of other people empathising with you
Oh, well... I'll keep trying, and post if I get it working.
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 2nd Oct 2011 00:23
Unfortunately, after some testing, I think I have found the problem... I have a 64-bit computer. I ran the program on a 32 bit PC, and that worked fine. Are they ever going to release a 64 bit version of DarkBASIC?
It cripples my development of games that stuff like this won't work...
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Oct 2011 01:39
Quote: "I think I have found the problem... I have a 64-bit computer"

Nope, there's something else going on here.

Sometimes the CREATE NET GAME command takes a while to do its thing - around 15 seconds on my machine.

I did notice when I ran an old piece of code I have that if you don't provide an IP address when using SET NET CONNECTION that when the application pops up an IP address entry window, on my machine this is sometimes hidden behind the DBPro window.

Apart from that, the program runs fine on my system, which is Windows 7 64 bit with SP1

The code isn't high quality, but you're welcome to try it:


Just fix the IP address at the top before compiling, then run it once as a server, then one or more times as a client - anything typed at a client will be delivered back to that client. The text entry is quite rough, but it demonstrates round-trip messages via a server.

SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 6th Nov 2011 19:30
Sorry not to have posted on here for so long...
Thanks for the code snippets guys! I have currently disabled the net game feature in my program, and just carried on with it. More testing seems to show that I can run a net game test on my machine once, twice, sometimes three times, but after that it locks up and stops working for some reason... I don't know why...
JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 6th Nov 2011 20:32 Edited at: 6th Nov 2011 22:14
<EDIT>I've been using "MikeNet" and been happy with the results:

MikeNet

I think this is the same as DarkNet

Hope this helps!</EDIT>
Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 6th Nov 2011 22:13
Yes, Darknet is a good choice, as is MultiSync (which is my personal preference). Don't waste time with the raw DBPro communications commands, they don't work consistently across machines.

I also want to echo IanM's response: CREATE NET GAME can take ages to come back with a response (be it failure or success). Back away slowly and install MultiSync or Darknet.

One more thing: If you plan to include multiplayer capability in a game, code everything with that in mind. It is extremely hard to convert a singleplayer game into a multiplayer game. Even if you haven't implemented the netcode yet, write all your program code such that you will easily be able to change a few things to get incoming communication influencing your game.

If you start writing a singleplayer game, it will never be a multiplayer game. Write a multiplayer game from the beginning that can also be played singleplayer, instead, and leave out the actual netcode until you're ready to tackle it.

Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 8th Nov 2011 06:29
Quote: "One more thing: If you plan to include multiplayer capability in a game, code everything with that in mind. It is extremely hard to convert a singleplayer game into a multiplayer game. Even if you haven't implemented the netcode yet, write all your program code such that you will easily be able to change a few things to get incoming communication influencing your game.

If you start writing a singleplayer game, it will never be a multiplayer game. Write a multiplayer game from the beginning that can also be played singleplayer, instead, and leave out the actual netcode until you're ready to tackle it.

"


learned the hard way... absolutely agree.


Login to post a reply

Server time is: 2026-07-10 07:38:33
Your offset time is: 2026-07-10 07:38:33