--------------------------------------------- JGame Flash - an Actionscript 3 port of JGame Version 1.0, 20110430 --------------------------------------------- By: Boris van Schooten, schooten@cs.utwente.nl License: BSD (see LICENSE) Website: www.13thmonkey.org/~boris/jgame/ JGame Flash uses the hashtable data structure from: AS3 Data Structures for Game Developers (as3ds.swc) Copyright (c) 2007 Michael Baczynski, http://www.polygonal.de See License-as3ds.txt. ----F U N D R A I S E R------------------------------------- Want to support JGame development? DONATE NOW at http://www.13thmonkey.org/~boris/jgame/ ------------------------------------------------------------ Introduction ------------ JGame Flash is an Actionscript 3 / Flex port of the JGame API. It can be compiled with the free Flex toolkit. About 90% of the 3.5 API is implemented right now. A Java-AS3 translator is included for making porting games easier. The goal of this project is to eventually enable Java games to be converted (semi) automatically to Actionscript 3. There is still some work to be done before that goal is met: the Java-Flash translation needs to be improved, and the APIs and media loading methods need to be synchronized. For now, JGame Flash is released as a separate package. The JGame Flash API is different because of limitations in AS3 method signatures: you cannot define multiple methods with the same name but with different parameters. To compensate, AS3 offers optional parameters. The JGame Flash API fits multiple Java methods with the same name into one AS3 method with optional parameters as much as possible. This means that some parameters are re-ordered and some methods are renamed. Media (images, sounds) loading in AS3 also follows a different method. While AS3 can load media from separate files, most Flash game sites assume that all game media are embedded in the SWF file. This means that the media have to be loaded using Embed directives. JGame Flash provides a tool (genmedialoaderas3) to convert a set of images and sounds directly to a class with appropriate Embed variables and define... methods. Instantiating this class will then define the media. While this provides a partial replacement of the media table, tools for converting a media table to an Embed class, and a Java version of GenJGameMediaLoader are still needed to make Java-AS3 conversion easier. Usage of media loader generator: java -jar genmedialoader.jar \ [] Also included is a Java to AS3 converter based on Mike Slinn's J2AS3: http://code.google.com/p/j2as3/ I converted it to Java and made some minor improvements to the parsing code. J2AS3 is based on shallow parsing, but manages to convert 90% of the code correctly, so that the most boring parts of Java to AS3 translation are done automatically. Usage of Java to AS3 translator: java -jar j2as3.jar > JGame Flash requires Flash 10.1 because it reads accelerometer events. These are probably useful only for the Android version of Flash. JGame Flash was tested on Android and found to work reasonably well. However, while Android Flash looks promising, I do not consider it mature yet. It suffers from serious mouse input lag in windowed mode and low graphical performance in full-screen mode. Moreover, screen orientation cannot be controlled properly, which makes accelerometer games less viable. Hopefully there will be a new Flash version soon that fixes these problems. JGame Flash uses an initialisation scheme that enables different preloaders to be attached to a game by just changing compiler switches. A preloader operates while the SWF file is still being loaded. It may show a progress bar but may also display ads or connect to services. The method init() is the entry point to your application when it has finished loading, called from the preloader. A parameter of type jgame.flash.PreloaderEnvironment is passed, which enables access to a service API provided by the preloader (which is currently very simple). Three preloaders are provided: a simple one which just displays a progress bar, and ones for MochiMedia and Kongregate, which are the best known game portals. Note that Mochi and some others are also capable of automatically adding a preloader. In those cases, just use the SimplePreloaderEnvironment to compile your game. Check the WebWars makefile to see how different preloaders are attached. Compile and run --------------- To compile the examples, enter the directory of the application and call make.sh. cd examples/webwars ./make.sh cd examples/paratroopers ./make.sh This will create a .swf in the example directory. To re-compile the tool jars: ./make-tools API --- The API is based on the JGame API, with some notable differences. Not implemented yet: JGTimer, Highscores(, JGImage, ImageMap) JGEngine.getObjects JGEngine.setTilesMulti media table / loading media from files. drawImageString Changed: StdGame: stage -> level_stage checkTime(min,max,inc) -> checkTime(inc,min,max) checkTime(inc) removed JGPoint: jgpoint(jgpoint) constructor removed JGColor All float constructors removed JGObject: lastbbox/lasttilebbox not implemented lastx,lasty not implemented only one constructor: JGObject(id:String, unique:Boolean,xpos:Number,ypos:Number, colid:int,anim:Animation,expiry:Number=-1,xspeed:int=0,yspeed:int=0, xdir:int=1,ydir:int=1,tilebbox:JGRectangle=null):void getbbox(rect) and gettilebbox(tile) removed checkBGCollision(rectangle) -> checkBGCollisionRect(rectangle) JGEngine: scalepos(x,y,width,height) -> scaleRect scalepos(rect) -> scaleRectO moduloFloor(int pos.int modulo) -> moduloFloorInt getTileCoord(JGPoint) removed getTiles(dest,r) removed getTileCid(Rectangle) -> getTileCidRect getTiles(rect,rect) -> getTilesCopy setTileCid(x,y,andmask,ormask) -> maskTileCid setTile(JGPoint,tile) -> setTilePoint getTileCid(JGPoint, xofs, yofs) -> getTileCidOfs getTileStr(JGPoint, xofs, yofs) -> getTileStrOfs drawImage: one version with all parameters as optional parameters. Changed order so that pf_relative is the first optional parameter. drawImage: extra parameter blendmode (BlendNormal, BlendAdd) drawString: one version with font,color first optional parameters, pf_relative last corrected inconsistent draw... parameter order: drawImage(x,y,img) -> drawImage(img,x,y); getKey is typically called using single-quoted symbols. These are numbers in java, but Strings in AS3. So the AS3 version of getKey takes a String as argument. checkBGCollision(rectangle) -> checkBGCollisionRect(rectangle) defineImage from image map -> defineImageFromMap