Connect a two-player QML game through Wifi
-
wrote on 1 Jan 2019, 13:06 last edited by tomy 1 Jan 2019, 13:08
I started learning QML and after a while wanted to test myself through writing a good QML app by what I'd learnt up to that time.
It's my app, called Pingpong.It embraces six QML files:
main.qml
,Racket.qml
,Ball.qml
,WinBox.qml
,Counter.qml
andLight.qml
:It's good, has an icon and works fine on Android devices.
For the second major version, I want to develop it so that the game can connect by Wifi and two players can play the game installed on their smartphones through a shared Wifi.
Actually, @J.HILK suggested that I consider that for the next progress in the app.
Now, what to do for that goal? Where should I start, please?
-
Hi,
Don't get hellbent on WiFi rather on network in general.
You can start by studying the Qt's network related example, specifically the TCP related ones. @VRonin's chat example will also be of interest (not so much for the chat part itself but for the network related stuff).
Next question is whether you want to have a server somewhere or the game instances being able to handle each other.
-
wrote on 1 Jan 2019, 21:40 last edited by
Thanks.
Wouldn't it be easier if I used Bluetooth instead of Wifi?
I'm myself new in QML I fear the stuff relating to networking (and Wifi) are too complex for this time of me. Aren't they, please? -
Thanks.
Wouldn't it be easier if I used Bluetooth instead of Wifi?
I'm myself new in QML I fear the stuff relating to networking (and Wifi) are too complex for this time of me. Aren't they, please?@tomy hi,
First of:
Happy new year, if you follow the gregorian calendar.I personlly find Networking(LAN and WLAN) a good bit easier to use and implement than Bluetooth, but that just my opninion.
What @SGaist says it true, TCPSockets (with or without a server) is probably the way you want to go.
Here are some helpfull links.
Fortune Client example
Fortune Server exampleinstall the client on one phone the sever on the other and see if you manage a connection, should be relatively easy, but can be a challenge. At first, do not try to cross OS's - for example windows <->Android, because that can be a lot more complicated.
-
wrote on 3 Jan 2019, 09:07 last edited by
Hello,
I'd use the new Qt Remote Objects. They hide away all the network stuff so you can focus on the game.citation from the doc:
"Qt Remote Objects (QtRO) is an inter-process communication (IPC) module developed for Qt. The idea is to extend Qt's existing functionalities to enable an easy exchange of information between processes or computers."cheers wink
1/5