]> git.lizzy.rs Git - dragonblocks_alpha.git/blobdiff - src/client/client_player.c
Add position display
[dragonblocks_alpha.git] / src / client / client_player.c
index e4a3a6c744d98a9b65c75c62f7053d52ae4154dd..0fdd10223b9cd543821142e299f63efd851b8eb5 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include "client/camera.h"
 #include "client/client.h"
 #include "client/client_player.h"
@@ -13,6 +14,11 @@ static void update_pos()
 
        client_player.obj->pos = client_player.pos;
        object_transform(client_player.obj);
+
+       char pos_text[BUFSIZ];
+       sprintf(pos_text, "(%.1f %.1f %.1f)", client_player.pos.x, client_player.pos.y, client_player.pos.z);
+
+       hud_change_text(client_player.pos_display, pos_text);
 }
 
 void client_player_init(Map *map)
@@ -41,6 +47,18 @@ void client_player_add_to_scene()
                }
        }
 
+       client_player.pos_display = hud_add((HUDElementDefinition) {
+               .type = HUD_TEXT,
+               .pos = {-1.0f, -1.0f, 0.0f},
+               .offset = {2, 2 + 16 + 2 + 16 + 2},
+               .type_def = {
+                       .text = {
+                               .text = "",
+                               .color = {1.0f, 1.0f, 1.0f},
+                       },
+               },
+       });
+
        update_pos();
 }