diff options
author | Schark <jordan@schark.online> | 2024-03-06 02:43:51 -0800 |
---|---|---|
committer | Schark <jordan@schark.online> | 2024-03-06 02:43:51 -0800 |
commit | a0480410651c65250ddb135cae61482796a9f086 (patch) | |
tree | 7d3d224de1f08fcd333495f842e02438aff0cfc2 | |
parent | c356e96932b5d1a23bf41914934cf83e8b535994 (diff) | |
download | gamedev-a0480410651c65250ddb135cae61482796a9f086.tar.gz gamedev-a0480410651c65250ddb135cae61482796a9f086.zip |
Modified keybinds and colors for heightmap
Diffstat (limited to '')
-rwxr-xr-x | height-map-display/height-map-display | bin | 17512 -> 17512 bytes | |||
-rw-r--r-- | height-map-display/src/main.c | 55 |
2 files changed, 34 insertions, 21 deletions
diff --git a/height-map-display/height-map-display b/height-map-display/height-map-display Binary files differindex b67544a..df41c3d 100755 --- a/height-map-display/height-map-display +++ b/height-map-display/height-map-display diff --git a/height-map-display/src/main.c b/height-map-display/src/main.c index 5ad5c78..95e6953 100644 --- a/height-map-display/src/main.c +++ b/height-map-display/src/main.c @@ -6,16 +6,29 @@ #define MAP_HEIGHT 10 #define MAP_WIDTH 10 +//int height_map[MAP_WIDTH][MAP_HEIGHT] = { +// {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +// {0, 1, 1, 1, 1, 1, 1, 1, 1, 0}, +// {0, 1, 3, 3, 3, 3, 3, 3, 1, 0}, +// {0, 1, 3, 5, 5, 5, 5, 3, 1, 0}, +// {0, 1, 3, 5, 8, 8, 5, 3, 1, 0}, +// {0, 1, 3, 5, 8, 8, 5, 3, 1, 0}, +// {0, 1, 3, 5, 5, 5, 5, 3, 1, 0}, +// {0, 1, 3, 3, 3, 3, 3, 3, 1, 0}, +// {0, 1, 1, 1, 1, 1, 1, 1, 1, 0}, +// {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +//}; + int height_map[MAP_WIDTH][MAP_HEIGHT] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 1, 1, 1, 1, 1, 1, 1, 1, 0}, - {0, 1, 3, 3, 3, 3, 3, 3, 1, 0}, - {0, 1, 3, 5, 5, 5, 5, 3, 1, 0}, - {0, 1, 3, 5, 8, 8, 5, 3, 1, 0}, - {0, 1, 3, 5, 8, 8, 5, 3, 1, 0}, - {0, 1, 3, 5, 5, 5, 5, 3, 1, 0}, - {0, 1, 3, 3, 3, 3, 3, 3, 1, 0}, - {0, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, -1, -2, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, -1, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 1, 2, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, }; @@ -49,9 +62,9 @@ float camera_pitch = 0.0f; // rotation aroudn x-axis void renderHeightMap() { float colors[3][3] = { - {0.0f, 1.0f, 0.0f}, // Green - {0.5f, 0.5f, 0.5f}, // Gray - {1.0f, 1.0f, 1.0f} // White + {0.0f, 1.0f, 0.0f}, // default green + {0.0f, 0.0f, 1.0f}, // blue + {0.5f, 1.0f, 0.5f} // light green }; float scale_factor = 1.0f; @@ -82,8 +95,8 @@ void renderHeightMap() { float z1 = y; float* color = colors[0]; - if (y0 < 1.0f) { color = colors[1]; } - if (y0 < 0.5f) { color = colors[2]; } + if (y0 > 0.5f) { color = colors[2]; } + if (y0 < -0.5f) { color = colors[1]; } glColor3fv(color); glVertex3f(x0, y0, z0); @@ -124,14 +137,14 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod const float camera_speed = 0.5f; - if (key == GLFW_KEY_W && action == GLFW_PRESS) { camera_pos_z -= camera_speed; } - else if (key == GLFW_KEY_S && action == GLFW_PRESS) { camera_pos_z += camera_speed; } - else if (key == GLFW_KEY_A && action == GLFW_PRESS) { camera_pos_x -= camera_speed; } - else if (key == GLFW_KEY_D && action == GLFW_PRESS) { camera_pos_x += camera_speed; } - else if (key == GLFW_KEY_Q && action == GLFW_PRESS) { camera_pitch -= camera_speed; } - else if (key == GLFW_KEY_E && action == GLFW_PRESS) { camera_pitch += camera_speed; } - else if (key == GLFW_KEY_Z && action == GLFW_PRESS) { camera_yaw -= camera_speed; } - else if (key == GLFW_KEY_C && action == GLFW_PRESS) { camera_yaw += camera_speed; } + if (key == GLFW_KEY_W && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pos_z -= camera_speed; } + else if (key == GLFW_KEY_S && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pos_z += camera_speed; } + else if (key == GLFW_KEY_A && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pos_x -= camera_speed; } + else if (key == GLFW_KEY_D && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pos_x += camera_speed; } + else if (key == GLFW_KEY_Q && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pitch -= camera_speed; } + else if (key == GLFW_KEY_E && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_pitch += camera_speed; } + else if (key == GLFW_KEY_Z && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_yaw -= camera_speed; } + else if (key == GLFW_KEY_C && (action == GLFW_PRESS || action == GLFW_REPEAT)) { camera_yaw += camera_speed; } } |