I am looking for a tutorial for a game like pong using Photon Cloud. The two simple and advanced files provided are neat but they lack comments for me to understand exactly what is going on. A tutorial like pong with four objects on the screen is not overly complex and not to simple and I think it would help a lot of people like myself who have never developed any multiplayer games etc.
When joined to room, detailed info on all actors in the room available from actors list: client:myRoomActors():
for actorNr, actor in pairs(client:myRoomActors()) do print(actor.name, actor.actorNr, actor:getCustomProperty("prop1"), actor:getCustomProperty("prop2") ) end
While client is connected to master server, general statistics for lobbies available: peers connected count and games count.
Use client:requestLobbyStats() to query stats and implement client:onLobbyStats() to handle response:
function client:onLobbyStats(errorCode, errorMsg, lobbies) if lobbies then for \_, l in pairs(lobbies) do print(l.lobbyName, l.lobbyType, l.peerCount, l.gameCount) end end end
When joined to room, detailed info on all actors in the room available from actors list: client:myRoomActors():
for actorNr, actor in pairs(client:myRoomActors()) do print(actor.name, actor.actorNr, actor:getCustomProperty("prop1"), actor:getCustomProperty("prop2") ) end
While client is connected to master server, general statistics for lobbies available: peers connected count and games count.
Use client:requestLobbyStats() to query stats and implement client:onLobbyStats() to handle response:
function client:onLobbyStats(errorCode, errorMsg, lobbies) if lobbies then for \_, l in pairs(lobbies) do print(l.lobbyName, l.lobbyType, l.peerCount, l.gameCount) end end end
I really think this module is lacking a tutorial. I’ve read through the example code, but it’s bloated with code specific to the “games” in the example. Perhaps I’m lacking the initial knowledge I require to begin working with Photon.
For me, I’d love a tutorial that showed you step by step what’s needed.
Saying this:
connect
join room
raise events (reliable or unreliable), put data you want to send around
Is like saying:
(sorry for the language )
It would be great if someone could compile a pong tutorial or something similar.
local photon = require “plugin.photon” local LoadBalancingClient = photon.loadbalancing.LoadBalancingClient local client = LoadBalancingClient.new(appInfo.MasterAddress, appInfo.AppId, appInfo.AppVersion)
override methods to handle events, responses and state change:
function client:onStateChange(state) if state == LoadBalancingClient.State.JoinedLobby then – join or create room here self:joinRandomRoom() – self:joinRoom(“helloworld”) – self:createRoom(“helloworld”) end end function client:onEvent(code, content, actorNr) if code == EVENT_CODE then – handle event, e.g. sync with other client end end
connect to server and run game loop with ‘service’ calls:
client:connect() function client:timer(event) self:service() – game logic end timer.performWithDelay( 100, client, 0)
send events to other clients somewhere inside game logic or handler:
local data = {x = 1, y = “bla”} self:raiseEvent(EVENT_CODE, data) – reliable by default – self:raiseEvent(EVENT_CODE, data, {sendReliable = false }) – unreliable
I really think this module is lacking a tutorial. I’ve read through the example code, but it’s bloated with code specific to the “games” in the example. Perhaps I’m lacking the initial knowledge I require to begin working with Photon.
For me, I’d love a tutorial that showed you step by step what’s needed.
Saying this:
connect
join room
raise events (reliable or unreliable), put data you want to send around
Is like saying:
(sorry for the language )
It would be great if someone could compile a pong tutorial or something similar.
local photon = require “plugin.photon” local LoadBalancingClient = photon.loadbalancing.LoadBalancingClient local client = LoadBalancingClient.new(appInfo.MasterAddress, appInfo.AppId, appInfo.AppVersion)
override methods to handle events, responses and state change:
function client:onStateChange(state) if state == LoadBalancingClient.State.JoinedLobby then – join or create room here self:joinRandomRoom() – self:joinRoom(“helloworld”) – self:createRoom(“helloworld”) end end function client:onEvent(code, content, actorNr) if code == EVENT_CODE then – handle event, e.g. sync with other client end end
connect to server and run game loop with ‘service’ calls:
client:connect() function client:timer(event) self:service() – game logic end timer.performWithDelay( 100, client, 0)
send events to other clients somewhere inside game logic or handler:
local data = {x = 1, y = “bla”} self:raiseEvent(EVENT_CODE, data) – reliable by default – self:raiseEvent(EVENT_CODE, data, {sendReliable = false }) – unreliable