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
This is a simple tic tac toe game that runs in the command line.

Tic Tac Toe Game This is a simple tic tac toe game that runs in the command line. Game Description: The game is made up of a square grid with 9 portio

Josias Aurel 2 Nov 12, 2022
A chess engine with basic AI capabilities (search for best move using MinMax algorithm)

A chess engine with basic AI capabilities (search for best move using MinMax algorithm)

Ken Wu 1 Feb 02, 2022
Bingo game with python

bingo-game-with-python type of plays possible player vs computer player vs player computer vs computer game is built with 4 objects classes 1.game 2.b

1 Nov 27, 2021
A full featured game of falling pieces using python's pygame library.

A full featured game of falling shapes using python's pygame library. Key Features • How To Play • Download • Contributing • License Key Features Sing

Giovani Rodriguez 7 Dec 14, 2022
Flappy Bird Game using Pygame in Python

Flappy Bird Game using Pygame in Python Demo Pages Hello dear, hope you are very well! I created Flappy Bird Game using Pygame ( Pygame is a cross-pla

Datt Panchal 3 Feb 05, 2022
AXI Combat is a networked multiplayer game built on the AXI Visualizer 3D engine.

AXI_Combat AXI Combat is a networked multiplayer game built on the AXI Visualizer 3D engine. https://axi.x10.mx/Combat AXI Combat is released under th

. 0 Aug 02, 2022
This a Chess PGN saver which allows you to save your game pgns, in a .pgn file

PGN Saver This a Chess PGN saver which allows you to save your game pgns, in a .pgn file This can be a very useful tool for the people using chessbase

3 Jan 06, 2022
A fun discord bot for music, mini games, admin controls, economy, ai chatbot and levelling system

A fun discord bot for music, mini games, admin controls, economy, ai chatbot and levelling system. This bot was specially made for Dspark discord server.

2 Aug 30, 2022
Chesston (Chess+Python) is a two-player chess game with graphical user interface written in PyQt5

♟️ Chesston (Chess+Python) is a two-player chess game with graphical user interface written in PyQt5. 💿 Dependencies This program uses Py

6 May 26, 2022
Space shooter being built for PyWeek 32

Axium Humanity's expansion into space had lasted centuries by the time we encountered the vicious Threx. The Threx adopted a single, religious mission

Daniel Pope 6 Oct 28, 2021
Finding a method to objectively quantify skill expression in games, using reinforcement learning

Analyzing Skill Expression in Games This is a repo where I describe a method to measure the amount of skill expression games have. Table of Contents M

Marcus Chiam 4 Nov 19, 2022
AutoPilot is a game where the player controls a car and tries to get the highest score he can while not dying under falling cement blocks.

AutoPilot AutoPilot is a game where the player controls a car and tries to get the highest score he can while not dying under falling cement blocks. C

Enoc Mena 1 Nov 17, 2021
Snake Game in Python

Snake game is one of the most popular arcade games of all time. In this game, the main objective of the player is to catch the maximum number of fruits without hitting the wall or itself.

Pavan Ananth Sharma 4 Jul 05, 2022
Magic: The Gathering Arena draft tool that utilizes 17Lands data

MTGA_Draft_17Lands Magic: The Gathering Arena draft tool that utilizes 17Lands data. Steps for Windows Step 1: Download and unzip the MTGA_Draft_17Lan

41 Dec 31, 2022
DOTD - A murder mystery game made in Python

DOTD This repo holds the files for my video game project from ENG101, Disaster o

Ben Bruzewski 1 Jan 13, 2022
Utility.py - a utility that offerres cool cli tools and games.

Utilty.py Utility.py is a utility that offerres cool cli tools and games. Currently the offerd games/items are: get the number, countdown, random name

bee-micizi 1 Dec 08, 2021
Open source Brawl Stars server emulator for version 29 of the game!

Welcome to Classic-Brawl v29 Remake 👋 Open source Brawl Stars server emulator for version 29 of the game! (Remake) What's working ? Battles Trophies

CrossFire 4 Jan 19, 2022
Ice-Walker-Game - This repository is about the Ice Walker game made in Python.

Ice-Walker-Game Ce dépot contient le jeu Ice Walker programmé en Python. Les différentes grilles du jeu sont contenues dans le sous-dossier datas. Vou

Mohamed Amine SABIL 1 Jan 02, 2022
Follow the numbers - A simple game where the player should follow the numbers and connect the dots

follow_the_numbers This is a simple game where the player should follow the numb

Sammy Mishinev 3 Nov 22, 2022
Quiz game made entirely with python and pygame for school work

Tabela de conteúdo Descrição Como instalar Linguagens usadas Contribuidores Créditos Problemas com o jogo? Contate-nos Descrição Quiz feito inteiramen

3 Apr 12, 2022