Skip to main content

A networking library for multiplayer games.

Project description

Aerics

A networking library for multiplayer games.

Getting Started

  1. Install Python
  2. Open cmd/terminal and type:
pip install Aerics

Examples

Creating a server

from aerics import *

server = Server("localhost", 5656)

@server.event
def setup():
    pass

@server.event
def update():
    pass

@server.event
def on_connection(connection, address, id, clients, globals):
    print("New connection")

    return {"x" : 0, "y" : 0}

@server.event
def on_disconnection(connection, address, id, clients, globals):
    print(f"Client {id} disconnected")

@server.event
def on_recv(connection, address, id, clients, globals, data):
    data = data.split(",")

    if data[0] == "move":
        clients[id]["x"], clients[id]["y"] = data[1], data[2]
        return clients

    if data[0] == "close":
        server.disconnect(connection)
        return None

server.listen()

Creating a client

from aerforge import *
from aerics import *

def update():
    client.send(f"move,{player.x},{player.y}")
    players = client.recv()

    for i in players:
        forge.draw(width = 50, height = 100, x = int(players[i]["x"]), y = int(players[i]["y"]))

if __name__ == "__main__":
    forge = Forge()
    
    client = Client("localhost", 5656)
    client.connect()

    player = prefabs.TopViewController(forge)
    player.visible = False

    forge.run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aerics-0.0.3.tar.gz (3.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page