Initial commit
This commit is contained in:
commit
ac0d491786
21 changed files with 1094 additions and 0 deletions
34
ecs/physics_system.odin
Normal file
34
ecs/physics_system.odin
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package ecs
|
||||
|
||||
Vec3 :: distinct [3]f32
|
||||
|
||||
Gravity :: struct {
|
||||
force: Vec3
|
||||
}
|
||||
|
||||
RigidBody :: struct {
|
||||
velocity: Vec3,
|
||||
acceleration: Vec3,
|
||||
}
|
||||
|
||||
Transform :: struct {
|
||||
position: Vec3,
|
||||
rotation: Vec3,
|
||||
scale: Vec3,
|
||||
}
|
||||
|
||||
PhysicsSystem :: struct {
|
||||
using base: SystemBase,
|
||||
}
|
||||
|
||||
|
||||
physics_system_update :: proc(physics_system: ^PhysicsSystem, coordinator: ^Coordinator, dt: f32) {
|
||||
for entity in physics_system.entities {
|
||||
rigid_body := coordinator_get_component(RigidBody, coordinator, entity)
|
||||
transform := coordinator_get_component(Transform, coordinator, entity)
|
||||
gravity := coordinator_get_component(Gravity, coordinator, entity)
|
||||
|
||||
transform.position += rigid_body.velocity * dt
|
||||
rigid_body.velocity += gravity.force * dt
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue