Code Monkey home page Code Monkey logo

codegame's Introduction

Usage

web server

  1. virtualenv venv
  2. source ./venv/bin/activate
  3. pip install -r requirements.txt
  4. export FLASK_APP=codegame.py
  5. flask db init
  6. flask db migrate
  7. flask db upgrade
  8. flask run and Running on http://127.0.0.1:5000/

game server

  1. cd gameserver
  2. virtualenv venv
  3. source ./venv/bin/activate
  4. pip install -r requirements.txt
  5. python server_test.pyand Running on http://127.0.0.1:6005/ (communicate with webserver)
  6. python games/easy/codes/pingpong/gamemain.pyand Running on http://127.0.0.1:8000/ (communicate with players)

Descript

Data flow

玩家上傳程式碼到 gameserver執行

  1. 程式碼由 app/games/routes.py 的 game_view function中,當 commit_form.validate_on_submit(),就build a websocket client: ws = create_connection("ws://localhost:6005")
  2. gameserver這邊由 server_test.py build websocket server接收 玩家程式碼 3. server_test.py 等待兩位玩家都上傳程式碼 4. fork 3 processes to execute 玩家程式碼 和 遊戲程式

玩家進入遊戲畫面、聊天室、遊戲訊息溝通

  1. 由 url: http://localhost:5000/games 輸入要進入的聊天室
  2. Webserver 透過 app/main/events.py 來接收 socket 訊息(聊天室和遊戲物件位置) gi

codegame's People

Contributors

yu-hancheng avatar

Watchers

James Cloos avatar SarahCheng 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.