basic ECS spawner

This commit is contained in:
2026-01-15 15:27:48 +01:00
parent 24a781f36a
commit eb737b469c
860 changed files with 58621 additions and 32 deletions

View File

@@ -0,0 +1,25 @@
class_name MovementSystem
extends System
func query():
# Find all entities that have both transform and velocity
return q.with_all([C_Velocity])
func process(entities: Array[Entity], _components: Array, delta: float):
for entity in entities:
var c_velocity = entity.get_component(C_Velocity) as C_Velocity
if entity.velocity.length() == 0:
entity.velocity = c_velocity.velocity
# Add the gravity.
if not entity.is_on_floor():
entity.velocity += entity.get_gravity() * delta
# Bounce off screen edges (simple example)
if entity.global_position.x > 10 && entity.velocity.x > 0:
entity.velocity = -c_velocity.velocity
if entity.global_position.x < -10 && entity.velocity.x < 0:
entity.velocity = c_velocity.velocity
entity.move_and_slide()