Giter Site home page Giter Site logo

hysbakstryd's Introduction

hysbakstryd

A multiplayer elevator battle game. The name is a combination of two africaans word, namely hysbak which stands for elevator and stryd that means battle.

How to run the headless server

On Ubuntu / Linux Mint you need to install libffi-dev before you install bcrypt. Run the following commands:

sudo apt-get install libffi-dev
virtualenv env -p python3;
. env/bin/activate
pip install bcrypt msgpack-python
python run.py

Packets

Login

send

{
    "type": "connect",       # str, required
    "username": "Hans",      # str, required
    "password": "gehaim",    # str, required
}

Shout

{
    "type": "shout",         # str, required
    ... # all you want
}

returns

 ("RESHOUT", "username", {... # all you want})

set level

{
    "type": "set_level",         # str, required
    "level": 0                   # int [0..9], required, add a level where the elevator should halt
}

set direction

{
    "type": "set_direction",         # str, required
    "direction": 0                   # str ("up", "down"), required, sets the direction of the elevator
}

Design choices

    +-------+                      +------------+
    | Game  |                      |            |
    |ClientA<-----------------+----+  Game      |
    +---+-^-+                 |    |  Instance  |
        | |                   |    |            |
        | |       +-------+   |    |            |
        | |       | Game  |   |    |            |
        | |       |ClientB<---+    |            |
        | |       +---+-^-+        +------^-----+
        | |           | |                 | Instanciate
        | |           | |                 |  / Reload
        | |           | |          +------+-----+
        | |           | |          |            |
        | |           | |          |  NetServer |
        | |           | |          |            |
        | |       +---v-+-+        +-+----------+
        | |       | Net   |          |
        | |       |ClientB<----------+
        | |       +-------+          |
    +---v-+-+                        |
    | Net   |                        |
    |ClientA<------------------------+
    +-------+

To make rapid development possible, I split the network communication part strictly from the game logic. After the NetServer (hysbakstryd.network.Server) is started, the GameInstance (hysbakstryd.game.Game) is spawned. After a successful connect to the server, a new NetClient (hysbakstryd.network.Client) is created, it will register to the game and a new GameClient is created. If the network connection from the client drops, it can reconnect with the same credentials to regain access to the coresponding game client. The client can disconnect / reconnect at any time without obstruct the server. At the same time, the network server is checking the filesystem if the code of the game (hysbakstryd.game.py) has changed, and will hot reload the code in a way that no connection will be dropped.

License

This code is licensed under GNU GENERAL PUBLIC LICENSE Version 2. See LICENSE for further information.

Misc.

Thanks asciiflow for their super easy, ascii chart generator.

hysbakstryd's People

Contributors

hwmrocker avatar spielmannj avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.