Lwjgl/Slick2D,Canvas,Webkit,IvanK/WebGL,Swing/Awt

I couldn't make it to WWX this year due to passport taken.
Was hoping to talk about abstracting graphics with some Java/JS graphics, but since I was unable to talk I have uploaded a little experiment for people to play with, you can easily view it here.

https://rawgit.com/Justinfront/wwx2014_justinfront/master/deployCanvas/bouncingLogo.html

There are 5 versions/flavours that work the same and use the same "ball" class, you can drag the Haxe Icon round the screen and use arrow keys to move it, and space for jump, it's shows how you might build a simple interaction from scratch (without physics engines) and targets multiple haxe targets, I am yet to add flambe and openfl/flash/nme examples, as I was more interested to explore less well trodden paths.  All the physics is simple stuff, see the Ball class full of comments that should be easy to follow.

https://github.com/Justinfront/wwx2014_justinfront/blob/master/src/simplephysics/Ball.hx

It uses another class of weighted averages for the velocity when you stop dragging, no idea if this is ideal approach but it works fine, so you can throw the logo and bounce off the walls, it includes some code to clean up edge case where behaviour would be anoying if not tweaked, this is the sort of code you could extend for a simple game or an interaction.

The targets are

1) Java OpenGL
Lwjgl + Slick2D uses an Image class for simplicity, I looked at other approaches but the image class is ideal for powerful quick graphics and slick2d is a really amazing library that complements lwjgl, the example use  -jar-lib for the Lwjgl wrapper and Slick2D externs.

2) Java Swing/awt
Uses out of the box haxe Java very easy to setup and use, for this example it seems to run a similar speed to 1) but suspect it is slower for more complex examples.

3) JS Canvas
Uses Javascript Canvas

4) Node-Webkit
Same as 3) but uses the node-webkit.app so the only difference is in the hxml file

5) WebGL IvanK JS
After experimenting with WebGL I decided like most things aimed to replace flash it was a complete nightmare, I got code for setup working but then getting the logo in a nice box... meh what crazyness, sure it's possible in haxe js but not fun.  But I came accross this wonderful library that emulates the Flash API but creates Webgl called IvanK and found some haxe externs that were mostly working. Anyway seem to have a small footprint and runs fast and is very easy and simple to use, I have sort of mix and matched the approach with 3) and unfortunately you can view it using gitraw but works fine local host I am unsure why maybe an image loading issue related to github setup, the loader.addEventListener( Event.COMPLETE, ... was not working which also did not help.

Hopefully these experiments will push you to explore Haxe graphically and to look more at coding JS and Java Haxe, currently the hxml are setup for a mac user but should be easy to amend.  Any thoughts or changes or additions, the idea it to create something complex enough to be useful but also simple enough to follow.  It could probably do with some font in the project.

#Java #lwjgl #Javascript #swing #canvas #node -webkit
Shared publiclyView activity