skyfallKit.package
- .metadata210 B
- README.md11.1 KB
- SkyfallDirector.component
- SkyfallObject.component
- core.module
- curves.module
- example-build-a-catch-the-falling-stars-game.guide
- gallery.module
- how-to-make-things-fall-from-the-sky-in-waves-for-an-arcade-game.guide
- looks.module
- motions.module
- package.yaml1.3 KB
- patterns.module
- skyfall.module
- spawner.module
README.md
skyfallKit
Things that fall, drift, rise or fly across a play area in waves, for arcade games: falling stars to catch, fruit thrown up to slice, balloons and bubbles rising to pop, meteors to dodge, leaves to grab. Multiplayer-correct and cheap: one authority decides what spawns, and every screen computes the motion itself, so it is smooth everywhere without streaming a single transform.
Version 1.0.4 (Skyfall.VERSION). This README, package.yaml and Skyfall.VERSION move together.
What you get
- 8 motions (per object):
drop(straight down, gently accelerating),zigzag,swirl(spirals down through the depth),float(wobbly leaf drift),arc(thrown up from below, then falls, like fruit-slicing games),bounce(three bounces on the floor, then through it),rise(bubbles, balloons),dart(fast diagonal streak). - 8 wave patterns:
rain(random across the width),line(a row),vee,burst(from one point, fanning out),spiral,sides(in from the left and right edges),lanes(fixed columns),fountain(thrown up from below). - 5 entry effects:
popIn,fadeIn,streak,sparkle,none; 4 warning markers where an object will enter:ring,arrow,glow,none. - 5 placeholder looks:
cartoon(bright, outlined),minimal(matte single shapes),neon(glowing),pixel(blocky),pastel(soft). Ten built-in shapes: orb, star, gem, bubble, balloon, rock, fruit, bomb, drop, leaf. - 5 difficulty curves over a round:
linear,easeIn,steps,waves(breather moments),flat— spawnerKit's curves (~spawnerKit.curves) read over the round. - Events on every peer:
spawned,escaped(left the play area, e.g. hit the ground: lose a life),removed(caught, cleared, or despawned by something else). - A
SkyfallDirectorcomponent for a no-code shower, and a gallery demo showing every motion side by side.
Install
Search ZeroMind for skyfallKit (or "things falling from the sky in waves") and install skyfallKit.package; once published, install it by its guid with zeromind_install. It brings spawnerKit's curves module with it. Then:
local Skyfall = require("skyfallKit.skyfall")
Quick start (code)
local Skyfall = require("skyfallKit.skyfall")
-- 1. Kinds: call on EVERY peer (module scope or the world entrypoint), never only on the host.
Skyfall.defineKind("star", { shape = "star", motion = "float", speed = 2.0, radius = 0.6, data = { points = 10 } })
Skyfall.defineKind("gloom", { shape = "bomb", motion = "drop", speed = 2.4, radius = 0.6, data = { points = -20 } })
-- 2. Events: every peer hears them, late joiners included.
Skyfall.on("escaped", function(ev) if ev.kind == "star" then loseLife() end end)
Skyfall.on("removed", function(ev) if ev.reason == "caught" then addScore(ev.data.points) end end)
-- 3. When play starts: the authority creates the director (other peers get a handle to it).
local dir = Skyfall.director({
name = "Skyfall",
area = { center = {0, 6, 0}, width = 14, height = 10, depth = 2, down = {0, -1, 0} },
look = "pastel", warning = "ring", entry = "popIn", curve = "easeIn", maxAlive = 40,
})
-- 4. A 90-second round that ramps up (authority only; harmless elsewhere).
Skyfall.run({ seconds = 90, curve = "easeIn", every = 3, waves = {
{ pattern = "rain", kinds = { "star", "star", "gloom" }, count = 6, gap = 0.4 },
{ pattern = "vee", kinds = { "star" }, count = 7, gap = 0.15 },
{ pattern = "sides", kinds = { "star", "gloom" }, count = 6, gap = 0.3, motion = "float" },
} })
-- 5. Catching: from any peer (forwarded to the authority).
Skyfall.remove(entity, "caught")
Quick start (no code)
Add a SkyfallDirector component to an empty entity in your scene and press play. With autoRun on (default) it runs a looping round of rain from its fields: look, pattern, motion (empty = each kind's own), curve, seconds, rate (objects per second at the start), waveEvery, kinds (comma list), areaCenter, areaSize ({width, height, depth}), down, warning, entry, maxAlive, speedScale, loop.
The play area
A rectangle in world space: center, width (across), height (along "up"), depth (thickness; swirl and float use it), and down, the direction things fall. {0,-1,0} is a vertical field seen by a fixed camera looking along -Z; for a top-down area pass the screen's down, e.g. {0,0,1} (depth then runs along world Y). across may be given to override the left-to-right axis. Objects start just outside the edge their motion enters from (above for falling motions, below for arc and rise, beside for the sides pattern) and escape when they leave by any edge (ev.edge = bottom, top, left, right, or timeout after 45 s).
API
| Call | Where | What |
|---|---|---|
Skyfall.VERSION | any | "1.0.4" |
Skyfall.defineKind(name, def) | every peer | def = { build = function(entity, look) end?, model?, material?, tint?, shape?, motion?, speed?, radius?, data? }. build gets the object's local body entity to parent your visuals under (it is moved for you); or give a model / material; or a built-in shape. Built-in kinds orb, star, gem, bubble, balloon, rock, fruit, bomb, drop, leaf exist already. |
Skyfall.director(opts) -> handle | any | Creates (host) or finds the synced director named opts.name (default "Skyfall") and makes it current. Options: area, look, warning, entry, curve, pattern, motion, maxAlive, speedScale, kinds, autoRun. Handle: h.name, h:id(), h:entity(), h:isAuthority(), h:fields(). |
Skyfall.spawn(kind, { motion?, x?, y?, vx?, speed?, delay?, data?, look?, radius? }) -> entity? | authority | One object. x 0..1 across, y 0..1 up (default: the motion's own start edge), vx sideways m/s. nil elsewhere or at maxAlive. |
Skyfall.wave({ pattern, kinds, kind?, count, gap, motion?, speed?, lanes?, data?, delay? }) -> { entity } | authority | One wave now. |
Skyfall.run(schedule, opts?) | authority | A list of waves ({ at = seconds, pattern = ..., ... }; missing at = previous + opts.every), or a round { seconds, waves, curve, every, strength?, loop? } that fires the next wave template every every seconds with count, speed and pace scaled by the curve. The schedule is stored in synced fields, so a new host carries on. |
Skyfall.stopAll() | authority | Stops the schedule; objects in play keep going. |
Skyfall.clear() | authority | Ends everything in play (removed, reason "cleared"). |
Skyfall.remove(entity, reason?) | any | Ends one object now (removed, reason default "removed"); forwarded to the authority from other peers. |
Skyfall.alive() -> { entity } | any | Objects in play on this peer. |
Skyfall.positionOf(entity) -> {x,y,z} | any | This peer's computed position now. |
Skyfall.infoOf(entity) / Skyfall.isObject(entity) | any | { kind, data, motion, look, appearsAt, ended, radius }. |
Skyfall.on(name, fn) | any | "spawned", "escaped", "removed" or "*" (fn(name, ev)). ev = { entity, id, kind, data, position, motion, director, reason?, edge?, appearsAt }. Returns a connection with :Disconnect(). |
Skyfall.isAuthority() / Skyfall.running() | any | Whether this peer drives; whether a schedule runs. |
Skyfall.setLook(name) / Skyfall.configure(opts) | authority | Switch look (objects in play too) / change director settings. |
Skyfall.area() | any | The current play-area frame { c, ax, up, dz, w, h, d }. |
Skyfall.looks() motions() patterns() entries() warnings() curves() shapes() | any | The style names. |
Skyfall.stats() | any | Event counts and alive count on this peer. |
Each object's synced SkyfallObject component also exposes its kind and gameData fields directly, for kits that hold the entity (e.g. a touch-target kit): entity.component.get(Skyfall.OBJECT).kind.
Gallery demo: require("skyfallKit.gallery").start({ center = {0,6,0}, cycleLooks = true }), .stop().
Multiplayer rules
- One authority: the peer that owns the director entity (the host creates it with
entity.spawnSynced; with host migration the new owner takes over, schedule included). Only it spawns, runs schedules and clears. Other peers'spawn/wave/runreturn nil /{}/ false and do nothing. - Objects carry parameters, not transforms. Each object is a synced entity with a
SkyfallObjectcomponent holding its start time onmultiplayer.sessionTime(), start point, motion, speed, seed and the play area. The synced entity never moves; every peer computes the pose every frame and moves a local body child, so motion is smooth everywhere and no poses are streamed. - Endings are fields. The object's owner sets
endReason(escaped / removed / cleared / your reason) and despawns it 0.3 s later; every peer fires the event from that field. An entity despawned by anything else firesremovedwith reason"despawned"on every peer and simply drops out ofalive(). - Late joiners receive live objects with the room snapshot; each fires
spawnedon them as it arrives. - defineKind on every peer: a kind's
buildis a function and cannot cross the network.
Performance
- Network: one synced entity per object, one message when it spawns and one when it ends. No per-frame traffic.
- CPU: measured on an Android phone with 40 objects alive: about 0.06 to 0.1 ms per object per frame (around 3 ms for 40), most of it the per-component update and three transform writes.
maxAlive(default 40) caps it. - Draw: 2 to 6 primitive meshes per object for the placeholder looks; a game's own
builddecides its own cost.
Known limitations
- Motion is deterministic per peer, but peers agree only to the accuracy of the session clock (typically a few tens of milliseconds), which is fine for catching but not for frame-exact physics.
- Objects do not collide with anything; hit tests are the game's (use
Skyfall.positionOfor the body entity). fadeInfades the tint in from white (the placeholder materials are opaque), not the opacity.
Guides in this package
how-to-make-things-fall-from-the-sky-in-waves-for-an-arcade-game— the concepts, every style, schedules, curves, multiplayer and performance.example-build-a-catch-the-falling-stars-game— a step-by-step small game with lives, score and a difficulty ramp.
Version history
- 1.0.4: runs on spawnerKit 1.2.7 (its README and version label now match; no code change in either kit).
- 1.0.3: runs on spawnerKit 1.2.5, which keeps every pooled object (prewarmed ones too) fully asleep until it is used and stops refused-write warnings on peers that do not own an enemy.
- 1.0.2 — declares spawnerKit (its difficulty curves) as a dependency, so installing skyfallKit on its own brings spawnerKit along.
- 1.0.1 — an entry effect is no longer spawned under an object whose synced entity is already gone.
- 1.0.0 — first release.