multiplayer -- what?

BlitzMax Forums/BlitzMax Programming/multiplayer -- what?

InvisibleKid(Posted 2008) [#1]
i've read every topic on gnet that the search brought up, and every thing in the code archives.

alot of the examples and code snippets wouldn't work, probably because of version differences, and i don't know where to start to correct them.

i've written a VERY CRUDE test project (just to test things out and try and get an understanding of using gnet), thats gone under many revisions based off the code examples that did work.

my final code is loosely based on the code that WendellM wrote.

it seems to connect, but doesn't send and/or receive any information.
i've spent the last 3 days constantly going over all the gnet posts and examples and recoding, but for the life of me can't figure out what to do or how to do it correctly.

in this test program each player is player 1 on their own computer and the other connected player is player 2.
i need to:
1. know when player 2 connects and add 1 to the numplayers var on both computers.

2. be able to send p1x,p1y coords to be recieved by the other player and put them into p2x,p2y.

as always any help would be greatly appreciated.




Arowx(Posted 2008) [#2]
Hi KingNothing,

Your problem is caused by the GNetObject localObj which you can only create after you have constructed the TGNetHost.

So if you change your connectTo() function and create the localObj after you create the Host it works fine!

e.g.

Function ConnectTo()
	CloseGNetHost(host)
	host:TGNetHost=CreateGNetHost()

	'localObj needs to be created from new host
	localObj = CreateGNetObject:TGNetObject( host )

	If hosting = 1


Hope this helps.


InvisibleKid(Posted 2008) [#3]
still having probs knowing how many are connected ie. 1 or 2
(but i know i'm doing something wrong), so i just changed numplayers to always read as 2 for now. other then that it works great.
the other comp connects and both players move great.
so big THANKYOU!!

now i have a place to start tinkering and figuring things out. then i can acctually attempt to add multiplayer to my real game.


Rimmsy(Posted 2008) [#4]
It took me a while to figure it out too. Once you get your head around it though, it's easy to play with. Try this demo.

note: you'll have to change the image.




InvisibleKid(Posted 2008) [#5]
very cool Rimmsy i like it,thanks for that.
i'm actually starting to under stand this gnet stuff a bit now thanks to you two.

its hard to believe well actually its not, that one line in the wrong place caused me three days of headache (literally) lol.


Rimmsy(Posted 2008) [#6]
Tell me about it. I went through every possible multiplayer lib on the forums and didn't have any joy with them. I must have spent about three days developing wrappers for them only to realise they weren't right for the job.

Good luck with your project, mine's coming along nice.