Ecosystem bridges · BUILT-IN MODULE

game

Small canvas-game scene builder.

Quick start

use game
use game

scene = game.new 640 360 "SE Game"
game.background scene "#111"
game.circle scene 320 180 50 "#8b7cff" true
try game.show scene

API reference

game.new width height title

Create a game scene and return its id.

建立 a game scene and return its id.
game.background scene color

Set scene background.

設定 scene background.
game.clear scene

Clear draw commands.

Clear draw commands.
game.rect scene x y width height color fill

Draw a rectangle.

Draw a rectangle.
game.circle scene x y radius color fill

Draw a circle.

Draw a circle.
game.line scene x1 y1 x2 y2 color width

Draw a line.

Draw a line.
game.text scene text x y size color

Draw text.

Draw text.
game.script scene javascript

Append browser JavaScript to a scene.

加入 browser JavaScript to a scene.
game.html scene

Return generated scene HTML.

回傳 generated scene HTML.
game.save scene path

Save scene HTML. Fallible.

Save scene HTML. 此操作可能失敗。
game.show scene

Open scene in a browser. Fallible.

開啟 scene in a browser. 此操作可能失敗。