Skip to content

Add a deltatime variable to the update cycle #8

Description

@Stuhl

Pretty basic thing, yet not implemented. A deltatime variable in the ECS.update() method should be added to get rid of inconsistent frames.

I would suggest just passing the down to the processor which the update function (the one the user writes) can safely use.

update(entity: Entity, components: Component[], processor: Processor, deltaTime: number) {
  const [position, mass] = components

  const gravity = 2
  const result = mass.state.mass * gravity * deltaTime

  mass.state.velocityY += result
  position.state.y += mass.state.velocityY
}

A thing that annoys me a bit here, is the amount of arguments that the update function gets, when being called. I didn't like it before and now it looks even worse. I've added the entity and processor variables as a way to query/change things on edge cases but I don't know if they are actually really needed. People could just query the ECS class if they need it tbh.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions