Python game engine for 2D multiplayer online games.

Overview

LAN-Caster

The goal of LAN-Caster is to provide an easy-to-use code base (game engine) for developing 2D multiplayer online games. LAN-Caster originally only supported Local Area Networks (LAN) but now also has experimental support for Wide Area Networks (WAN), also known as the Internet.

How To Run

Prerequisites

The following items need to be installed to run LAN-Caster.

Python 3.6 or higher

LAN-Caster uses Python 3.6 or higher (tested on python 3.7.3) which can be installed from https://www.python.org/downloads/.

If multiple versions of python are installed, ensure you are running python 3.6+, not python 3.5 or python 2. The examples in this README use the "python" command assuming python 3.6+ is the default. The command "python3" (Linux) or "py -3" (Windows) may be required to force the correct version.

Python Modules

LAN-Caster requires two added python moduels to be installed.

  1. Pygame is used by the clients to open the game window, render graphics, and collect player input.
  2. Msgpack is used to encode and decode messages between the server and clients.

To install pygame and msgpack on Windows use:

py -3 -m pip install pygame msgpack-python

To install pygame and msgpack on Linux use:

pip3 install pygame msgpack-python

Note, if a computer is only running the LAN-Caster server then the pygame module is not required.

LAN-Caster Code

The LAN-Caster code can be cloned with git from: https://github.com/dbakewel/lan-caster.git or downloaded in zip form from: https://github.com/dbakewel/lan-caster/archive/master.zip

Running the Demo

On windows, double click "run-demo.bat" in the root of the LAN-Caster directory.

If this does not work, open a command window (cmd), cd into the directory containing run-demo.bat and type "rundemo.bat".

The rundemo script will start 4 processes on the local computer: 1 server and 3 clients. Normally, each client would run on a different computer and be used by a different player. The run-demo.bat allows one user to move back and forth between all 3 clients and play all the players at once.

Running on Separate Computers

By default LAN-Caster only listens on localhost 127.0.0.1 which does not allow messages to be sent or received between computers. To listen on all network interfaces, and allow messages from other computers, use -ip 0.0.0.0 on server and clients.

Note, if you want to run LAN-Caster across a network then the ports you choose must be open in the OS and network firewalls for two way UDP traffic. By default, LAN-Caster uses ports of 20000 and above but any available UDP ports can be used.

For example:

Assuming:

  • computer 1 has IP address of 192.168.1.10
  • computer 2 has IP address of 192.168.1.11
  • computer 3 has IP address of 192.168.1.22
  • computer 4 has IP address of 192.168.1.33

The server can be run on computer 1 with:

py -3 src/startserver.py -game "demo" -ip 0.0.0.0

The server will listen on 127.0.0.1 and 192.168.1.10

A client can be run on Computer 2, 3, and 4 with:

py -3 src/startclient.py -game "demo" -sip 192.168.1.10

Command Line Help

The server and client allow some customization with command line switches. Use the -h switch to display help. For example:

D:\lan-caster>py src\startserver.py -h
usage: startserver.py [-h] [-game dir] [-register name] [-ch hostname]
                      [-cp port] [-sip ipaddr] [-sp port] [-fps fps]
                      [-busy secs] [-pause secs] [-test] [-verbose] [-debug]

optional arguments:
  -h, --help      show this help message and exit
  -game dir       Directory to load game from (default: demo)
  -register name  Experimental: Register with connector as name (False == do
                  not register) (default: False)
  -ch hostname    Experimental: Connector hostname or IP address (default:
                  lan-caster.net)
  -cp port        Experimental: Connector port number (default: 20000)
  -sip ipaddr     Server IP address (default: 0.0.0.0)
  -sp port        Server port number (default: 20001)
  -fps fps        Target frames per second (aka steps/sec) (default: 30)
  -busy secs      Seconds between logging percent busy (default: 60)
  -pause secs     Duration to pause in seconds before starting server (for
                  testing) (default: 0)
  -test           Start server in test mode (default: False)
  -verbose        Print VERBOSE level log messages (default: False)
  -debug          Print DEBUG level log messages (includes -verbose) (default:
                  False)
