Pyjsdl Demo Apps

The apps on this page were coded in Python and Pygame. They were derived from the Pygame examples included in Pygame distribution. The first app is the Chimp example that is also used in a Pygame tutorial.

Chimp



The next app is derived from the Aliens script included with the Pygame examples in Pygame distribution.

Aliens



The final app is derived from the Stars script also included with the Pygame examples in Pygame distribution.

Stars



The Pygame examples were deployed as JavaScript apps using the Pyjs compiler and the Pyjsdl library. Minor modification of the script is required, a demo pack of the modified scripts for these Pygame examples can be downloaded to demonstrate the changes required.

PyJ2D and Pyjsdl libraries were developed with the goal to provide enhanced deployment methods for Pygame apps. The libraries replace Pygame functionality in target environments, PyJ2D for the Java environment and Pyjsdl for the JavaScript environment. The demo pack includes modified Pygame examples for both these libraries.

PyJ2D was the pioneer project to run Pygame apps with Jython in the Java VM. The script requires minor modifications to work with PyJ2D. Unsigned apps can run in earlier versions of the Java VM browser plugin, but security changes with the current version of the Java VM plugin the apps need to be officially signed, which makes this procedure less convenient. PyJ2D permits distribution as a single cross-platform package for systems with Java VM installed.

Pyjsdl permits compilation of the Pygame script using Pyjs. The Pygame script needs minor modifications to work with Pyjsdl, though a little more extensive compared with PyJ2D. Since Pyjsdl was developed from PyJ2D and share similar functionality, with greater ease in development with Jython than Pyjs that requires compilation and execution in the browser, it is easier to initially modify a Pygame script to function with PyJ2D prior to the additional modifications required for Pyjsdl. The modified scripts for these examples are provided to demonstrate the changes required, instructions to run the modified scripts are included in the demo pack. Check PyJ2D and Pyjsdl project pages for further information regarding the methods.

Scripts modified to function with PyJ2D are included in the demo pack within the PyJ2D demo folder. To run the examples on a system with Java VM installed, download Jython installation package, or as a Jython standalone interpreter that can be placed on the path or within the script folder, the PyJ2D examples can use Jython 2.2.1 or later. Download PyJ2D and unpack on the path or within the script folder. To run the Chimp script, use the command ‘java -jar jython.jar chimp.py’, or if Jython was installed use the command ‘jython chimp.py’. These modified example scripts can also run with Python2.7 and Pygame. A single script package with Jython and PyJ2D can be created to distribute on any systems with Java VM installed.

Scripts modified to function with Pyjsdl are included in the demo pack within the Pyjsdl demo folder. To compile the example scripts, the Pyjs compiler needs to be installed from the Pyjs source on Github, follow installation instructions on the Pyjs Github site and on the Pyjsdl project page. Download Pyjsdl and unpacked on the path or within the script folder. Pyjs has two compilation modes, strict for closer adherence to Python, and optimise for minor restriction of certain Python constructs for increased performance. For the optimise mode, the script modified for strict mode requires additional modifications. The example scripts modified for these modes are included. To compile the Chimp script with Pyjs in strict mode, use the command ‘[pyjs folder]/pyjsbuild -S chimp-strict.py –dynamic-link -o outputdir1’. The example scripts modified for strict mode are able to also run with Python2.7 and Pygame. To compile the Chimp script with Pyjs in optimise mode, use the command ‘[pyjs folder]/pyjsbuild -O chimp.py –dynamic-link -o outputdir2’. The output folder has the JavaScript app, and can be tested locally from the main HTML file, then deployed to a server to run on the Web.

Updated: 2021/04/30 – revised demo pack

This entry was posted in Programming and tagged , , , , , , , . Bookmark the permalink. Trackbacks are closed, but you can post a comment.

2 Comments

  1. Drew Ronsman
    Posted 2022/02/19 at 10:58 | Permalink

    Do yall have a tutorial

    Reply

Post a Reply to Drew Ronsman Cancel reply

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*
*