add world boundary collision
parent
9612846d79
commit
d5f150619d
|
@ -149,7 +149,6 @@ void DEBUG_draw_ground(uint64_t key, entity_view data) {
|
||||||
int32_t y = data.y * view->chunk_size * view->block_size;
|
int32_t y = data.y * view->chunk_size * view->block_size;
|
||||||
|
|
||||||
int32_t size = view->chunk_size * view->block_size;
|
int32_t size = view->chunk_size * view->block_size;
|
||||||
int32_t half_size = size/2;
|
|
||||||
int16_t block_size = view->block_size;
|
int16_t block_size = view->block_size;
|
||||||
int32_t half_block_size = block_size/2;
|
int32_t half_block_size = block_size/2;
|
||||||
int16_t offset = 10;
|
int16_t offset = 10;
|
||||||
|
@ -157,10 +156,10 @@ void DEBUG_draw_ground(uint64_t key, entity_view data) {
|
||||||
|
|
||||||
switch (data.kind) {
|
switch (data.kind) {
|
||||||
case EKIND_CHUNK: {
|
case EKIND_CHUNK: {
|
||||||
DrawRectangleEco(x+offset-half_size, y+offset-half_size, size-offset, size-offset, LIME);
|
DrawRectangleEco(x+offset, y+offset, size-offset, size-offset, LIME);
|
||||||
for (uint16_t i = 0; i < view->chunk_size*view->chunk_size; i++) {
|
for (uint16_t i = 0; i < view->chunk_size*view->chunk_size; i++) {
|
||||||
int32_t bx = i % view->block_size * block_size + x - half_size + offset;
|
int32_t bx = i % view->block_size * block_size + x + offset;
|
||||||
int32_t by = i / view->block_size * block_size + y - half_size + offset;
|
int32_t by = i / view->block_size * block_size + y + offset;
|
||||||
DrawRectangleEco(bx+block_offset-half_block_size,
|
DrawRectangleEco(bx+block_offset-half_block_size,
|
||||||
by+block_offset-half_block_size,
|
by+block_offset-half_block_size,
|
||||||
block_size-block_offset,
|
block_size-block_offset,
|
||||||
|
@ -168,7 +167,7 @@ void DEBUG_draw_ground(uint64_t key, entity_view data) {
|
||||||
GREEN);
|
GREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawTextEco(TextFormat("%.01f %.01f", data.x, data.y), x-half_size+5, y-half_size+5, 65 , BLACK, 0.0);
|
DrawTextEco(TextFormat("%.01f %.01f", data.x, data.y), x+5, y+5, 65 , BLACK, 0.0);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
default:break;
|
default:break;
|
||||||
|
|
|
@ -16,10 +16,11 @@ void MoveWalk(ecs_iter_t *it) {
|
||||||
v[i].y = zpl_lerp(v[i].y, 0.0f, PHY_WALK_DRAG);
|
v[i].y = zpl_lerp(v[i].y, 0.0f, PHY_WALK_DRAG);
|
||||||
|
|
||||||
// NOTE(zaklaus): world bounds
|
// NOTE(zaklaus): world bounds
|
||||||
/*{
|
{
|
||||||
double w = (double)world_world_size()*world_chunk_size()*world_block_size();;
|
double w = (double)world_dim()/2.0;
|
||||||
p[i].x = zpl_clamp(p[i].x, -w, w);
|
p[i].x = zpl_clamp(p[i].x, -w, w);
|
||||||
}*/
|
p[i].y = zpl_clamp(p[i].y, -w, w);
|
||||||
|
}
|
||||||
|
|
||||||
librg_entity_chunk_set(world_tracker(), it->entities[i], librg_chunk_from_realpos(world_tracker(), p[i].x, p[i].y, 0));
|
librg_entity_chunk_set(world_tracker(), it->entities[i], librg_chunk_from_realpos(world_tracker(), p[i].x, p[i].y, 0));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue