Giter VIP home page Giter VIP logo

pytime's Introduction

PyTime

This is a simple 2-player RTS game based on pygame.

We haven't released the game yet. You have to pull or download the source code and run it in required python environment. Stability is not guaranteed.

Run

To run the game on Windows 10, enter the root folder and run in command line:

python main.py

To test the game, enter the root folder and run in command:

python test.py

(for now the test won't give much helpful information to players, I mean, people who are not developers of the game. But we may make it more useful in the future.)

Play

There are two characters available in the game. Both of them can move and attack by keyboard input.

player A: moves by arrow keys, attacks by backslash

player B: moves by WASD, attacks by space

Requirements

  • OS

    • The game is developed on Windows 10. We haven't tested the game on other types of OS. If you encounter problems that are probably related to OS, it would be helpful to report it in issue, but due to our limited conditions for development, there's no guarantee that we'll be able to fix them.
  • Python

    • The game is developed with Python 3.7.4, and we are not planning to support Python 2. So make sure you are running the game with at least a Python 3.
    • We haven't tested the game in other versions of python 3 environment. If you use a different version and encounter problems that are probably related to python itself, please report it in the issue.

Python Package requirements:

pygame==1.9.6

Credit

deemolover

TDL9

License

We use an MIT License. Check the LICENSE file for detail.

pytime's People

Contributors

xiaoxiaoyumiao avatar

Watchers

James Cloos avatar  avatar

pytime's Issues

Rewrite low-level calculation with numpy

Use of matrix calculation may improve performance when the number of particles is getting larger.

  • replace Vec2d with numpy vector

  • rewrite ParticleGroup to support calculation of physical state iteration in batches

  • change the way particle history data is stored in ParticleContainers

Play online

Support battle online through frame synchronization algorithm.

  • rewrite all value calculation using fixed-point numbers

  • synchronize event input at every logic frame

  • bridge terminals with sockets

Deepen the buffer of ParticleContainers

Now the buffer is maintained with simple lists of data from different moments. Several ways to improve:

  • set up a sample rate, like 1 sampling for every 10 frames

  • compress the history data using more complicated(and efficient) data structure

Reduce the rendering cost

Now the layer rendering uses a lot of surface blitting to another surface (and most of them are of screen size, which means the blitting will be time consuming). Here are some possible ways to improve:

  • register callback rendering functions to the LayerManager and let LayerManager to determine whether, when and where to render.

Currently renderers acquire surfaces they need from the LayerManager and do whatever they want. Then LayerManager just piles up surfaces from different layers and renders them to provided screen. The problem is: to ensure rendering of different layers won't mix up, LayerManager needs to maintain different surfaces so as to provide them to objects using different layers. But piling up surfaces of screen size costs a lot of time.

  • maintain dirty rects to reduce time cost of screen.update()

Updating the whole screen is quite time-consuming. Pygame supports partial update, that is, update pixels only in specified regions (rectangles, actually). One possible way to implement this is to leave this work to renderers. Renderers are responsible for maintaining all regions they modify in a frame, and provide them to the LayerManager (as returning value of callback rendering functions, for instance). In this way the LayerManager will know where to update when it's rendering the screen.

Judge the game

Implement the logic to monitor and decide who is the winner. Now the number of particles owned by a player can be queried through the ParticleManager(statistics).

UI

make game interface more friendly with buttons, texts and bars

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.