Monkey-X: Game Template

Import mojo
Function Main()
	New Game
End

Class Game Extends App

	'summary:The OnCreate Method is called when mojo has been initialized and the application has been successfully created.
	Method OnCreate()
	
		'Set how many times per second the game should update and render itself
		SetUpdateRate(60)
	
	End
	
	'summary: This method is automatically called when the application's update timer ticks. 
	Method OnUpdate()
		
	End
	
	'summary: This method is automatically called when the application should render itself, such as when the application first starts, or following an OnUpdate call. 
	Method OnRender()
		
	End

	'summary: This method is called instead of OnRender when the application should render itself, but there are still resources such as images or sounds in the process of being loaded. 
	Method OnLoading()
		
	End
	
	'summary: This method is called when the application's device window size changes. 
	Method OnResize()
		
	End
	
	'#REGION Code to handle susped status of the game goes here
	
	'summary: OnSuspend is called when your application is about to be suspended. 
	Method OnSuspend()
	
	End
	
	'summary: OnResume is called when your application is made active again after having been in a suspended state. 
	Method OnResume()
		
	End	
	'#END REGION
	
	'#REGION Code to handle game closing goes here:
	
	'summary: This method is called when the application's 'close' button is pressed. 
	Method OnClose()
		Super.OnClose()
	End

	'summary:This method is called when the application's 'back' button is pressed. 
	Method OnBack()
		Super.OnBack()
	End
	
	'#END REGION

End

Quelle: Template

Monkey-X: Template Command line tool

Import commandlineapp

'summary: This is the command line tool starting point:
Function Main()	
	Local tool:= New CommandLineTool()
End

'summary: This class handles the launching and parameters of the command line tool
Class CommandLineTool Extends CommandLineApp

	'summary: This is called when the command line tool launches.
	Method New()
	
		#REM
		Notice there are several field defined in this class, such as assemblyLocation, assemblyName and  parameters.
			- Self.assemblyName contains the name of the tool executable file (IE. the EXE file in windows os)
			- Self.assemblyLocation contains the path in the filesystem where the tool is located.
			- Self.paramters is a string array with any parameter passed to the tool. If no parameter is present, this array is of length zero.
		#END
		
		'Place the command line tool code here:
		
	End

End
Import brl.filepath
Import os

'summary: This class handles the launching and parameters of the command line tool
Class CommandLineApp Abstract

	'summary: This field contains the name of this tool assembly. That is, in windows, the EXE file of this tool.
	Field assemblyName:String

	'summary: This field contains the location in the file system where this tool is stored.
	Field assemblyLocation:String

	'summary: This array of strings contains all the paramters passed to this command line tool from the terminal or console.<br>If none is passed, this array will be of length zero.
	Field parameters:String[]

	Method New()
	
		'this is the tool executable name (on windows, the EXE file name):
		assemblyName = filepath.StripDir(os.AppArgs[0])
	
		'This is the tool executable path, the folder where the assembly is located:
		assemblyLocation = filepath.ExtractDir(os.AppArgs[0])
		
		'We get the list of parameters
		parameters = os.AppArgs[1 ..]
	
	End

	'summary: Use this method to abruptly end current application.<br>The "success" parameter may be set to true or false depending of the cause of the tool being ended.
	Method EndApplication(success:Bool)
		If success Then os.ExitApp(0) Else os.ExitApp(-1)
	End
	
End

 

Quelle: Templates