eco2d/code/modules/source/system_demo.c

26 lines
880 B
C
Raw Normal View History

2021-08-10 11:19:45 +00:00
#define DEMO_NPC_CHANGEDIR_FACTOR 0.1
#define DEMO_NPC_MOVE_SPEED 1500
void DemoNPCMoveAround(ecs_iter_t *it) {
Velocity *v = ecs_column(it, Velocity, 1);
for (int i = 0; i < it->count; i++) {
v[i].x = zpl_lerp(v[i].x, (rand()%3-1)*DEMO_NPC_MOVE_SPEED, DEMO_NPC_CHANGEDIR_FACTOR);
v[i].y = zpl_lerp(v[i].y, (rand()%3-1)*DEMO_NPC_MOVE_SPEED, DEMO_NPC_CHANGEDIR_FACTOR);
}
}
void DemoPlaceIceBlock(ecs_iter_t *it) {
Input *in = ecs_column(it, Input, 1);
Position *p = ecs_column(it, Position, 2);
uint8_t watr_id = blocks_find(BLOCK_BIOME_DEV, BLOCK_KIND_WATER);
for (int i = 0; i < it->count; i++) {
if (in[i].use) {
2021-08-11 09:24:44 +00:00
in[i].use = false;
2021-08-10 11:19:45 +00:00
world_block_lookup l = world_block_from_realpos(p[i].x, p[i].y);
2021-08-11 09:24:44 +00:00
world_chunk_replace_block(it->world, l.chunk_id, l.id, watr_id);
2021-08-10 11:19:45 +00:00
}
}
}