Monkey: a base script for the fantomEngine

Strict

#rem
    Script:     baseScript.monkey
    Description:    Base Script fantomEngine 
    Author:         Michael Hartlef
    Version:      1.0
#end

Import fantomEngine
Global g:game

'***************************************
Class game Extends App
    Field eng:engine
    Field isSuspended:Bool = False
    '------------------------------------------
    Method OnCreate:Int()
        SetUpdateRate(60)
        eng = New engine
        Return 0
    End
    '------------------------------------------
    Method OnUpdate:Int()
        Local d:Float = Float(eng.CalcDeltaTime())/60.0
        If isSuspended = False Then
            eng.Update(Float(d))
        Endif
        Return 0
    End
    '------------------------------------------
    Method OnRender:Int()
        Cls
        eng.Render()
        Return 0
    End
    '------------------------------------------
    Method OnResume:Int()
        isSuspended = False
        SetUpdateRate(60)
        Return 0
    End
    '------------------------------------------
    Method OnSuspend:Int()
        isSuspended = True
        SetUpdateRate(5)
        Return 0
    End
End

'***************************************
Class engine Extends ftEngine
    '------------------------------------------
    Method OnObjectCollision:Int(obj:ftObject, obj2:ftObject)
        Return 0
    End
    '------------------------------------------
    Method OnObjectTimer:Int(timerId:Int, obj:ftObject)
        Return 0
    End
    '------------------------------------------
    Method OnObjectTouch:Int(obj:ftObject, touchId:Int)
        Return 0
    End
    '------------------------------------------
    Method OnObjectTransition:Int(transId:Int, obj:ftObject)
        Return 0
    End
    '------------------------------------------
    Method OnObjectUpdate:Int(obj:ftObject)
        Return 0
    End
    '------------------------------------------
    Method OnLayerTransition:Int(transId:Int, layer:ftLayer)
        Return 0
    End
    '------------------------------------------
    Method OnLayerUpdate:Int(layer:ftLayer)
        Return 0
    End
End

'***************************************
Function Main:Int()
    g = New game
    Return 0
End