Fork of gorp for Roblox-ts.
- This package is versioned with
<gorp version>-ts.<x>
where x is incremented for any changes to the TS version in particular.
The following requires the gorp-ecr package
Server
import ecr from "@rbxts/ecr";
import gorp from "@rbxts/gorp";
import gorp_ecr from "@rbxts/gorp-ecr";
// Required, sets up the ecs layer for ecr
gorp_ecr.init({ ecr, gorp });
Client
import ecr from "@rbxts/ecr";
import gorp from "@rbxts/gorp";
import gorp_ecr from "@rbxts/gorp-ecr";
// Required, sets up the ecs layer for ecr
gorp_ecr.init({ ecr, gorp });
// Create components
const Position = ecr.component(() => Vector3.zero);
const Velocity = ecr.component<Vector3>();
// Assign names to components
gorp.names({ pos: Position, vel: Velocity });
// Create world and assign name
const world = ecr.registry();
gorp.hook_world(world, "main_world");
// Get the client and mount the selector interface
const client = gorp.get_client();
client.gorp_selector();
// Create entity, assign components
const ent = world.create();
world.add(ent, Position);
world.set(ent, Velocity, Vector3.xAxis);
// Create scheduler
const scheduler = gorp.scheduler("main_scheduler");
function position_system(dt: number) {
for (const [id, pos, vel] of world.view(Position, Velocity)) {
world.set(id, Position, pos.add(vel.mul(dt)));
}
}
// Run the system every frame in the scheduler
game.GetService("RunService").RenderStepped.Connect((dt) => {
scheduler.system("position_system", position_system, dt);
scheduler.finish();
});
// Connect F keybind to toggle the interface
game.GetService("UserInputService").InputBegan.Connect((input) => {
if (input.KeyCode === Enum.KeyCode.F) {
client.enabled(!client.enabled());
}
});
gorp-ts's People
Forkers
aloroidgorp-ts's Issues
uWu pwetttty pweeease updateyyy ≧◡≦
(づ。◕‿‿◕。)づ (✿◠‿◠)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.