GithubHelp home page GithubHelp logo

ilarikuoppala / onlinesnake Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 2.0 15 KB

Let's have some online snake fun!

Home Page: https://onlinesnake.fun

Python 53.90% JavaScript 29.08% HTML 7.80% CSS 7.36% Dockerfile 1.85%
game game-server html5-game websocket-application websocket-server python3

onlinesnake's Introduction

OnlineSnake.fun

OnlineSnake.fun is a small fun multiplayer browser game.

Background

This project was started when I was volunteering at the Junction 2018. I wanted to try out real-time web programming with websockets and decided to make a simple game. This is the result.

Development setup

Docker container

In project repository, run docker-compose up. After the container is ready, navigate to localhost:8080 using your web browser. If you make changes to web files (client), refresh the web page to see the effect. If you change server files (python), rebuild (docker-compose build) and restart the docker container to see changes.

Without Docker

In project repository execute following commands (for Windows setup or additional information about using venv, see https://docs.python.org/3/library/venv.html):

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 snake.py

You should now have the websocket backend running. Next, use your text editor to change the websocket port from web/game.js: change line var wsurl = "ws://localhost:8080/websocket/"; to var wsurl = "ws://localhost:8765/websocket/";. Make sure not to commit this port change accidentally! Now open the index.html page with your browser, no setup for web server needed. Similarly to development with docker, refresh the index.html web page when making changes to web files, and restart the snake.py server (use ctrl-c to kill current process) if you change server-side files.

onlinesnake's People

Contributors

felixbade avatar ilarikuoppala avatar samporapeli avatar

Stargazers

 avatar

onlinesnake's Issues

Add theme support

Nice to have:
Ability to change between different themes, e. g. dark mode.

Closing websockets cause error flood in server stdout

Example output:

Traceback (most recent call last):
  File "snake.py", line 14, in receive
    async for message in websocket:
  File "/Users/felix/Documents/onlinesnake/env/lib/python3.7/site-packages/websockets/protocol.py", line 414, in __aiter__
    yield await self.recv()
  File "/Users/felix/Documents/onlinesnake/env/lib/python3.7/site-packages/websockets/protocol.py", line 484, in recv
    await self.ensure_open()
  File "/Users/felix/Documents/onlinesnake/env/lib/python3.7/site-packages/websockets/protocol.py", line 771, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason```

Add style and contribution guidelines

Currently the repository does not contain any guidelines for code style or the goals of the project. These should be added to make life easier for contributors.

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.