Monkey/Modules/Mojo

Mojo is a lightweight programming framework module for Monkey. It currently supports HTML5, Flash, Android, iOS, XNA and GLFW targets. Mojo is designed primarily for writing simple 2D games.

Basic Stub
' use Strict for less errors in your code Strict

' import the mojo module Import mojo

' declare your game class Global myGame:MyGame

' the entry point of a monkey program Function Main:Int myGame = New MyGame Return 0 End

' your game class which extends the mojo app class Class MyGame Extends App

Method OnCreate:Int SetUpdateRate 60 Return 0 End Method OnUpdate:Int Return 0 End Method OnRender:Int Return 0 End End

Tips

 * Mojo applications must extend the Mojo App class and create a new instance of this class somewhere inside the Monkey Main function. This is what actually ‘creates’ the application.
 * All data for Mojo programs (images, sounds and text files) must go into a special data directory. This directory has the same name as the program’s main source file, only with a ‘.data’ extension instead of ‘.monkey’. For example, if your main source file is called ‘joust2k.monkey’, then your data directory should be name ‘joust2k.data’.
 * Mojo functions should not be called until your application’s OnCreate method is called. This means you cannot initialize global variables with values returned by Mojo functions such as MilliSecs - you must instead initialize such variables in your application’s OnCreate method or later.
 * Mojo is callback based, as opposed to earlier Blitz Research products where your application ‘drove’ the main loop. A callback based app instead responds to events generated by the underlying OS.
 * Mojo does not deal with ‘resizing’ the display. This must be done on the ’target side’ of things, meaning that you will need to modify the target project in the program’s ‘.build’ directory. The exact process involved with resizing the display (and controlling display capabilities in general) varies greatly from target to target. It may involve editing some source code, or perhaps using a RAD tool to resize a window, which is why Mojo makes no attempt to deal with this side of things