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
For the Exapunk minigame, ПАСЬЯНС

Exapunks Automation This repository solves Exapunk's Solitaire minigame, ПАСЬЯНС. This repository is useable, but only with specific display condition

Will C 5 Jul 29, 2022
General Crossy Road Game using Python code

Python-Game General Crossy Road Game using Python code Using code such as function and while using turtle, I was able to recreate a beginner version o

Jacob Paquette 1 Dec 19, 2021
A very simple 3D maze game with ray tracing.

PytracingMaze MOST RECENT VERSION: Pytracing Maze.py Also, executable for Windows available on itch.io Simple ray tracing game in Python, based on my

FinFET 15 Dec 20, 2022
A Cataclysm: Dark Days Ahead launcher with additional features

CDDA Game Launcher A Cataclysm: Dark Days Ahead launcher with additional features. Download here. Implemented features Launching the game Detecting th

Rémy Roy 402 Jan 02, 2023
2d war game single player

WarGame-third-version-0.0.4- 2d war game single player Hi ! Today, I publish on GitHub the version 0.0.4 of "WarGame". In this version, you can find a

Edouard Vincent 2 Apr 08, 2022
It just a cli based snake game written in Python.

Snake Game in Python Things that I learned in this project: OOP in Python. Clean code. The curses library. How to run the game You need to clone this

Kevin Marques 7 Oct 01, 2022
This is a simple Tic-Tac-Toe game.

Tic-Tac-Toe Nosso famoso e tradicional Jogo da Velha, mas agora em Python. Development setup Para rodar o programa, basta instalar python em sua maqui

João Assalim 1 Oct 10, 2022
Simulate a Monopoly game to generate the probabilities of landing on each square.

Monopoly-Probabilities Simulate a Monopoly game to generate the probabilities of landing on each square. While this project originally was inspired by

George Waters 2 Jan 04, 2023
Trio Assembly Snakemake Workflow

Trio Assembly Snakemake Workflow Input HiFi reads for child in bam format Either

Juniper A. Lake 1 Jan 28, 2022
Python fitting assistant, cross-platform fitting tool for EVE Online

pyfa What is it? Pyfa, short for python fitting assistant, allows you to create, experiment with, and save ship fittings without being in game. Open s

1.4k Dec 22, 2022
A sprite ripper and converter for Com2uS' 2007 game Music World.

Music World Sprite Dumper This repository contains a python script reads an UNCOMPRESSED Music World pxo file and attempts to dump sprites from it. Th

Buu342 1 Mar 16, 2022
PLVRA is a TUI (Terminal User Interface) implementation of wordle / termo in portuguese, written in Python

PLVRA is a TUI (Terminal User Interface) implementation of wordle / termo in portuguese, written in Python

Enzo Shiraishi 1 Feb 11, 2022
Jiminy, fast and portable Python/C++ simulator of poly-articulated systems with OpenAI Gym interface for reinforcement learning.

Jiminy is a fast and portable cross-platform open-source simulator for poly-articulated systems. It was built with two ideas in mind: provide a fast y

Alexis DUBURCQ 122 Dec 29, 2022
Inject custom C++ code into GameMaker Studio 2 YYC builds

YYC Boost Inject custom C++ code into GameMaker Studio 2 YYC builds! WARNING: This tool is currently in an early stage of development and it is not gu

Patrik Kraif 7 Dec 30, 2022
PYGA: Python Google Analytics (ga.js) - Data Collection API

PYGA: Python Google Analytics - Data Collection API pyga is an implementation of Google Analytics (ga.js) in Python; so that it can be used at server

Arun Karunagath 136 Sep 19, 2022
🐍 Conway's Game of Life cellular automaton implemented in PyGame

Conway's Game of Life My PyGame implementation of Conway's Game of Life. This implementation involves treating all edges of the grid as stitched toget

Mateusz Żebrak 1 May 29, 2022
Just a copied of flappy bird game made by Thuongton999

flappy-bird Just a copied of flappy bird game made by Thuongton999 Installation and Usage Using terminal (on Window) Make sure you installed Python an

ThuongTon 9 Aug 08, 2021
This is game 2048 created with moudle of python tkinter and OOP.

Game 2048 This is game 2048 created with moudle of python tkinter and OOP. This game build on classes. For start this game run: If you have python ver

0 Nov 02, 2021
We tried to recreate this classic game using python physics libraries.

We tried to recreate this classic game using python physics libraries. The result is certainly hilarious but enjoyable. One of my very first physics application.

Delwys Glokpor 2 Dec 12, 2021
Stock game is a python program that simulates real-life stock marketing, saving, and investments

Stock game is a python program that simulates real-life stock marketing, saving, and investments. Users get to trade and manage their portfolio and manage their 100,000 dollar portfolio.

Sai Praneth Raju K. 1 Jul 14, 2022