Skip to content

Add entity component system functionality #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft

Add entity component system functionality #5

wants to merge 19 commits into from

Conversation

anissen
Copy link
Owner

@anissen anissen commented Nov 22, 2022

Integrate Composite into Cosy to be able to use entity component functionality directly as part of the language.

This is especially useful for applications with a lot of objects that can change properties interactively. However, it can also be convenient as a sort of in-memory database for a wider variety of applications.

Limitations:

  • Composite library is currently linked in. This only works locally.
  • Still work-in-progress.

Example usage:

struct Position {
    mut x Num
    mut y Num
}
struct Velocity {
    mut x Num
    mut y Num
}

// create entity
spawn(
    Position { x = 200, y = 200 }, 
    Velocity { x = 1.2, y = -3.4 }
)

// query entities
query mut Position p, Velocity v {
    p.x += v.x * delta
    p.y += v.y * delta
}

@skial skial mentioned this pull request Nov 23, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant