[iPhone] Bluetooth Multiplayer

Previous topic - Next topic

trucidare

Hi There,

here is some Bluetooth Multiplayer blah

Add these lines into your Project.
Code (glbasic) Select

IMPORT "C" void GLB_iBT_Init()
IMPORT "C" void GLB_iBT_Start(const char* sessID)
IMPORT "C" int GLB_iBT_Send(const char* strValue)
IMPORT "C" const char* GLB_iBT_Recv()
IMPORT "C" int GLB_iBT_Connected()


use this functions in your game. Init at start of your Program, Start opens the Bluetooth search dialog.

to compile add attached lib and GameKit.framework to your xcode project.



[attachment deleted by admin]
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Marmor


bigsofty

Another fine release, well done Truci!  :good:

Can anyone recommend a good link on Bluetooth networking? Its completely new to me.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

fjsantosb

Hi there,

As usual another great work coming from trucidare!

Thanks for sharing!

King Regards, fjsantos.
Francisco Santos Belmonte founder of Tip Tap Games.
Website: www.tiptapgames.com
Twitter: www.twitter.com/tiptapgames
Facebook: http://dld.bz/dYVd
iPhone News & Sales: www.gamesappetizer.com

codegit

------------------------------------------
1 X Acer TravelMate 4270, laptop, XP PRO
1 X Dell Studio 17 laptop, Windows 7
1 X MacBook Pro 2,2 GHz Core 2 Duo, 2 GB RAM, 160 GB HDD, 9400M
2 X iTouch
1 X HTC Desire (Android 2.1)
iPad soon to be added

Crivens

Thats brilliant. Nice one! Got a simple effort working no worries. A couple of questions though:-

1. How do you close a connection so you can start a new one with a different device? I tried using the init function again, which works but I end up with multiple versions of the same device on the menu list. Tried the start function and it picks up the old connection straight away. Can't see how to stop the connection to search for a new one (without using init again)
2. Is it possible to allow more than two players? I have heard elsewhere of certain games (eg. Guitar Hero) using 4 player for example. Does this current lib handle it, or is it only for 2 players?

Thanks for the library, brilliant stuff!

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

trucidare

i dont know if the new gamekit allows more than 2 players - i will have a look in the next days. i think closing and create a new connection should be no problem
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Moebius

First of all, brilliantly done trucidare!  I know this is a bit late, but I only noticed this thread and library recently  :whistle:

It's been a long time since this was released, but I have found two problems in my testing:

1)  It seems that after a while and many sends and receives, the app will crash.  The best I've been able to get out of the use of GDB is the error  'EXC_BAD_ACCESS', which seems to happen during either the receive or send function - I'm unsure of which ATM (in other words I forgot which one sry).

2)  After the devices go out of range, or disconnect for some other reason, if the app is left open, the flag that remembers whether the device is 'busy' or not seems to be left set, and it cannot connect with any other devices due to this.

Apart from these problems, everything seems to work outstandingly well.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Crivens

Thanks Trucidare, that would be great!

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Moebius

Okay apparently, at some point in the receive function the call:
[CFString _fastCharacterContents]
is made to a deallocated instance.
More specifically, the function listed on the stack in the debugger is "-[iBluetooth _GLB_iBT_Recv]".

I can't offer anything more than this, and the assembly code that the program stops on (I doubt that would help much but ask if you want it), as I don't have the actual code...
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

trucidare

ok i will have a look, sounds like the var to store informations to receive are broken after some readings.
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Moebius

Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

trucidare

hmm i´m thinking about a xcode template for writing external libs.
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Crivens

Really? With also a bit of a tutorial on how to create our own XCode libs that link to GLB then it would surely expand much quicker. I mean you do amazing stuff, but there is only so much one man can do!

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Crivens

Yeah, I can get one of the devices to crash out after a while too. Don't know why it happens just after a few minutes of knocking data back and fore one of the devices just dies off.

Any news on the closing a link down? Would totally clean mine up if I could close an existing link down and effectively start again without calling init.

Admittingly I don't know much about bluetooth communication, but I send an update message once a second, and try to retreive a message every single loop incase I miss anything. Do I need to worry about that, or will it stay on a queue and when I next receive it will pick up the last one? What I am getting at the minute is now and again a move is missed by the receiver. Before I start debugging more (for example I am 99% sure it should always send a move to the other device when a move is made, but perhaps it's not for some reason) then have you any better advice on how to use this library in the middle of a game loop? My game is fairly simple, and knowing of a move once a second or even longer is fine.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.