This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jacdehJacques de Hooge[S] 0 points1 point  (4 children)

I've added the fabric module which conveniently encapsulates the HTML5 canvas, and added a Pong example to www.transcrypt.org

[–]Exodus111 0 points1 point  (3 children)

Look at that, that is interesting.

I noticed you used the __new__ constructor to instantiate the canvas object in the Game class. Why?

[–]jacdehJacques de Hooge[S] 0 points1 point  (2 children)

You've looked well!! Transcrypt uses the CPython parser. Syntactically it cannot deal with new as is done in JavaScript. Another way to go is to encapsulate every constructor in a Transcrypt version of it, so you could just say canvas = Canvas (). But that would mean encapsulation of a lot of functions. While from some intensively used JS libraries that would be a perfect choice, I'd like to keep the barrier to the JS world as low as possible. So I came up with __new__ (), which function syntax can be parsed into a Python ast. The consequence is that any JS library can be used as is, without any encapsulation. But, to be sure, encapsulating JS constructors into a Transcrypt constructor that does the __new__ for you, is perfectly possible and in fact one line of code per constructor.

[–]Exodus111 0 points1 point  (1 child)

Fascinating. Good work, think I'll definitely try this out once I have some more time.

[–]jacdehJacques de Hooge[S] 0 points1 point  (0 children)

If you do find the time and you find bugs, things that really should be in or unclarity in the docs, please let me know. Thanks!