BlitzPlay internet use..

Blitz3D Forums/Blitz3D Programming/BlitzPlay internet use..

..I would like to use BlitzPlay in my upcoming D platformer since its looking quite good and fast..I did try demo, and its working very well within LAN environment...in order to use it over internet, how to initially set up BlitzPlay?? Any existing user out there wanna share some info about it?? If so, I'll apprechiate it a lot....thank youu..

I tried blitzplay a while ago and played around with it for a few days. Finally, I wrote this and tested it over the internet.
;-----------------------------------------------------------------------------------------------------
;										BlitzPlay 2d example
;-----------------------------------------------------------------------------------------------------

Include "BPliteV1.14.bb"

SeedRnd MilliSecs()

Type player
	Field x
	Field y
	Field netid
	Field name$
	Field say$
	Field colour
End Type

Global guest.player
Global host

;-----------------------------------------------------------------------------------------------------
;											Setup()
;-----------------------------------------------------------------------------------------------------

Cls
FlushKeys
myname$ = Input$ ("Your name? ")

If Not debug Then

	ips 	= CountHostIPs("")
	If Not ips Then End
	hip 	= HostIP(1)
	Print DottedIP(hip)

	hostyn$ = Input ("Host or Join (h/j) ? ")
	host = (Lower$(hostyn$) = "h")

	If host Then	
		My_Port = 2222
		If Not BP_HostSession (myname,10,1,2222,10) Then
			Cls
			Locate 0,0
			Print "Host port was unavailable..Push a key to exit.."
			WaitKey
			End
		End If
		
	myself.player = New player
	myself\name$ = myname
	myself\x = 160
	myself\y = 120	
	myself\netid = BP_My_ID
	myself\colour = Rnd($44, 16777216)

	Else
	
	Print "Host port = 2222"
	Print "(Blank for Local IP)"
	IP$ = Input$("Please enter the host's IP? ")
	Select IP
		Case ""
			IP$ = "127.0.0.1"
			My_Port = Rand(3000,4000)
			If Not fullscreen Then
				width = 600
				height = 200
			End If
		Default
			My_Port = Input$ ("What port would you like to use? ")
			If Not My_Port Then My_Port = Rand (3000,4000)
			If Not fullscreen
				width = 600
				height = 600
			End If
	End Select
	Cls
	Text 200,50,"Connecting! (Hit [esc] to cancel)",True,True
	Select BP_JoinSession (myname,My_Port,IP,2222)
		;Handle any of the reasons if we couldn't join.
		Case BP_NOREPLY
			Cls
			Text 0,0,"No reply in specified timeout period.. exiting"
			WaitKey
			End
		Case BP_IAMBANNED 
			Cls
			Text 0,0,"You have been banned from joining this game.. exiting"
			WaitKey
			End
		Case BP_GAMEISFULL
			Cls
			Text 0,0,"The game is full.. exiting"
			WaitKey
			End
		Case BP_PORTNOTAVAILABLE
			Cls
			Text 0,0,"Port: " + My_Port + " was not available.. exiting"
			WaitKey
			End
		Case BP_USERABORT
			Cls
			Text 0,0,"Connection attempt aborted!"
			WaitKey
			End
	End Select
	;Oh, we're allowed in? here we go!
	myself.player = New player
	myself\name 	= myname
	myself\x 		= 160
	myself\y 		= 120
	myself\netid 	= BP_My_ID
	myself\colour 	= Rnd($44, 16777216)
	
	End If
	
End If

;-----------------------------------------------------------------------------------------------------
;												Game()
;-----------------------------------------------------------------------------------------------------

Graphics 		320, 240, 0, 2
SetBuffer 		BackBuffer()

ix 	= 100
iy 	= 100

;main loop
While Not KeyHit(1)

Cls

If KeyDown(203) Then ix = ix - 10
If KeyDown(205) Then ix = ix + 10
If KeyDown(200) Then iy = iy - 10
If KeyDown(208) Then iy = iy + 10
If ix < 0 	Then ix = 0
If iy < 0 	Then iy = 0
If ix > 320 Then ix = 320
If iy > 240 Then iy = 240

myself\x = ix
myself\y = iy

Tyme = MilliSecs() / 20

If Tyme <> chk Then
	BP_UpdateNetwork
	HandleMessages
	msgtosend$ 		= BP_IntToStr(Int(Tyme), 3) + BP_IntToStr(Int(myself\x), 3) + BP_IntToStr(Int(myself\y), 3) 
	BP_UDPMessage 	(0, 1, msgtosend)
	chk 			= Tyme	
	End If

;draw players
For guest = Each player
	Color 0, 0, guest\colour
	cx = guest\x
	cy = guest\y
	Text cx, cy - 20, guest\name$, True, False
	Oval cx, cy, 10, 10, True
Next

Flip

Wend

End

;-----------------------------------------------------------------------------------------------------
;  										    Handle messages
;-----------------------------------------------------------------------------------------------------
Function HandleMessages ()
	For msg.MsgInfo = Each MsgInfo
		Select msg\msgType
			Case 255
				guest.player = New player
				guest\name = msg\msgData
				guest\x = width/2
				guest\y = height/2
				guest\netid = msg\msgFrom
				guest\colour = Rnd($44, 16777216)
			Case 254
				For guest = Each player
					If guest\netid = msg\msgFrom Then Delete guest
				Next
			Case 253
				For guest = Each player
					If guest\netid = msg\msgFrom Then Delete guest
				Next
			Case 1
				time% = BP_StrToInt (Mid$(msg\msgData,1,3))
				newx% = BP_StrToInt (Mid$(msg\msgData,4,3))
				newy% = BP_StrToInt (Mid$(msg\msgData,7,3))
				For guest = Each player
					If guest\netid = msg\msgFrom Then guest\x = newx: guest\y = newy
				Next
		End Select
	Delete msg
	Next
End Function

It was a while ago, and I didn't really understood networking (still don't really get it), but I remember at one point we had to enable a port on the firewall.

hmm..looking pretty much as demo i download...maybe firewall issue was reason why it wasnt work over internet..did you maybe try demo whats included with lite version trough internet?? I'll give it a try later to see is it actually firewall issue..

Yes, that is what I did: I ran the (lite) demo, noticed some interpolation problems (ships went the wrong way) and tried to rebuild it. I was going to get back to this later on, but haven't gotten to it yet.
This might be very obvious, but for me it was a solution: with both this and the directplay examples I tried, I needed to enter a valid IP adres (for the host) to get it to work. First, I tried leaving the IP adres empty, which only worked locally.