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.

AppGameKit Classic Chat / Multiplayer Remoto (NO LAN)

Author
Message
Rickyes
9
Years of Service
User Offline
Joined: 7th Sep 2015
Location:
Posted: 4th Mar 2016 11:53
Salve a tutti.
Vorrei creare un gioco multiplayer dove i giocatori si connettono ad una rete che non e' LAN o locale.
Chiaramente per una connessione Lan non ho trovato problemi ed infatti sono riuscito a creare questo tipo di collegamento senza troppi patemi.
A questo punto mi domando:
1) Per essere raggiunto in rete ho bisogno di un server esterno e quindi devo acquistare qualche servizio di game server?
2)Devo impostare un IP statico?

chiaramente i listati che seguono sono solo un piccolo esempio e funzionano in LAN

Adesso in pratica, vorrei che con questo esempio, i giocatori potessero comunicare fuori da una rete Lan
ed eventualmente sapere tutto quello che serve perche' la magia avvenga

Ringrazio chiunque puo' aiutarmi a risolvere il dilemma

GRAZIE!!!!!
Rickyes
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
listato
Host:

SetVirtualResolution( 640, 960 )
SetResolutionMode(1)
net=HostNetwork("192.168.0.103","host",48230)

AddVirtualButton(1,200,200,50)
AddVirtualButton(2,100,200,50)
AddVirtualButton(3,100,300,50)
AddVirtualButton(4,100,400,50)
///
LoadImage(1,"Square.png")
CreateSprite(1,1)
LoadImage(2,"Square.png")
CreateSprite(2,2)
SetSpriteColor(2,0,255,0,255)

do
Sync()
print("PROGRAMMA HOST")
Print("Network ID is " + Str(net))
Print("Device IP is " + GetDeviceIP())
Print("Server ID is " + str (GetNetworkServerID(net)))
Print("Client ID is " + str (GetNetworkMyClientID(net)))

gosub internet

if GetVirtualButtonState(1)=1 then xx=xx +1
if GetVirtualButtonState(2)=1 then xx=xx -1
if GetVirtualButtonState(3)=1 then yy=yy -1
if GetVirtualButtonState(4)=1 then yy=yy +1
loop


internet:
msg2=CreateNetworkMessage()

msg=GetNetworkMessage(net)
if msg <> 0
x=GetNetworkMessageInteger(msg)
y=GetNetworkMessageInteger(msg)
name$=GetNetworkMessageString(msg)
AddNetworkMessageInteger(msg2,xx)
AddNetworkMessageInteger(msg2,yy)
SendNetworkMessage(net,0,msg2)
DeleteNetworkMessage(msg2)
DeleteNetworkMessage(msg)


endif

SetSpritePosition(1,x,y)
SetSpritePosition(2,xx,yy)
print(name$)

return

----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
Listato
Cliente:

SetVirtualResolution( 640, 960 )
SetResolutionMode(1)
net=JoinNetwork("192.168.0.103",48230,"client")

AddVirtualButton(1,200,200,50)
AddVirtualButton(2,100,200,50)
AddVirtualButton(3,100,300,50)
AddVirtualButton(4,100,400,50)
AddVirtualButton(5,100,600,50)
///
LoadImage(1,"Square.png")
CreateSprite(1,1)
LoadImage(2,"Square.png")
CreateSprite(2,2)
SetSpriteColor(2,0,255,0,255)
xx=xx
yy=yy
do
Sync()
print("PROGRAMMA CLIENTE")
Print("Network ID is " + Str(net))
Print("Device IP is " + GetDeviceIP())
Print("Server ID is " + str (GetNetworkServerID(net)))
Print("Client ID is " + str (GetNetworkMyClientID(net)))
gosub internet

if GetVirtualButtonState(1)=1 then x=x +1
if GetVirtualButtonState(2)=1 then x=x -1
if GetVirtualButtonState(3)=1 then y=y -1
if GetVirtualButtonState(4)=1 then y=y +1
if GetVirtualButtonState(5)=1 then end

loop


internet:

msg=CreateNetworkMessage()

msg2=GetNetworkMessage(net)


AddNetworkMessageInteger(msg,x)
AddNetworkMessageInteger(msg,y)
AddNetworkMessageString(msg,"Cliente")

xx=GetNetworkMessageInteger(msg2)
yy=GetNetworkMessageInteger(msg2)

SendNetworkMessage(net,0,msg)
DeleteNetworkMessage(msg2)
DeleteNetworkMessage(msg)

//in aggiunta

SetSpritePosition(1,x,y)

SetSpritePosition(2,xx,yy)
//fine
return
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 4th Mar 2016 13:18
Rickyes
9
Years of Service
User Offline
Joined: 7th Sep 2015
Location:
Posted: 4th Mar 2016 13:24
Hello everyone
. I would like to create a multiplayer game where players connect to a network that is not local or LAN.
Clearly for a Lan connection have not found problems and in fact I was able to create this type of connection without too many worries.
At this point I wonder:
1) to be reached on the net I need to an external server and so I have to buy some service to the games server?
2) should I set a static IP? clearly listings that follow are only a small example and work in LAN
I would like this example, players could communicate out from a network Laned possibly know everything because the magic happen I thank anyone who can help me resolve


Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 4th Mar 2016 13:29 Edited at: 4th Mar 2016 13:34
Quote: "1) to be reached on the net I need to an external server and so I have to buy some service to the games server?"

No, you dont need to pay for a game services web server, you just need their external IP address, not the internal one. (You can poll whatismyip.com for thi.s) This is where people use an internet site to store IPs of active players. Not needed for testing where you can ask for IPs, probably needed when deployed. A simple php script and database can do this.

Quote: "2) should I set a static IP? clearly listings that follow are only a small example and work in LAN"

Not needed.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 4th Mar 2016 14:13
I have not tried to make a multiplayer game in AppGameKit or tried to connect to others over internet. So can't help you there.

Quote: "A simple php script and database can do this."


This is probably the best solution. Get a cheap web space like one.com and you can have AppGameKit connect to a php script through HTML, and that php script can connect to a MySQL database. Or set up your own web server if you have a good internet connection. Then players can host games that others can join. But keep in mind that peer to peer connections like this aren't the best for fast paced multiplayer games. For that you need really advanced servers.
Rickyes
9
Years of Service
User Offline
Joined: 7th Sep 2015
Location:
Posted: 4th Mar 2016 19:33
Non essendo esperto di php ed mysql e' possibile avere un esempio di script ?

Not being expert in php and mysql it is possible to have a sample script?



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Mar 2016 20:15
This is a tutorial for high score tables in DBPro. But you can learn a lot from it

https://forum.thegamecreators.com/thread/170586
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-09-29 11:26:09
Your offset time is: 2024-09-29 11:26:09