Documentation

Everything you need to create a game with FRAG

Documentation is still very much a work in progress. Please understand there may be rapid changes to this section of the website.

Documentation Progress: 5%

Initialization

of a FRAG application


After the framework has been initialized, the application is given a chance to do the same.

Along with creating the initial application state, it is common to load any resources that the application might depend on, during this phase of the application lifecycle.

Example Game Code

proc initApp(app: App, ctx: Frag) =
  discard ctx.assets.load(“textures/texture01.png”, AssetType.Texture)
        
It is often uncessary and undesirable to load every resource your application will use, at this point in time. More commonly, applications will load whatever resources are necessary for the presentation of their home screen | main menu, and additional resources are loaded when needed.

Listeners for framework-related events should also be registered during this phase of the game loop.

Example Game Code

  proc resize*(e: EventArgs) =
    let event = SDLEventMessage(e).event
    let sdlEventData = event.sdlEventData
    let graphics = event.graphics
    graphics.setViewRect(0, 0, 0, uint16 sdlEventData.window.data1, uint16 sdlEventData.window.data2)

proc initApp(app: App, ctx: Frag) = ctx.events.on(SDLEventType.WindowResize, resize)