code: minor qol changes
parent
04175594d4
commit
3fd5e282cf
|
@ -95,7 +95,9 @@ static debug_item items[] = {
|
|||
.is_collapsed = true,
|
||||
.items = (debug_item[]) {
|
||||
{ .kind = DITEM_TEXT, .name = "delta time", .proc = DrawDeltaTime },
|
||||
{ .kind = DITEM_TEXT, .name = "pos", .proc = DrawCameraPos },
|
||||
{ .kind = DITEM_TEXT, .name = "camera pos", .proc = DrawCameraPos },
|
||||
{ .kind = DITEM_TEXT, .name = "mouse block", .proc = DrawBlockPos },
|
||||
{ .kind = DITEM_TEXT, .name = "mouse chunk", .proc = DrawChunkPos },
|
||||
{ .kind = DITEM_TEXT, .name = "zoom", .proc = DrawZoom },
|
||||
{ .kind = DITEM_END },
|
||||
}
|
||||
|
|
|
@ -43,6 +43,23 @@ DrawCameraPos(debug_item *it, float xpos, float ypos) {
|
|||
return DrawFormattedText(xpos, ypos, TextFormat("%d %d", (int)(cam.x/WORLD_BLOCK_SIZE), (int)(cam.y/WORLD_BLOCK_SIZE)));
|
||||
}
|
||||
|
||||
static inline debug_draw_result
|
||||
DrawChunkPos(debug_item *it, float xpos, float ypos) {
|
||||
float mx, my;
|
||||
platform_get_block_realpos(&mx, &my);
|
||||
int csize = world_chunk_size();
|
||||
|
||||
return DrawFormattedText(xpos, ypos, TextFormat("%d %d", (int)(mx/WORLD_BLOCK_SIZE/csize), (int)(my/WORLD_BLOCK_SIZE/csize)));
|
||||
}
|
||||
|
||||
static inline debug_draw_result
|
||||
DrawBlockPos(debug_item *it, float xpos, float ypos) {
|
||||
float mx, my;
|
||||
platform_get_block_realpos(&mx, &my);
|
||||
|
||||
return DrawFormattedText(xpos, ypos, TextFormat("%d %d", (int)(mx/WORLD_BLOCK_SIZE), (int)(my/WORLD_BLOCK_SIZE)));
|
||||
}
|
||||
|
||||
static inline debug_draw_result
|
||||
DrawUnmeasuredTime(debug_item *it, float xpos, float ypos) {
|
||||
(void)it;
|
||||
|
|
|
@ -7,6 +7,7 @@ typedef enum {
|
|||
// NOTE(zaklaus): Debug
|
||||
ASSET_EMPTY,
|
||||
ASSET_BLANK,
|
||||
ASSET_BLOCK_FRAME,
|
||||
ASSET_BUILDMODE_HIGHLIGHT,
|
||||
|
||||
// NOTE(zaklaus): entities
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
static asset assets[] = {
|
||||
ASSET_TEX(ASSET_EMPTY),
|
||||
ASSET_TEX(ASSET_BLANK),
|
||||
ASSET_TEX(ASSET_BLOCK_FRAME),
|
||||
ASSET_TEX(ASSET_BUILDMODE_HIGHLIGHT),
|
||||
ASSET_TEX(ASSET_DEMO_ICEMAKER),
|
||||
ASSET_TEX(ASSET_CHEST),
|
||||
|
|
|
@ -28,6 +28,8 @@ void buildmode_draw(void) {
|
|||
cam.x = (double)mx;
|
||||
cam.y = (double)my;
|
||||
|
||||
renderer_draw_single(cam.x, cam.y, ASSET_BLOCK_FRAME, WHITE);
|
||||
|
||||
// NOTE(zaklaus): Check distance
|
||||
double dx = old_cam.x - cam.x;
|
||||
double dy = old_cam.y - cam.y;
|
||||
|
|
|
@ -169,3 +169,21 @@ float platform_zoom_get(void) {
|
|||
void platform_request_close(void) {
|
||||
request_shutdown = true;
|
||||
}
|
||||
|
||||
void platform_get_block_realpos(float *x, float *y){
|
||||
camera cam = camera_get();
|
||||
Vector2 mpos = GetMousePosition();
|
||||
entity_view *e = game_world_view_active_get_entity(cam.ent_id);
|
||||
if (!e) return;
|
||||
float zoom = renderer_zoom_get();
|
||||
mpos.x -= screenWidth/2.0f;
|
||||
mpos.y -= screenHeight/2.0f;
|
||||
cam.x += mpos.x*(1.0f/zoom);
|
||||
cam.y += mpos.y*(1.0f/zoom);
|
||||
cam.x = ((int32_t)cam.x / (int32_t)(WORLD_BLOCK_SIZE)) * WORLD_BLOCK_SIZE;
|
||||
cam.y = ((int32_t)cam.y / (int32_t)(WORLD_BLOCK_SIZE)) * WORLD_BLOCK_SIZE;
|
||||
cam.x += WORLD_BLOCK_SIZE/2.0f;
|
||||
cam.y += WORLD_BLOCK_SIZE/2.0f;
|
||||
if (x) *x = (float)cam.x;
|
||||
if (y) *y = (float)cam.y;
|
||||
}
|
||||
|
|
|
@ -169,3 +169,21 @@ float platform_zoom_get(void) {
|
|||
void platform_request_close(void) {
|
||||
request_shutdown = true;
|
||||
}
|
||||
|
||||
void platform_get_block_realpos(float *x, float *y){
|
||||
camera cam = camera_get();
|
||||
Vector2 mpos = GetMousePosition();
|
||||
entity_view *e = game_world_view_active_get_entity(cam.ent_id);
|
||||
if (!e) return;
|
||||
float zoom = renderer_zoom_get();
|
||||
mpos.x -= screenWidth/2.0f;
|
||||
mpos.y -= screenHeight/2.0f;
|
||||
cam.x += mpos.x*(1.0f/zoom);
|
||||
cam.y += mpos.y*(1.0f/zoom);
|
||||
cam.x = ((int32_t)cam.x / (int32_t)(WORLD_BLOCK_SIZE)) * WORLD_BLOCK_SIZE;
|
||||
cam.y = ((int32_t)cam.y / (int32_t)(WORLD_BLOCK_SIZE)) * WORLD_BLOCK_SIZE;
|
||||
cam.x += WORLD_BLOCK_SIZE/2.0f;
|
||||
cam.y += WORLD_BLOCK_SIZE/2.0f;
|
||||
if (x) *x = (float)cam.x;
|
||||
if (y) *y = (float)cam.y;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,21 @@ Texture2D GenColorEco(Color color) {
|
|||
return Image2TexEco(img);
|
||||
}
|
||||
|
||||
static inline
|
||||
Texture2D GenFrameRect() {
|
||||
RenderTexture2D temp_texture = LoadRenderTexture(64, 64);
|
||||
|
||||
Color mouse_color_a = {0, 0, 0, 200};
|
||||
Color mouse_color_b = {255, 255, 255, 200};
|
||||
|
||||
BeginTextureMode(temp_texture);
|
||||
DrawRectangleLines(0, 0, 64, 64, mouse_color_a);
|
||||
DrawRectangleLines(1, 1, 62, 62, mouse_color_b);
|
||||
EndTextureMode();
|
||||
|
||||
return temp_texture.texture;
|
||||
}
|
||||
|
||||
Texture2D texgen_build_anim(asset_id id, int64_t counter) {
|
||||
(void)counter;
|
||||
switch (id) {
|
||||
|
@ -46,6 +61,7 @@ Texture2D texgen_build_sprite(asset_id id) {
|
|||
switch (id) {
|
||||
case ASSET_BLANK: return GenColorEco(WHITE); break;
|
||||
case ASSET_BUILDMODE_HIGHLIGHT: return GenColorEco(WHITE); break;
|
||||
case ASSET_BLOCK_FRAME: return GenFrameRect(); break;
|
||||
|
||||
// NOTE(zaklaus): items
|
||||
case ASSET_DEMO_ICEMAKER: return LoadTexEco("demo_icemaker");
|
||||
|
|
Loading…
Reference in New Issue