eco2d/code/modules/source/system_onfoot.c

17 lines
607 B
C
Raw Normal View History

2021-08-29 10:48:29 +00:00
#define PLR_MOVE_SPEED 30.0
2021-08-29 11:48:54 +00:00
#define PLR_MOVE_SPEED_MULT 1.5
2021-08-10 11:19:45 +00:00
void MovementImpulse(ecs_iter_t *it) {
Input *in = ecs_column(it, Input, 1);
Velocity *v = ecs_column(it, Velocity, 2);
2021-08-29 10:48:29 +00:00
Position *p = ecs_column(it, Position, 3);
2021-08-10 11:19:45 +00:00
for (int i = 0; i < it->count; i++) {
2021-08-11 10:22:46 +00:00
world_block_lookup lookup = world_block_from_realpos(p[i].x, p[i].y);
2021-08-11 16:19:10 +00:00
float drag = zpl_clamp(blocks_get_drag(lookup.block_id), 0.0f, 1.0f);
2021-08-10 11:19:45 +00:00
double speed = PLR_MOVE_SPEED * (in[i].sprint ? PLR_MOVE_SPEED_MULT : 1.0);
2021-08-29 10:48:29 +00:00
v[i].x += in[i].x*speed*drag;
2021-08-29 12:59:00 +00:00
v[i].y -= in[i].y*speed*drag;
2021-08-10 11:19:45 +00:00
}
}