For All You Game Developers

Example Applet

This is an example Java Applet that uses the MoiDev API. It uses Java's own XML functionality to parse the XML data returned from server.

The application is split into three classes. MoiDevApplet is the main application class and contains user interface which simply prompts the user for pal name and player key. It also handles key events and takes care of drawing the application. PalData class (common with all Java examples) is a simple container class that holds pal's properties.

The MoiDev functionality is mainly within the PalLoaderExample class (which is mostly shared with other Java examples). Once constructed with the MoiDev API URL and inited with pal name and player key the class connects to the API, reads and parses the provided pal data and stores it into the given PalData object. The loader also automatically downloads the character animation images automatically as soon as the XML parsing has completed. It also implements a simple state machine to allow the host application to keep track of it and requires the owner to implement LoaderOwner interface for a callback once loading is finished.

A simple php proxy script is used to work around the applet security measures that prevent loading data from other server than the one applet is located in (in this case, applet in www.moidev.net loading data from wwwmoipal.com). The script (forwarder.php) is included in the source code archive.

Downloads

MoiDev applet source code zip.

If you have Java enabled in your browser the example application should be running above. You can try it with your own pal or if you don't have one, try Harry / 8128.