MULTIPLAYER ONLINE GAME - how to do?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
MULTIPLAYER ONLINE GAME - how to do?
How to create SERVER/CLIENT with love2d, pleaseeeeeeeee I am trying 1 week left
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: MULTIPLAYER ONLINE GAME - how to do?
Hi and welcome to the forums!
https://love2d.org/wiki/lua-enet has code for a simple server+client project, although you need to modify the infinite loops since löve already has love.update you should use.
Alternatively
https://love2d.org/wiki/socket and https://love2d.org/wiki/Tutorial:Networking_with_UDP may also work.
I must say, one week to finish such a thing is kind of a brave thing to do!
https://love2d.org/wiki/lua-enet has code for a simple server+client project, although you need to modify the infinite loops since löve already has love.update you should use.
Alternatively
https://love2d.org/wiki/socket and https://love2d.org/wiki/Tutorial:Networking_with_UDP may also work.
I must say, one week to finish such a thing is kind of a brave thing to do!
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: MULTIPLAYER ONLINE GAME - how to do?
A polite way of saying "not going to happen".I must say, one week to finish such a thing is kind of a brave thing to do!
Technically it's possible, but concurrency for real-time multiplayer games is a hard problem.
- Sir_Silver
- Party member
- Posts: 286
- Joined: Mon Aug 22, 2016 2:25 pm
- Contact:
Re: MULTIPLAYER ONLINE GAME - how to do?
I was able to create a multiplayer game in love within 1 week using https://github.com/camchenry/sock.lua.
Re: MULTIPLAYER ONLINE GAME - how to do?
I got make connection and send/receive data, server -> client and client -> server... but
How is the system about interaction of maps, player, players, criatures, objects, itens, etc... ??
(I will make a mmorpg game)
Can explain about that, please?!
here is my code (server: lua, client:love )
How is the system about interaction of maps, player, players, criatures, objects, itens, etc... ??
(I will make a mmorpg game)
Can explain about that, please?!
here is my code (server: lua, client:love )
Code: Select all
-- Server
local socket = require("socket")
udp = socket.udp()
udp:setsockname("*", 53474)
udp:settimeout(1)
while true do
data, ip, port = udp:receivefrom()
if data then
print(os.date().." - RECEIVED: ".. data, ip, port)
udp:sendto('I AM SERVER', ip, port)
end
socket.sleep(0.01)
end
-- Client
local socket = require("socket")
udp = socket.udp()
udp:setpeername("127.0.0.1", 53474)
udp:settimeout(1)
udp:send("I AM CLIENT!")
data = udp:receive()
function love.load()
end
function love.draw()
if data then
love.graphics.print("RECEIVED: ".. data)
end
end
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: MULTIPLAYER ONLINE GAME - how to do?
>MMORPG
>Without game programming knowledge
It's getting better and betterm, though i do admire your brazenness.
Okay, so basically you send whatever you want to send, and then process whatever you want to process. It's that simple.
It's all up to you how you code your game.
>Without game programming knowledge
It's getting better and betterm, though i do admire your brazenness.
Okay, so basically you send whatever you want to send, and then process whatever you want to process. It's that simple.
It's all up to you how you code your game.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: MULTIPLAYER ONLINE GAME - how to do?
CLIENT SEND ' asks for tilemap coordinates'
SERVER RECEIVE WHEN ASKS AND SEND coordinates
CLIENT DRAW tile map with coordinates
CLIENT SEND ' asks for objects in tilemap coordinates'
SERVER RECEIVE WHEN ASKS AND SEND objects attr.., coordinates, etc..
CLIENT DRAW objects with attr.., coordinates, etc.. RECEIVED
same to players online...
PLAYER SEND 'moveUP' to server
SERVER RECEIVE, validate (colisions/events) and SEND awser
CLIENT executate
so it works?
SERVER RECEIVE WHEN ASKS AND SEND coordinates
CLIENT DRAW tile map with coordinates
CLIENT SEND ' asks for objects in tilemap coordinates'
SERVER RECEIVE WHEN ASKS AND SEND objects attr.., coordinates, etc..
CLIENT DRAW objects with attr.., coordinates, etc.. RECEIVED
same to players online...
PLAYER SEND 'moveUP' to server
SERVER RECEIVE, validate (colisions/events) and SEND awser
CLIENT executate
so it works?
Re: MULTIPLAYER ONLINE GAME - how to do?
The topic of highly scalable networking systems is a huge one.
We will not be able to explain it here. There are lots of options and possibilities for how to setup your game and networking. And they all depend on you knowing what you will be creating and knowing the options themselves.
We can without any issue explain and discuss specific techniques or issues. Like when to use reliable replication or how to prevent user input from showing up so late (in a networked game if you request coordinates from the server there will always be a delay of ping * 2)
But for a general "how to make mmo networking"... well. That requires enough knowledge to fill up a semester or so.
Certainly beyond the scope of a support forum.
We will not be able to explain it here. There are lots of options and possibilities for how to setup your game and networking. And they all depend on you knowing what you will be creating and knowing the options themselves.
We can without any issue explain and discuss specific techniques or issues. Like when to use reliable replication or how to prevent user input from showing up so late (in a networked game if you request coordinates from the server there will always be a delay of ping * 2)
But for a general "how to make mmo networking"... well. That requires enough knowledge to fill up a semester or so.
Certainly beyond the scope of a support forum.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: MULTIPLAYER ONLINE GAME - how to do?
I can give some further pointers though, but it may be in vain in terms of your deadline;
From my experience with Lineage II (private servers, before the game went free2play i mean), i can state a few things:
- Have your server be authoritative, that is to say, you only ever send user interaction data to the server from the clients, and that would validate your new positions, effects of actions you did, et cetera; that said, you do need to mimic these actions/effects locally as well, so that the aforementioned ping*2 delay time won't happen to you; it's here where things like keeping a "buffer of past states" get important, that you need to check against, and modify the local attributes of the world/characters if something's off from what the server says.
- You should chunk your world, if necessary; Big worlds take a long time to load, take up large amounts of space in RAM (both on the server and on the clients), so you should limit processing to areas where users are currently in, unless you need to keep updating things everywhere for sake of realism or similar. (and even then, it doesn't hurt to not have just one gigantic file/table loaded in)
- For very big games, using some kind of database system (like a flavour of SQL) might come in handy, although this step is really REALLY at the end of the "tried to optimize everything" path.
- By default, both server and client should have the whole dataset available to it (or at least the initial ones on release, i'm not counting downloadable new content); maps, items, monsters, everything.
- Chances are, you will need to use other threads for processing network events (and possibly local ones too), otherwise your game will block too much for it to be playable.
- How you code the events is completely up to you; your example above seems workable, although the client should have already locally executed the "moveUP" event, so you wouldn't need to wait for the server's response, since usually it'd agree with such a move; as i said before, you'd need to keep track of previously sent events, and only remove those from a buffer, when the server acknowledged or rejected those; in the latter case, rewinding the local state back to the last event the server accepted.
In short, it's complicated.
From my experience with Lineage II (private servers, before the game went free2play i mean), i can state a few things:
- Have your server be authoritative, that is to say, you only ever send user interaction data to the server from the clients, and that would validate your new positions, effects of actions you did, et cetera; that said, you do need to mimic these actions/effects locally as well, so that the aforementioned ping*2 delay time won't happen to you; it's here where things like keeping a "buffer of past states" get important, that you need to check against, and modify the local attributes of the world/characters if something's off from what the server says.
- You should chunk your world, if necessary; Big worlds take a long time to load, take up large amounts of space in RAM (both on the server and on the clients), so you should limit processing to areas where users are currently in, unless you need to keep updating things everywhere for sake of realism or similar. (and even then, it doesn't hurt to not have just one gigantic file/table loaded in)
- For very big games, using some kind of database system (like a flavour of SQL) might come in handy, although this step is really REALLY at the end of the "tried to optimize everything" path.
- By default, both server and client should have the whole dataset available to it (or at least the initial ones on release, i'm not counting downloadable new content); maps, items, monsters, everything.
- Chances are, you will need to use other threads for processing network events (and possibly local ones too), otherwise your game will block too much for it to be playable.
- How you code the events is completely up to you; your example above seems workable, although the client should have already locally executed the "moveUP" event, so you wouldn't need to wait for the server's response, since usually it'd agree with such a move; as i said before, you'd need to keep track of previously sent events, and only remove those from a buffer, when the server acknowledged or rejected those; in the latter case, rewinding the local state back to the last event the server accepted.
In short, it's complicated.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: MULTIPLAYER ONLINE GAME - how to do?
Thanks
I'am trying
I'am trying
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 9 guests