| Crates.io | tx2-core |
| lib.rs | tx2-core |
| version | 0.1.3 |
| created_at | 2025-11-27 17:05:00.827522+00 |
| updated_at | 2025-12-03 01:06:25.640646+00 |
| description | High-performance native ECS engine for cross-platform applications and games |
| homepage | https://github.com/IreGaddr/tx2-core |
| repository | https://github.com/IreGaddr/tx2-core |
| max_upload_size | |
| id | 1954113 |
| size | 138,175 |
A high-performance native ECS engine for cross-platform applications, games, and simulations.
tx2-core is the native Rust implementation of the TX-2 world runtime, providing an authoritative Entity-Component-System architecture that powers desktop apps, game-like experiences, and high-performance servers. It's designed to work seamlessly with the broader TX-2 ecosystem for isomorphic state synchronization across web, native, and CLI environments.
wgpu (WebGPU API)winit (Windows, macOS, Linux)tx2-link for efficient state synchronizationuse tx2_core::{World, Entity, Component, System, App};
use serde::{Serialize, Deserialize};
// Define components
#[derive(Component, Serialize, Deserialize, Clone)]
struct Position { x: f32, y: f32 }
#[derive(Component, Serialize, Deserialize, Clone)]
struct Velocity { dx: f32, dy: f32 }
// Create a world
let mut world = World::new();
world.register_component::<Position>();
world.register_component::<Velocity>();
// Spawn entities
let player = world.create_entity();
world.add_component(player, Position { x: 0.0, y: 0.0 });
world.add_component(player, Velocity { dx: 1.0, dy: 0.5 });
// Query and iterate
for (entity, (pos, vel)) in world.query::<(&Position, &Velocity)>() {
println!("Entity {:?} at ({}, {})", entity, pos.x, pos.y);
}
cargo run --example hello_window
This demonstrates:
winitwgputx2-core follows a pure ECS architecture where:
Components are stored in type-erased hashmaps, allowing:
Systems are executed in a deterministic order based on:
tx2-core is designed to work as part of the broader TX-2 stack:
The same world state can be:
One world, many views.
tx2-core is built for high-performance applications:
World state can be serialized for:
Supported formats:
let entity = world.create_entity();
world.add_component(entity, Position { x: 10.0, y: 20.0 });
world.add_component(entity, Health { current: 100, max: 100 });
// Iterate over all entities with Position and Velocity
for (entity, (pos, vel)) in world.query::<(&mut Position, &Velocity)>() {
pos.x += vel.dx;
pos.y += vel.dy;
}
// Create a snapshot of the current world state
let snapshot = world.create_snapshot();
// Restore from snapshot
world.restore_from_snapshot(&snapshot)?;
use tx2_core::DeltaCompressor;
let mut compressor = DeltaCompressor::new();
// Generate delta between two snapshots
let delta = compressor.create_delta(&previous_snapshot, ¤t_snapshot)?;
// Apply delta to reconstruct current state
let reconstructed = compressor.apply_delta(&previous_snapshot, &delta)?;
tx2-core includes a rendering abstraction built on wgpu:
use tx2_core::{Renderer, RenderBatch};
// Create renderer
let mut renderer = Renderer::new(&window).await;
// Prepare render batches from world
let batches = renderer.prepare_batches(&world);
// Render frame
renderer.render(&batches)?;
Build complete applications with the App framework:
use tx2_core::App;
let mut app = App::new("My Game", 800, 600)?;
app.run(|world, delta_time| {
// Update game logic
update_physics(world, delta_time);
update_ai(world, delta_time);
update_animations(world, delta_time);
});
tx2-core is in active development. Current status:
serde - Serialization frameworkuuid - Entity identifierswinit - Cross-platform windowingwgpu - WebGPU rendering APItx2-link - World synchronization protocolMIT
Contributions are welcome! This is part of the broader TX-2 project for building isomorphic applications with a unified world model.