commit b96cc18582bf5deca4d9e739833850c403c619d5
parent 8d95d62d310c89d8a3239e52c804faedf8df1c20
Author: Samdal <samdal@protonmail.com>
Date: Thu, 2 Sep 2021 21:43:56 +0200
added aroom (anders tale room format)
Diffstat:
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/hs_graphics.h b/hs_graphics.h
@@ -87,6 +87,13 @@ typedef struct {
hs_tex_square* vertices;
} hs_tilemap;
+// this is how anders tale rooms are stored
+// in the future a system to add layers must be made
+typedef struct {
+ uint16_t width, height;
+ uint16_t* data;
+} hs_aroom;
+
typedef struct {
uint32_t width, height;
GLFWwindow* window;
@@ -225,6 +232,8 @@ extern void hs_tilemap_draw(const hs_tilemap tilemap);
extern void hs_tilemap_free(hs_tilemap* tilemap);
extern void hs_tilemap_transform(const hs_tilemap tilemap, const mat4 trans);
extern void hs_tilemap_perspective(const hs_tilemap tilemap, const mat4 perspective);
+extern void hs_aroom_set_xy(hs_aroom* aroom, const uint16_t x, const uint16_t y, const uint16_t data);
+extern uint16_t hs_aroom_get_xy(const hs_aroom aroom, const uint16_t x, const uint16_t y);
/* Sprite stuff */
@@ -994,6 +1003,18 @@ hs_tilemap_perspective(const hs_tilemap tilemap, const mat4 perspective)
glUniformMatrix4fv(1, 1, GL_FALSE, castf(perspective));
}
+inline void
+hs_aroom_set_xy(hs_aroom* aroom, const uint16_t x, const uint16_t y, const uint16_t data)
+{
+ aroom->data[x + y * aroom->width] = data;
+}
+
+inline uint16_t
+hs_aroom_get_xy(const hs_aroom aroom, const uint16_t x, const uint16_t y)
+{
+ return aroom.data[x + y * aroom.width];
+}
+
inline hs_shader_program_tex
hs_sprite_create(const char* texture, const GLenum colour_channel, hs_vobj* vobj, const hs_game_data gd)
{