Coder Social home page Coder Social logo

pixelscommander / flashjs Goto Github PK

View Code? Open in Web Editor NEW
174.0 174.0 40.0 47.62 MB

JavaScript graphics and games engine with API similar to Flash one. Just look to examples sources.

Home Page: http://pixelscommander.com/polygon/skateboarding/

Java 41.56% JavaScript 54.75% CSS 1.24% HTML 2.44%

flashjs's People

Contributors

pixelscommander avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flashjs's Issues

Choose best way to inform AssetList about assets scale needed

Assets scale is nice feature of FlashJS, but there are few issues connected with this.

Assets are loaded with AssetsLists which is object of AssetList class. Every AssetList have to know what scale to use (what folder to use as loading path). And scale can be obtained from pixelScale property of Stage. And we can have few stages on page.

So first question is - what is the best way to pass scale to AssetLoader? Is it ok to have one AssetsList per Stage? There are no any problems if it is. Every Stage would have AssetLoader with particular pixelScale.

But!

We also need tag for DOM interface and this can be otained with help of global AssetsList. This breaks proposition of one AssetList per Stage!

So there are few questions:

1.Choose best way to inform AssetList about assets scale needed.
2.Propose mechanism for determining source AssetList for tag. Will it be global AssetList?

Implement <asset/> tag

<asset/> tag accept "id" attribute with assetID, then determines URL of this asset in needed scale and then inserts it to page as tag. Also <asset/> tag have to forward all of it`s attributes to tag it produces, so <asset id='logo' width='100%'/> will produce <img src='./assets/2/logo.png' width='100%'/>

For image asset it will produce <img> tag.
For audio asset - <audio> tag.
For animation asset - <img> animated with css animation technique.

Propose mechanism for determining source AssetList for <asset/> tag

Assets scale is nice feature of FlashJS, but there are few issues connected with this.

Assets are loaded with AssetsLists which is object of AssetList class. Every AssetList have to know what scale to use (what folder to use as loading path). And scale can be obtained from pixelScale property of Stage. And we can have few stages on page.

So first question is - what is the best way to pass scale to AssetLoader? Is it ok to have one AssetsList per Stage? There are no any problems if it is. Every Stage would have AssetLoader with particular pixelScale.

But!

We also need tag for DOM interface and this can be otained with help of global AssetsList. This breaks proposition of one AssetList per Stage!

So there are few questions:

1.Choose best way to inform AssetList about assets scale needed.
2.Propose mechanism for determining source AssetList for tag. Will it be global AssetList?

Canvas still empty

I try to accomplish the YAZ-demo, without the fish-sprite (is that even possible?). However the canvas element is still empty. What I'm doing wrong? http://fiddle.jshell.net/pdcBR/

// FlashJS
var stage = new Stage("canvas");
var testObject = new DisplayObject();
testObject.width = 100;
testObject.height = 100;
testObject.x = 0;
testObject.y = 0;
testObject.rotation = 18;
testObject.fillColor = '#f00';

stage.addChild(testObject);

Implement WebGL render

At the moment we have Canvas and DOM renders but we need WebGL one to get maximum perfomance for desktop.

It`s quite easy to use Canvas render as example and develop WebGL analogues of DisplayObject, DisplayList, Stage, SpriteAnimation

Implement initial AssetsList attribute for FlashJS script tag

Very often we need to preload some assets even before page is displayed and any user code is executed.

Probably it`s good idea to implement data-assets attribute for FlashJS script tag like data-main in RequireJS.

It will calculate current scale based on window size and load initial assets.

Event dispatching a-la Flash

Let users to dispatch events in flash manner. Object.dispatchEvent(new Event("type")); At this moment it works only in Chrome and other browsers need jQuery style object.trigger("type");

ActionScript custom tags enhancement

Hi all, I'm opening this issue because I'd like a new feature is implemented into FlashJS, allowing developer to add actionscript bootstrapping in script tag sections. How I imagine the script element is illustrated below.

<script id="actionscript1" type="text/actionscript" data-width="200px" data-height="200px"  data-scaletoscreen="false">
<!-- FlashJS ActionScript code goes here without any worries about xml escaped characters -->
</script>

Please note that I've nothing against the actionscript custom HTML tag, but I feel that these application specific tags find their appropriate usage in web design realm and when you need them to support your web application logic. In most browsers your custom tags will be treated as inline elements like span, this means you have to write CSS to declare rules such as "actionscript { display: none }" at least to prevent unwanted content display when JS is disabled or you page is not processed as expected.

Thus, the ActionScript Tag Executor would be easily adapted for the new pseudo script tag as follow.

var $push = Array.prototype.push;
var tags0 = document.getElementsByTagName('actionscript');
var tags1 = document.getElementsByTagName('script');
var tags  = [];
$push.apply(tags, tags0);
$push.apply(tags, tags1);

for (var i = 0; i < tags.length; i++) {
    var astag = tags[i];

    if (astag.tagName === 'SCRIPT' && 'text/actionscript' !== (astag.type || ''))
        continue;

    var scriptText = replaceAll(astag.innerHTML, "&lt;", '<');
    scriptText = replaceAll(scriptText, "&gt;", '>');
    var width = astag.getAttribute('data-width') || astag.getAttribute('width');
    var height = astag.getAttribute('data-height') || astag.getAttribute('height');
    var scaleToScreen = astag.getAttribute('data-scaleToScreen') || astag.getAttribute('scaleToScreen');
    var canvas = w.document.createElement('canvas');
    canvas.setAttribute('width', width);
    canvas.setAttribute('height', height);
    canvas.id = 'flashjs' + UID();

    // replace existing node astag with the new span element canvas
    //astag.parentNode.appendChild(canvas);
    //astag.parentNode.removeChild(astag);
    astag.parentNode.replaceChild(canvas, astag);

    var stage = new Stage('#' + canvas.id, parseInt(width), parseInt(height));
    //...
    //...
}

I think what is most enticing about this diverse approach is that you don’t have to vary too much the existing code base in order to begin using it.

Best regards, Giorgio Arata.

Add a drawing API

I miss some simple drawing methods like:

  • Arc
  • Ellipse
  • Line
  • Polygon
  • Rectangle
  • Text

Refactor code to use virtual width/height

At the moment we have scale-independant X,Y for objects but their width, height depends on real size of images used.

So for scale 4 it will be 32_32 and for scale 1 it will be 8_8.

It`s not good for game logic development, all game logic have to be independant of scales.

We have to modify DisplayObject code to have 8*8 always, but also implement realWidth and realHeight properties to use for rendering.

scaleX, scaleY properties for DisplayObject

It seems not so easy problem.

First of it have to be done throuth CSS transformations. They are fast enought.
Second - if we have two transformations we have to build a transformations: CSS properties string as space separated list ex. rotate(45deg) scale(1,1) translate(0,0) and it is needed to have some kind of memoisation in it to do manipulations with this string as fast as possible.

Not easy issue.

MovieClip pseudo-class

Add MovieClip constructor that would have TimeLine and corresponding methods.
Large issue have to be started after corresponding investigation.
We have to understand all methods of animation - SVG, GIF, PNG frames.
Also MovieClip have to depends on document FPS.

Getters/setters code clearing

Have to develop utility function like setVeriableGetterSetter(var, getter, setter) and change all this IF stuff with it

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.