{"id":31580140,"url":"https://github.com/solarlune/tetraflow","last_synced_at":"2025-10-05T21:07:44.333Z","repository":{"id":188366382,"uuid":"678609252","full_name":"SolarLune/tetraflow","owner":"SolarLune","description":"TetraFlow is a package to help create a simple game-engine-like flow for Tetra3D projects.","archived":false,"fork":false,"pushed_at":"2023-08-17T02:20:42.000Z","size":232,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-21T07:41:51.320Z","etag":null,"topics":["3d","ebitengine","gamedev","tetra3d","tetraterm"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SolarLune.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-15T00:33:45.000Z","updated_at":"2023-08-18T07:24:41.000Z","dependencies_parsed_at":"2023-08-15T03:14:19.253Z","dependency_job_id":null,"html_url":"https://github.com/SolarLune/tetraflow","commit_stats":null,"previous_names":["solarlune/tetraflow"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SolarLune/tetraflow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Ftetraflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Ftetraflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Ftetraflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Ftetraflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SolarLune","download_url":"https://codeload.github.com/SolarLune/tetraflow/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Ftetraflow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278519084,"owners_count":26000211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","ebitengine","gamedev","tetra3d","tetraterm"],"created_at":"2025-10-05T21:07:36.073Z","updated_at":"2025-10-05T21:07:44.327Z","avatar_url":"https://github.com/SolarLune.png","language":"Go","readme":"# TetraFlow 🚗💨\n\nTetraFlow is a package specifically for creating a simple object-oriented game engine-like flow for [Tetra3D](https://github.com/solarlune/tetra3d) projects.\n\n# How does it work\n\nThe general approach is to load in your Tetra3D library (a collection of Scenes), create an `*tetraflow.Engine`, and then register a function to create game objects (`IReceivers`) for each relevant node. TetraFlow will register these receivers in the connected nodes' `INode.Data()` slots. You then create `Stage`s for each Scene in your Scene stack (e.g. one for your GUI, one for your game, and one for your background skybox), setting relevant scenes in each Stage. When you call `Engine.Update()`, the `Engine` object will continuously message IReceivers on engine events (when a node is added or removed from the scene tree, when the engine updates, etc) for all Stages.\n\nTo summarize, the Engine updates Stages, Stages contain Tetra3D Scenes, and you can create game logic structs to be IReceivers, which listen for the Engine's updates.\n\n# How to get it\n\n```go get github.com/solarlune/tetraflow```\n\n# How to use it\n\n```\n\nfunc (g *Game) Init() {\n\n    g.Engine = tetraflow.NewEngine(\n        \n        g.Library,\n\n        func(node tetra3d.INode) tetraflow.IReceiver {\n\n            // Create relevant engine receivers for a game object depending on what logic the game object should have\n            if node.Properties().Has(\"gameobject\") {\n                switch node.Properties().Get(\"gameobject\").AsString() {\n                case \"player\":\n                    return NewPlayer(node)\n                case \"enemy\":\n                    return NewEnemy(node)\n                }\n            }\n\n            return nil\n\n        },\n    )\n\n    gameStage := g.Engine.AddStage(\"Game\")\n    gameStage.SetScene(\"Level 1\")\n\n}\n\nfunc (g *Game) Update() error {\n\n    // Engine.Update() returns an error if you call Engine.Quit().\n    return g.Engine.Update()\n}\n\n```\n\n## Messages\n\nTetraFlow's engine flow is based around the concept of message passing.\n\nThe general idea is to have your game objects fulfill the `tetraflow.IReceiver` interface, which just defines a single function - `ReceiveMessage(messages.IMessage)`. By declaring this function, your game object struct becomes something that can receive messages from the `Engine` instance.\n\nThe `Engine` will send a variety of messages as nodes live in a scene's node hierarchy. These messages can indicate changes in the node or the scene's life-cycle; for example, a message could indicate that the node is being updated (once per game frame), removed from the scene tree, or that the scene itself has just begun or just ended execution. By listening for these messages, GameObjects can behave appropriately:\n\n```go\n\ntype Player struct {\n    Node tetra3d.INode\n}\n\nfunc NewPlayer(node tetra3d.INode) *Player {\n    return \u0026Player{ Node: node }\n}\n\n// This function allows Player to become an IReceiver.\nfunc (player *Player) ReceiveMessage(msg messages.IMessage) {\n\n    switch message := msg.(type) {\n        case messages.MessageOnUpdate:\n            // Update message, happens once per game-frame\n        case messages.MessageOnAdd:\n            // OnAdd, called once when the node is added to the scene tree.\n    }\n\n    if msg.Type() == messages.MessageTypeOnUpdate {\n        // Update message, happens every game frame\n    }\n\n}\n\n```\n\nYou can switch off against either `IMessage.Type()`, or by the type of the message objects itself (`switch message := msg.(type)`) to distinguish between IMessages. The latter is the more elegant approach, as this allows you to access custom message values like `MessageOnSceneEnd.Scene`.\n\nBy using messages, one can also make their own custom messages to pass around, by simply making a custom struct that implements `IMessage`. You can send messages to target objects, or to the entire engine using `Engine.SendMessage()`.\n\n## Message Subscription\n\nMessages can be filtered down by making your object implement `ISubscriber`, which entails creating a `Subscribe() messages.MessageType` function. This function returns the MessageTypes that should be received for that object. If you want to subscribe to more than one message type, you can simply add them together, as the types are bitwise values.\n\n```go\n\nfunc (player *Player) Subscribe() messages.MessageType {\n    return messages.TypeUpdate + messages.TypeSceneStart // Only subscribe to update messages or messages indicating the start of the current scene\n}\n\n```\n\n# Todo\n\n## Functionality\n\n- [x] - Message subscription so all Receivers aren't receiving all Messages\n\n## Message types\n\n- [x] - On Scene Start / End (`OnSceneStart()`)\n- [ ] - Collision checking (`OnCollision(other IBoundingObject)`)?\n- [ ] - Input messages?\n- [ ] - Scene Tree change","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolarlune%2Ftetraflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolarlune%2Ftetraflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolarlune%2Ftetraflow/lists"}