Async Multiplayer Stub

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
andrewyu
Prole
Posts: 1
Joined: Sun May 15, 2022 11:38 am
Contact:

Async Multiplayer Stub

Post by andrewyu »

I was starting to work on my fork of a PyGame multiplayer stub program (a program that you may extend into an actual multiplayer game, which in my case would be (irrelevantly) an detective game similar to the popular Among Us game but is free software and hopefully more flexible) hosted at git://git.andrewyu.org/pygame-multiplayer.git. Discussion with some people from #libregamenight on LiberaChat convinced me to use LÖVE as Lua tables are in my opinion easier to handle than Python dataclasses.dataclass and LÖVE has a cleaner programming interface.

The goal is to be able to scalably have players see each other move with a reasonably low amount of latency and minimal overhead. Both 'every player connects to a non-playing server' and 'every player connects to a host's game' are acceptable, though the former is preferred as this ensures that no player has special permissions over the game's movement traffic, which makes future anti-cheat extensions easier.

I have used Lua before, mainly in general playing-around and Minetest modhacking. However, I have no experience with concurrency and networking in Lua. Though it is likely that I will eventually dive into these topics, I am looking for an example program that fulfills part or all of what I described as it may vastly speed up my learning process and can speed up the development of the actual game.
User avatar
togFox
Party member
Posts: 770
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Async Multiplayer Stub

Post by togFox »

I'll volunteer this project:
https://github.com/togfoxy/Mars-Lander-reboot

I taught myself the networking bits so may not be the most elegant but it is in LOVE and has LAN option.

Love 11.3 btw
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Async Multiplayer Stub

Post by zorg »

For concurrency, you either have coroutines, which are pre-empted on the same OS thread since it's lua's own thing, or, with löve specifically, you can also use Threads which are actual parallel os threads.
Me and my stuff :3True 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.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: Async Multiplayer Stub

Post by pgimeno »

Not sure if that usage of "pre-empted" was right, but basically, coroutines are manual task switches, with some similarity to Python generators, where all tasks work on a shared Lua environment, while Löve threads are OS threads that run each in its own Lua environment, and it's not so easy to share data between them.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Async Multiplayer Stub

Post by zorg »

pgimeno wrote: Sun May 15, 2022 7:27 pm Not sure if that usage of "pre-empted" was right, but basically, coroutines are manual task switches, with some similarity to Python generators, where all tasks work on a shared Lua environment, while Löve threads are OS threads that run each in its own Lua environment, and it's not so easy to share data between them.
Maybe not, though i did want to just point out that coroutines are not exactly executed in paralell; they're still running on the same cpu core.
löve threads can be due to the OS' scheduler may run them on different cpu cores/threads.
Me and my stuff :3True 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests