Coder Social home page Coder Social logo

endless-field's People

Contributors

zhukovsd avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

endless-field's Issues

Canvas animations

Rendering in the JS client based on canvas layers, every independent logical 'layer' (cells or player labels) render separately, which is convenient.

Within this principle, it would be handy to implement animation rendering on layers.

What information describes an animation:

  • Position bound to cells or screen. If position bound to cells, then animation moves on camera scrolling, doesn't moves otherwise
  • Animation value, which represents a stage of animation, shows which portion of its duration has been already completed for the current moment from a start moment. For example, if we animate a full turnover of a second hand in the clocks, then logical value range would be from 0 to 59, and duration is 60 seconds.
  • Rendering function, which renders an animation sprite for the given value. For example, renders the second hand in given position from 0th to 59th second.

An animation layer holds an array of animations.

A global tick timer iterates through all animation layers and their animations, calculates the value for the current moment, renders it and refreshes all animation layers.

Browser window resize support

When browser window size changed, a size of the canvas changes as well. Canvas content gets stretched, breaking the aspect ratio.

Actually, canvas has 2 kinds of sizes, width/height for canvas as UI element, and width/height of its content. When these sizes not matches, aspect ratio breaks.

In order to correctly handle resize, we need to process resize events, and update width/height of canvas content.

When content size gets changed, canvas clears, to it has to be repainted.

If canvas size increases significantly, we might need to request additional chunks from the server. It makes sense to request additional information not on every size change, but only if the size has not changed for some interval, 200 ms, for example.

Field endpoint response to partial scope changing

When a user moves his camera, his scope changes and field manager requests new chunks. During the scrolling, the scope may change only partially, so the user has to receive only new chunks, and there is no need to resend him chunks which he already has.

For example, if user scope = [0, 1], he moves the camera and new scope is [1, 2], the server should only send him chunk with id 2.

So, field endpoint response should look like:

  {
    "responseCode": 0,
    skippedChunks: [
      ids of previously requested chunks
    ],
    chunks: [
      {
        origin, ordered cells array
      },
      < ... >
    ]
  }

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.