D:\lan-caster>py src\startclient.py -h
pygame 2.1.2 (SDL 2.0.16, Python 3.6.7)
Hello from the pygame community. https://www.pygame.org/contribute.html
usage: startclient.py [-h] [-game dir] [-player name] [-connect name]
                      [-ch hostname] [-cp port] [-sip ipaddr] [-sp port]
                      [-ip ipaddr] [-p port] [-width width] [-height height]
                      [-fps fps] [-busy secs] [-pause secs] [-verbose]
                      [-debug]

optional arguments:
  -h, --help      show this help message and exit
  -game dir       Directory to load game from (default: demo)
  -player name    Player's name to display in game (default: anonymous)
  -connect name   Experimental: Connect to server using connector. "name" must
                  match server's "-register name" (if False then use -sip and
                  -sp to connect to server) (default: False)
  -ch hostname    Experimental: Connector hostname or IP address (default:
                  lan-caster.net)
  -cp port        Experimental: Connector port number (default: 20000)
  -sip ipaddr     Server IP address (default: 127.0.0.1)
  -sp port        Server port number (default: 20001)
  -ip ipaddr      Client IP address (default: 0.0.0.0)
  -p port         Client port number (client will search for an open port
                  starting with this number.) (default: 20002)
  -width width    Window width (default: 640)
  -height height  Window height (default: 640)
  -fps fps        Target frames per second (default: 30)
  -busy secs      Seconds between logging percent busy (default: 60)
  -pause secs     Duration to pause in seconds before starting client (for
                  testing) (default: 0)
  -verbose        Print VERBOSE level log messages (default: False)
  -debug          Print DEBUG level log messages (includes -verbose) (default:
                  False)

Tutorials

The following videos provide an overview of how to use LAN-Caster to build your own game. Also, see comments in the LAN-Caster code and docs folder.

videos coming soon...

Additional Information

Install Connector Systemd Service on Linux (Experimental)

Assuming lan-caster has been installed under a linux user name 'lan-caster' with home dir '/home/lan-caster'

cd /home/lan-caster/lan-caster/systemd
sudo cp connector.service /lib/systemd/system/
sudo systemctl enable $f
Comments
  • Is it possible to create an outOfBounds for some players, and not others?

    Is it possible to create an outOfBounds for some players, and not others?

    What do you need help with? My group is trying to make a 'base' for players of one team to spawn/respawn on; players from the other team should not be able to walk into this base. How would we make it so the base is outOfBounds to an opposing team? We have a ['team'] attribute for players of both teams in the .json already.

    Thank you so much!

    opened by pahu2353 4
  • Sprites

    Sprites

    Is it possible to hide certain sprites in a layer using something like setLayerVisablitybyName with changes made to it, or is it not possible? Ex. Player 1, Player 2, and Player 3 With advancing dialog, each player's screen shows the same thing, but only player 1 is visible, and player 2,3 is off-screen, with no name tag. With something like "show Player 2" player 1 and 2 is visible, and player 3 is not.

    opened by GaoZe36 3
  • Tileset not working

    Tileset not working

    What do you need help with? Hi there! I'm wondering if there are any restrictions on how tilesets are drawn that might make it so the game cannot run? I'm aware that tiles cannot be rotated, but I was wondering if there were any other restrictions on how tiles are implemented that might break the game? After adding a tile from a certain tileset, it gives me an error... Thank you ! (I've tried to attach an image but I'm not sure if it attached!)

    Capture

    opened by jasminejamjelly 3
  • Textbox special effects

    Textbox special effects

    Greetings,

    I'm wondering if lan-caster comes with any built-in code to add special effects to sprites when they talk? For example, my group wants to add a typewriter effect to player speech, just like this: typewriter-animation-text

    opened by Dason-IsopodOverseer 2
  • Possible spelling error

    Possible spelling error "speachText" in engine/servermap.py under setSpriteSpeechText

    Came across this when reading the code. Line 422 under in engine/servermap.py. Seems to be a minor error as no problems because of this are seen so far.

    opened by Sunery030 1
  • Develop

    Develop

    Description

    Added support for rect to rect collision detection. Sprite now have a collisionType attribute which is 'anchor' by default but can be changed to 'rect'.

    Motivation and Context

    This was done to allow things like the pushing of blocks. The blocks can't overlap other objects.

    Related Issue(s)

    none

    Completeness

    Should be complete.

    Testing

    Created a new map in the enginetest game called test19push, in which blocks have collision type set to 'rect' and the player can push the blocks around.

    opened by dbakewel 0
