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
Historical battle simulation package for Python

Jomini v0.1.4 Jomini creates military simulations by using mathematical combat models. Designed to be helpful for game developers, students, history e

Ümit Kaan Usta 36 Dec 08, 2022
This is an amazing game make using pygame.

This is an awesome balloon game. It is made in python using Pygame library. It is a project game while learning game development.

Rishikesh Kumar 2 Oct 10, 2021
My first Minecraft CPU. Created in collaboration with Peer Carnes as a final project in CS 281: Architecture and Assembly at the University of Puget Sound

Minecraft CPU This is my first ever Minecraft CPU, created in collaboration with Peer Carnes. We created a custom assembly language, including an asse

Andy Chamberlain 4 Oct 10, 2022
This is a python bot to automate BombCrypto game

This is a python bot to automate BombCrypto game. Logs in to the game, reconnects when needed, closes error warnings, sends heroes to work or home automatically, has Telegram integration and lets you

AFKAPP 39 Sep 28, 2022
Just a simple Tic Tac Toe game, built with Python

TicTacToe Author: Gabriel Lima Table of Contents About Getting Started Linux Windows About This is one of the first projects I built when I first star

1 Nov 28, 2021
Open source Board Games Like Tic Tac Toe, Connect 4, Ludo, Snakes and Ladder etc...

Board-Games What to do... Add Board games like Tic Tac Toe, Connect 4, Ludo, Snakes and Ladder etc... How to do... Fork the repo Clone the repo git cl

Bit By Bit 1 Oct 10, 2022
Flappy Bird clone in Python using Pyglet

python_Flappy-Bird This is the Game Flappy Bird which was originally developt by Dong Nguyen under .Gears recreated in Python. Requirements (used to d

Konstantin Opora 1 Dec 10, 2021
The Turtle Race Game built in Python with Turtle module.

Turtle Race Game The Turtle Race Game built in Python with Turtle module. Installation If you don't have Turtle module on your computer. You can downl

Aytaç Kaşoğlu 1 Nov 09, 2021
16-bit PvP platform minigame made for a final high-school project

16-bit PvP platform minigame made for a final high-school project

Flavien 1 Feb 10, 2022
Battle of Saiyans: Goku v Vegeta is a 1 v 1, (Player vs CPU) 2D Martial arts fighting game

Battle of Saiyans: Goku v Vegeta is a 1 v 1, (Player vs CPU) 2D Martial arts fighting game inspired by the popular anime series Dragon Ball Z The game

ARZ 3 Feb 16, 2022
PyChess - a chess client for Linux/Windows

PyChess - a free chess client for Linux/Windows The mission of PyChess is to create a free, pleasant, PyGObject based chess game for the Linux desktop

559 Dec 28, 2022
Flappy Bird hack using Deep Reinforcement Learning (Deep Q-learning).

Using Deep Q-Network to Learn How To Play Flappy Bird 7 mins version: DQN for flappy bird Overview This project follows the description of the Deep Q

Yen-Chen Lin 6.4k Dec 30, 2022
Tic Tac Toe game developed in python; have 2 difficulty levels

Tic Tac Toe Game This is a code for Tic Tac Toe game in python. Game has 2 difficulty levels. Easy Hard To play the game, use this command in a LINUX

Akshat Mittal 1 Jun 25, 2022
Meu primeiro jogo desenvolvido em Python, usado o módulo do Pygame

📖 Sobre Esse repositório é dedicado ao meu primeiro jogo feito em Python, utilizando o módulo do pygame. O jogo foi desenvolvido seguindo o tutorial

Michael Douglas 0 May 06, 2022
A Neural Network based chess engine and GUI made with Python and Tensorflow/Keras.

Haxaw-Chess Haxaw: Haxaw is the Neural Network based chess engine made with Python and Tensorflow/Keras. Also uses the python-chess library. (WIP: Imp

Sarthak Bharadwaj 8 Dec 10, 2022
This repository contains the Unix Game challenges and metadata

This repository contains the Unix Game challenges and metadata

Nokia 7 Apr 06, 2022
Just to play with my kids: create a secret alphabet and exchange encrypted messages

Secret Alphabet Description This project allows you to randomly generate an alphabet (a set of characters) and its corresponding translation. For the

BS 1 Nov 12, 2021
TetrisAI - Tetris AI Bot using computer vision to play game automatically

Tetris AI Tetris AI Bot using computer vision to play game automatically bot.py

11 Aug 29, 2022
Box - a world simulator written in python with pygame

Box is a world simulator written in python with pygame. Features A world generation system A world editor Simulates creatures called boxlanders. You c

1up Community 3 Nov 14, 2022
Chess GUI

Lucas Chess Lucas Chess is a GUI of chess: To learn to play chess. To play chess against engines. Dependencies Python 2.7 PyQt4 PyAudio psutil Python

Lucas 322 Dec 20, 2022