package djup DELTA: f32 : 1.0 / 60.0 @(export = true) sim_tick :: proc "c" (cur, next: ^Snapshot) { if cur == nil || next == nil { return } context = next.ctx^ next.tick = cur.tick + 1 copy(next.metadata, cur.metadata) player_input_system(cur, next) ball_movement_system(cur, next) } player_input_system :: proc(cur, next: ^Snapshot) { for &e, id in soa_zip(m = cur.metadata, input = cur.player_inputs, ball = cur.balls) { if e.m < {.Exists, .PlayerInput, .Ball} { continue } PLAYER_ACCELERATION :: 1500 PLAYER_DRAG :: 2 acc := vec2_normal(e.input.direction) * PLAYER_ACCELERATION + e.ball.velocity * -PLAYER_DRAG e.ball.velocity += acc * DELTA next.player_inputs[id] = e.input } } ball_movement_system :: proc(cur, next: ^Snapshot) { for &e, id in soa_zip(m = cur.metadata, ball = cur.balls) { if e.m < {.Exists, .Ball} { continue } next.balls[id].position = e.ball.velocity * DELTA next.balls[id].velocity = e.ball.velocity } }