Releases(v1.0.0)
Owner
Douglas Bakewell
Douglas Bakewell
An algorithm to reach a correlated equilibrium in multiplayer games.

Correlatedpy: a python library for distributed learning of correlated equilibrium in multiplayer strategic games. View Demo · Report Bug · Request Fea

Omar Boufous 2 Feb 1, 2022
A networking library for multiplayer games.

Aerics A networking library for multiplayer games. Getting Started Install Python Open cmd/terminal and type: pip install Aerics Examples Creating a

Yusuf Rençber 3 Jan 4, 2023
Guess Your Card - A Multiplayer Python Game

Guess Your Card - A Multiplayer Python Game This is a guessing card game having two levels - Developed in Python and can be played between two to four

Hammad Ahmed ~ 1 Oct 20, 2021
Blender Game Engine Game Type Templates Logic Bricks (and Python script) based Game Templates for Blender

Blender-Game-Engine-Templates Blender Game Engine Game Type Templates Logic Bric

null 3 Oct 25, 2022
Made with pygame. Multiplayer game using socket module and threading.

Rock Paper Scissor made with python-pygame. Poorly made, as a beginner in programming. Multiplayer with server code and client code provided.

AllenJo 1 Dec 29, 2021
A launcher to launch games from Riot Games under Linux

rito-launcher A launcher to launch games from Riot Games under Linux Requirements: Python 3, with the following pip plugins: 'configparser, pathlib, w

null 6 Mar 7, 2022
Datamining of 15 Days of (free) Games at the Epic Games Store (EGS).

EGS: 15 Days of Games This repository contains Python code to data-mine the 15 Days of (free) Games at the Epic Games Store (EGS). Requirements Instal

Wok 9 Dec 27, 2022
A use of the python MCPI to enhance the multiplayer and singleplayer gameplay.

Morpheus 2.0 A use of the python MCPI to enhance the multiplayer and singleplayer gameplay. To Use: You will need to install the keyboard, pysimplegui

null 11 Oct 11, 2022
Mandaw 2 Mar 1, 2022
Multiplayer 2D shooter made with Pygame

PyTanks This project started as a one day project with two goals: Create a simulated environment with as much logic as possible written in Numpy, to o

Felix Chippendale 1 Nov 7, 2021
A multiplayer RPG Discord bot, where you play as a god.

To run Ensure your Python is up to date, and install packages from requirements.txt Duplicate secrets-template.yaml, and name it secrets.yaml Insert y

null 4 Jan 18, 2022
Lint game data metafiles against GTA5.xsd for Rockstar's game engine (RAGE)

rage-lint Lint RAGE (only GTA5 at the moment) meta/XML files for validity based off of the GTA5.xsd generated from game code. This script accepts a se

GoatGeek 11 Sep 18, 2022
Automates cubemap generation for Source Engine games.

AutoCube Automates cubemap generation for Source Engine games during compile-time. Download: see the release page Installation Using with CompilePal A

null 5 Feb 18, 2022
TwoDMaker (2DMaker) - Simple engine for 2D games making!

TwoDMaker (2DMaker) - Simple engine for 2D games making! Create simple games (or ui) in one hour! About. This is a simple engine for game or gui app c

Ivan Perzhinsky. 1 Jan 3, 2022
To solve games using AI, we will introduce the concept of a game tree followed by minimax algorithm.

To solve games using AI, we will introduce the concept of a game tree followed by minimax algorithm.

Vaibhaw 7 Oct 13, 2022
Launch any Heroic-Games-Launcher game using bash scripts without having to open Heroic.

HeroicBashLauncher Ever wanted to launch your EGS games installed through Heroic Games Launcher directly from the terminal, Lutris or any other fronte

null 288 Dec 27, 2022
source codes for my(small indie game developer) games

My repository for most of my finished && unfinished games Table of Contents Getting Started Prerequisites Installation Usage License Contact Prerequis

Gustavs Jākobsons 1 Jan 30, 2022
Online battleships game on python and JS

Battleships Online battleships game Using websockets to connect to the client. SQLite database for storing account data and game logs (for players top

null 5 Nov 11, 2021
A python-based multi-player online educational game for students to play in a class or club setting.

Kurono (codename: aimmo) Code for Life has been developed by Ocado Technology as a free, open-source project to inspire the next generation of compute

Ocado Technology 108 Nov 7, 2022