update zpl and fix conveyor belt speed

isolation_bkp/dynres
Dominik Madarász 2021-11-03 15:31:10 +01:00
parent 6405e59117
commit f6bc4d3d44
6 changed files with 19 additions and 22 deletions

View File

@ -85,6 +85,7 @@ ActEraseWorldChanges(void) {
if (l.is_outer && l.block_id > 0) {
asset_id item_asset = blocks_get_asset(l.block_id);
if (item_asset == ASSET_INVALID) continue;
uint64_t e = item_spawn(item_asset, 1);
Position *dest = ecs_get_mut(world_ecs(), e, Position, NULL);

View File

@ -1,9 +1,6 @@
#include "camera.h"
#include "item_placement.h"
#define ZPL_ENABLE_MATH
#include "zpl.h"
static bool build_submit_placements = false;
static bool build_is_in_draw_mode = false;
static uint8_t build_num_placements = 0;
@ -69,10 +66,10 @@ void buildmode_draw(void) {
float p2y = build_placements[1].y;
float p3x = (float)cam.x;
float p3y = (float)cam.y;
float sx = zpl_sign(p2x-p1x);
float sy = zpl_sign(p2y-p1y);
float sxx = zpl_sign(p3x-p1x);
float syy = zpl_sign(p3y-p1y);
float sx = zpl_sign0(p2x-p1x);
float sy = zpl_sign0(p2y-p1y);
float sxx = zpl_sign0(p3x-p1x);
float syy = zpl_sign0(p3y-p1y);
if (sx != sxx || sy != syy) break;
}
@ -103,6 +100,7 @@ void buildmode_draw(void) {
if (build_is_in_draw_mode) {
if (IsKeyPressed(KEY_SPACE)) {
build_is_in_draw_mode = false;
buildmode_clear_buffers();
}
if (IsMouseButtonReleased(MOUSE_RIGHT_BUTTON)) {

View File

@ -43,7 +43,6 @@ uint16_t item_find(asset_id kind) {
return item_resolve_proxy(i);
}
ZPL_PANIC("Unknown asset id: %d\n", kind);
return ASSET_INVALID;
}

View File

@ -18,8 +18,8 @@ static block blocks[] = {
BLOCK(ASSET_WOOD, BLOCK_FLAG_COLLISION, '#', .drag = 1.0f , .friction = 1.0f, .bounce = 0.0f),
BLOCK(ASSET_TREE, BLOCK_FLAG_COLLISION, '@', .drag = 1.0f , .friction = 1.0f, .bounce = 0.0f),
BLOCK(ASSET_BELT_LEFT, 0, '@', .drag = 1.0f , .friction = 1.0f, .velx = -120.0f),
BLOCK(ASSET_BELT_RIGHT, 0, '@', .drag = 1.0f , .friction = 1.0f, .velx = 120.0f),
BLOCK(ASSET_BELT_UP, 0, '@', .drag = 1.0f , .friction = 1.0f, .vely = -120.0f),
BLOCK(ASSET_BELT_DOWN, 0, '@', .drag = 1.0f , .friction = 1.0f, .vely = 120.0f),
BLOCK(ASSET_BELT_LEFT, 0, '@', .drag = 1.0f , .friction = 1.0f, .velx = -150.0f),
BLOCK(ASSET_BELT_RIGHT, 0, '@', .drag = 1.0f , .friction = 1.0f, .velx = 150.0f),
BLOCK(ASSET_BELT_UP, 0, '@', .drag = 1.0f , .friction = 1.0f, .vely = -150.0f),
BLOCK(ASSET_BELT_DOWN, 0, '@', .drag = 1.0f , .friction = 1.0f, .vely = 150.0f),
};

View File

@ -204,8 +204,8 @@ void UseItem(ecs_iter_t *it) {
float p1y = in[i].placements_y[0];
float p2x = in[i].placements_x[1];
float p2y = in[i].placements_y[1];
float sx = zpl_sign(p2x-p1x);
float sy = zpl_sign(p2y-p1y);
float sx = zpl_sign0(p2x-p1x);
float sy = zpl_sign0(p2y-p1y);
ofs = (sx < 0.0f) ? 1 : 2;
if (sx == 0.0f) {
ofs = (sy < 0.0f) ? 3 : 4;

15
code/vendors/zpl.h vendored
View File

@ -31,6 +31,7 @@ GitHub:
https://github.com/zpl-c/zpl
Version History:
15.0.2 - zpl_sign0 was introduced
15.0.1 - hashtable performance improvements
- zpl_sign(0) returns 0
15.0.0 - Rework zpl ring buffer
@ -4415,7 +4416,6 @@ return NULL;
} \
\
void ZPL_JOIN2(FUNC, remove)(NAME * h, zpl_u64 key) { \
zpl_isize i; \
zpl_hash_table_find_result fr = ZPL_JOIN2(FUNC, _find)(h, key); \
if (fr.entry_index >= 0) { \
zpl_array_remove_at(h->entries, fr.entry_index); \
@ -6595,7 +6595,11 @@ typedef short zpl_half;
#endif
#ifndef zpl_sign
#define zpl_sign(x) (x == 0.0f) ? 0.0f : ((x) >= 0.0f ? 1.0f : -1.0f)
#define zpl_sign(x) ((x) >= 0.0f ? 1.0f : -1.0f)
#endif
#ifndef zpl_sign0
#define zpl_sign0(x) ((x == 0.0f) ? 0.0f : ((x) >= 0.0f ? 1.0f : -1.0f))
#endif
ZPL_DEF zpl_f32 zpl_to_radians(zpl_f32 degrees);
@ -18171,9 +18175,4 @@ typedef zpl_intptr intptr;
// source/core/print.c
// source/core/time.c
// source/core/string.c
// source/core/random.c
// source/core/sort.c
// source/core/file_tar.c
// source/opts.c
// source/timer.c
// source/math.c
// source/c