diff --git a/assets/scenes/basic_2.rt b/assets/scenes/basic_2.rt index dc6f223..922e9ba 100644 --- a/assets/scenes/basic_2.rt +++ b/assets/scenes/basic_2.rt @@ -1,6 +1,6 @@ -C 0,0,-5 0,0,5 90 +C 0,0,-5 0,0,1 90 L 0,2,-2 1 255,255,200 A 0.5 0,0,100 sp 0,0,0 2 234,123,123 sp 0,0,0 2 123,234,123 -cy 0,0,0 0,1,0 1 5 123,123,234 \ No newline at end of file +cy 0,0,0 0,1,0 1 5 123,123,234 diff --git a/assets/scenes/snowman.rt b/assets/scenes/snowman.rt deleted file mode 100644 index a7c92d0..0000000 --- a/assets/scenes/snowman.rt +++ /dev/null @@ -1,10 +0,0 @@ -C 20,20,-20 -20,-20,20 60 -L 0,0.5,-1 1 255,255,200 -A 0.5 100,100,100 -pl 0,-1.5,2 0,-1,0 234,234,123 -sp 0,-1.25,2 1 234,234,234 -sp 0,-0.5,2 0.75 234,234,234 -sp 0,0,2 0.5 234,234,234 -cy 0,0.25,2 0,1,0 0.3 0.3 50,50,50 -di 0,0.2,2 0,1,0 0.5 150,150,150 -cn 0,0,1.3 0,1,100 0.1 0.5 255,200,100 \ No newline at end of file diff --git a/out/miniRT b/out/miniRT index a383822..940a9cf 100755 Binary files a/out/miniRT and b/out/miniRT differ diff --git a/src/io/explorer.c b/src/io/explorer.c index 275d2ba..ddbe6aa 100644 --- a/src/io/explorer.c +++ b/src/io/explorer.c @@ -13,6 +13,8 @@ #include "../../minirt.h" #include +const char *asset_root = ROOT_DIRECTORY"/assets"; + void container_item_dirent_create(t_item *item, char *title, \ int type, void (*func)(void *, void *)) { @@ -31,8 +33,8 @@ void explorer_create(t_container *explorer, t_data *data) ft_fprintf(STDERR_FILENO, "Failed to get current directory, exiting...\n"); lst_memory(NULL, NULL, FAIL); } - if (ft_strncmp(cwd, ROOT_DIRECTORY, ft_strlen(ROOT_DIRECTORY)) != 0) { - if (chdir(ROOT_DIRECTORY) != 0) { + if (ft_strncmp(cwd, asset_root, ft_strlen(asset_root)) != 0) { + if (chdir(asset_root) != 0) { ft_fprintf(STDERR_FILENO, "Failed to change directory, exiting...\n"); lst_memory(NULL, NULL, FAIL); } @@ -46,8 +48,7 @@ void explorer_read_dir_loop(DIR *dir, void *param, \ { struct dirent *entry; t_item item; - - bool is_root_dir = ft_strncmp(cwd, ROOT_DIRECTORY, ft_strlen(cwd)) == 0; + bool is_root_dir = ft_strncmp(cwd, asset_root, ft_strlen(cwd)) == 0; ft_strlcpy(explorer->title, cwd, CONTAINER_TITLE_LEN); while (1) diff --git a/src/io/key_press.c b/src/io/key_press.c index 02768fb..a119da6 100644 --- a/src/io/key_press.c +++ b/src/io/key_press.c @@ -16,6 +16,8 @@ uint key_misc_function(int keycode, t_scene *scene, t_data *data) { if (keycode == KEY_P) scene_save(scene); + else if (keycode == KEY_X) + return (scene->anti_aliasing = scene->anti_aliasing == 0 ? ANTI_ALIASING_FACTOR : 0, true); else if (keycode == KEY_M) return (data->current_menu = &data->menu[MENU_MAIN], true); else if (keycode == KEY_Y) @@ -42,11 +44,11 @@ int key_move_camera(int keycode, t_camera *camera) calc_camera_space(camera); if (keycode == KEY_A || keycode == KEY_D) translation = scale_vector(camera->right, \ - (keycode - KEY_A - 1.5) * 0.66); + (keycode - KEY_A - 1.5) * 0.1); else if (keycode == KEY_W || keycode == KEY_S) - translation = scale_vector(camera->normal, (keycode - KEY_S - 2) * 0.5); + translation = scale_vector(camera->normal, (keycode - KEY_S - 2) * 0.1); else if (keycode == KEY_Q || keycode == KEY_E) - translation = scale_vector(camera->up, (keycode - KEY_E - 6) * 0.33); + translation = scale_vector(camera->up, (keycode - KEY_E - 6) * 0.1); else return (false); camera->position = add_vector(camera->position, translation); diff --git a/src/io/keys.c b/src/io/keys.c index db791fb..915b72f 100644 --- a/src/io/keys.c +++ b/src/io/keys.c @@ -79,7 +79,7 @@ bool calc_camera_rotation(int key, t_camera *camera) float rotation_angle; t_vector perpendicular_normal; - rotation_angle = 10; + rotation_angle = 5; if (key == KEY_UP) { perpendicular_normal = camera->up; diff --git a/src/io/menu.c b/src/io/menu.c index ef97af3..f68fb0a 100644 --- a/src/io/menu.c +++ b/src/io/menu.c @@ -49,15 +49,15 @@ void help_menu_draw(void *data_ptr, void *pixel) (void)pixel; rt_draw_rect_blend(background, data->pixel, 0, HELP_MENU_BG); glyph_print(x + 2, y + 2, \ - "controls\n" \ + "controls\n\n" \ "main menu: m\n" \ "movement: \n" \ "move: wasdqe\n" \ "rotate: arrow keys\n" \ "move light: hjklio\n" \ + "toggle anti aliasing: x\n" \ "select next light: n\n\n" \ "drag object: lmouse\nchange object: rmouse + use menu\n\n" \ - "resolution and anti-aliasing:\n\nnumpad + or -; Enter to reset\n" \ "backsp: reset_cam\n" \ "p: save file\nesc: exit\n", \ data->pixel); diff --git a/src/minirt.c b/src/minirt.c index 3f7df99..d4067d2 100644 --- a/src/minirt.c +++ b/src/minirt.c @@ -112,6 +112,7 @@ void initialize_data(t_data *data, char *path) data->texture = LoadTextureFromImage(img); data->should_rerender = true; pixels_image_syncronize(data->pixel_colors, data->pixel); + SetTargetFPS(60); } char* validate_file_extension(int argc, char **argv) @@ -130,6 +131,34 @@ void get_key_code(int keys[]) { keys[c++] = KEY_ESCAPE; if (c == 3) return; } + if ((IsKeyPressed(KEY_H) || IsKeyDown(KEY_H))) { + keys[c++] = KEY_H; + if (c == 3) return; + } + if ((IsKeyPressed(KEY_L) || IsKeyDown(KEY_L))) { + keys[c++] = KEY_L; + if (c == 3) return ; + } + if ((IsKeyPressed(KEY_K) || IsKeyDown(KEY_K))) { + keys[c++] = KEY_K; + if (c == 3) return ; + } + if ((IsKeyPressed(KEY_I) || IsKeyDown(KEY_I))) { + keys[c++] = KEY_J; + if (c == 3) return ; + } + if ((IsKeyPressed(KEY_O) || IsKeyDown(KEY_O))) { + keys[c++] = KEY_K; + if (c == 3) return ; + } + if ((IsKeyPressed(KEY_J) || IsKeyDown(KEY_J))) { + keys[c++] = KEY_J; + if (c == 3) return ; + } + if ((IsKeyPressed(KEY_X))) { + keys[c++] = KEY_X; + if (c == 3) return ; + } if ((IsKeyPressed(KEY_W) || IsKeyDown(KEY_W))) { keys[c++] = KEY_W; if (c == 3) return; @@ -174,6 +203,10 @@ void get_key_code(int keys[]) { keys[c++] = KEY_M; if (c == 3) return ; } + if (IsKeyPressed(KEY_N)) { + keys[c++] = KEY_N; + if (c == 3) return ; + } if (IsKeyPressed(KEY_P)) { keys[c++] = KEY_P; if (c == 3) return ;