GlyEngine 0.4
Create games and apps with lua
Loading...
Searching...
No Matches
Typescript

Create games and apps with typescript and jsx. More...

Topics

 JSX
 Write UI for apps with GlyEngine + TSX.

Detailed Description

The .ts and .tsx support works perfectly with the gly engine, you can use it on old consoles, ginga and any other device supported by the gly ecosystem, you can also take advantage of components and libraries written in lua and typescript at the same time.

Tutorial

To build you need an auxiliary tool available via npmjs, so I recommend you use the @gamely/gli-cli package and nodejs as the environment for gly-engine.

  • Step 1
    configure your tsconfig.json and package.json like this:
    • tsconfig.json
      {
      "$schema": "https://raw.githubusercontent.com/TypeScriptToLua/TypeScriptToLua/master/tsconfig-schema.json",
      "compilerOptions": {
      "outDir": "build"
      },
      "tstl": {
      "buildMode": "library",
      "luaTarget": "universal",
      "luaLibImport": "inline",
      "noImplicitGlobalVariables": true,
      "noImplicitSelf": true,
      "noHeader": true
      }
      }
    • package.json
      You don't necessarily need to build for HTML because it's in Node JS, you can use other targets:
      "build": "gly-cli build --cwd build src/game.lua --core Love2D --Bundler"
      "build": "gly-cli build --cwd build src/game.lua --core Ginga --Bundler --enterprise"
      {
      "scripts": {
      "prebuild": "tstl",
      "build": "gly-cli build --cwd build src/game.lua --core html5 --fengari --cdn"
      },
      "dependencies": {
      "@gamely/gly-cli": "0.1.3",
      "@gamely/gly-types": "0.1.2",
      "typescript-to-lua": "^1.31.2"
      }
      }
  • Step 2
    download npmjs packages
    npm install
  • Step 3
    execute build script
    npm run build
Template
  • modern
export const title = 'Your Awesome Game'
export const author = 'IntellectualAuthor'
export const version = '1.0.0'
export const description = 'The best game in the world made in GlyEngine'
export function init(std: any, game: any) {
}
export function loop(std: any, game: any) {
}
export function draw(std: any, game: any) {
}
export function exit(std: any, game: any) {
}
local function exit()
@decorator
local function title(window_name)
@decorator
local function draw(src, pos_x, pos_y)
  • classic
export const meta = {
title: 'Your Awesome Game',
author: 'IntellectualAuthor',
version: '1.0.0',
description: 'The best game in the world made in GlyEngine'
}
function init(std: any, game: any) {
}
function loop(std: any, game: any) {
}
function draw(std: any, game: any) {
}
function exit(std: any, game: any) {
}
export const callbacks = {
init, loop, draw, exit
}
local function callbacks(handler)