GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - firefly-zero/firefly-lua: 🌙 Lua SDK for making Firefly Zero games

BranchesTags
Open more actions menu

Latest commit

 

History

52 Commits
52 Commits

Folders and files

NameName
Last commit message
Last commit date
.cargo
.cargo
 
 
src
src
 
 
.gitignore
.gitignore
 
 
Cargo.lock
Cargo.lock
 
 
Cargo.toml
Cargo.toml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
Taskfile.yml
Taskfile.yml
 
 
firefly.toml
firefly.toml
 
 
main.lua
main.lua
 
 

Repository files navigation

firefly-lua

Lua SDK for making Firefly Zero games. Based on a wasm-compatible fork of piccolo.

  • ▶️ getting started
  • 🐙 github

SDK state

A Lua app is about 50 times slower than an equivalent Go app. So, until we find a more performant solution, we recommend to use Lua only for simple demos or as an intermediate step when migrating a game from another platform. The latter is a good way to do a gradual migration: first rewrite runtime calls (like calls to draw a shape on the screen) and then change the syntax and code structure to Go.

At the moment, the SDK doesn't implement audio API.

Examples

Callbacks:

function boot()
    -- ...
end

function update()
    -- ...
end

function render()
    -- ...
end

function before_exit()
    -- ...
end

function handle_menu(index)
    -- ...
end

function cheat(cmd, val)
    -- ...
    return 0
end

Graphics:

firefly.set_color(firefly.RED, {r=255, g=0, b=0})

firefly.clear_screen(firefly.BLUE)

firefly.draw_point({x=10, y=20}, firefly.BLACK)

firefly.draw_line(
    {x=10, y=20}, {x=30, y=40},
    {color=firefly.RED, width=1},
)

local style = {
    fill_color=firefly.Red,
    stroke_color=firefly.BLUE,
    stroke_width=1,
}
local point = {x=10, y=20}
local size = {width=30, height=40}

firefly.draw_rect(point, size, style)

local corner = {width=4, height=4}
firefly.draw_rounded_rect(point, size, corner, style)

firefly.draw_circle(point, 10, style)

firefly.draw_ellipse(point, size, style)

firefly.draw_triangle(
    {x=40, y=20},
    {x=30, y=40},
    {x=50, y=40},
    style,
)

firefly.draw_arc(
    point,
    10, -- diameter
    0, math.pi / 2, -- start and sweep angles
    style,
)

firefly.draw_sector(
    point,
    10, -- diameter
    0, math.pi / 2, -- start and sweep angles
    style,
)

local font = firefly.load_file("font")
firefly.draw_text("oh hi mark", font, point, firefly.BLACK)

firefly.draw_qr(
    "https://fireflyzero.com/",
    point, firefly.BLACK, firefly.WHITE,
)

Multiplayer:

local peer = firefly.get_me()

local peers = firefly.get_peers()
for i = 1, #peers do
    peer = peers[i]
end

Input:

local pad = firefly.read_pad(peer)
if pad then
    {pad.x, pad.y}
end

local btns = firefly.read_buttons(peer)
{btns.s, btns.e, btns.w, btns.n}

-- Read combined inputs.
pad = firefly.read_pad(firefly.COMBINED)
btns = firefly.read_buttons(firefly.COMBINED)

Filesystem:

local file = firefly.load_file("font")

firefly.dump_file("font", file)

firefly.remove_file("font")

Menu:

firefly.add_menu_item(1, "intentory")
firefly.remove_menu_item(1)
firefly.open_menu()

Boards (scoreboards) and badges (achievements):

local badge1 = 1
local badge2 = 2

local progress = firefly.get_progress(peer, badge1)
{progress.done, progress.goal}

progress = firefly.add_progress(peer, badge1, 1)

local board1 = 1
local board2 = 2

local best_score = firefly.get_score(peer, board1)
best_score = firefly.add_score(peer, board1, 10)

Misc:

firefly.log_debug("let's go!")

firefly.log_error("oh no...")

firefly.set_seed(13)

local seconds_since_start = firefly.get_time()

local rand_val = firefly.get_random()

local name = firefly.get_name(peer)

local settings = firefly.get_settings(peer)
if settings.language == "en" then
    -- ...
end

firefly.quit()

About

🌙 Lua SDK for making Firefly Zero games

Topics

firefly-zerogamedevluasdk

Resources

Readme
License
Activity
Custom properties

Stars

2 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.